Skip to content
Snippets Groups Projects
Commit d8fa2270 authored by Irene Zhang's avatar Irene Zhang
Browse files

updating a bunch of make files and removing some .cc files

parent a9a320ac
No related branches found
No related tags found
No related merge requests found
......@@ -4,10 +4,10 @@ SRCS += $(addprefix $(d), benchClient.cc retwisClient.cc terminalClient.cc)
OBJS-all-clients := $(OBJS-strong-client) $(OBJS-weak-client) $(OBJS-tapir-client)
$(d)benchClient: $(LIB-store-common) $(OBJS-all-clients) $(o)benchClient.o
$(d)benchClient: $(OBJS-all-clients) $(o)benchClient.o
$(d)retwisClient: $(LIB-store-common) $(OBJS-all-clients) $(o)retwisClient.o
$(d)retwisClient: $(OBJS-all-clients) $(o)retwisClient.o
$(d)terminalClient: $(LIB-store-common) $(OBJS-all-clients) $(o)terminalClient.o
$(d)terminalClient: $(OBJS-all-clients) $(o)terminalClient.o
BINS += $(d)benchClient $(d)retwisClient $(d)terminalClient
d := $(dir $(lastword $(MAKEFILE_LIST)))
SRCS += $(addprefix $(d), bufferclient.cc txnclient.cc client.cc)
SRCS += $(addprefix $(d), bufferclient.cc)
LIB-store-frontend := $(o)bufferclient.o $(o)txnclient.o $(o)client.o
LIB-store-frontend := $(o)bufferclient.o
// -*- mode: c++; c-file-style: "k&r"; c-basic-offset: 4 -*-
/***********************************************************************
*
* common/client.cc:
* Interface for a multiple shard transactional client.
*
**********************************************************************/
#include "store/common/frontend/client.h"
using namespace std;
Client::Client() { }
Client::~Client() { }
void
Client::Begin()
{
Panic("BEGIN Unimplemented");
}
int
Client::Get(const string &key, string &value)
{
Panic("GET Unimplemented");
return 0;
}
int
Client::Put(const string &key, const string &value)
{
Panic("PUT Unimplemented");
return 0;
}
bool
Client::Commit()
{
Panic("COMMIT Unimplemented");
return false;
}
void
Client::Abort()
{
Panic("ABORT Unimplemented");
}
vector<int>
Client::Stats()
{
Panic("STATS Unimplemented");
vector<int> v;
return v;
}
/* Takes a key and number of shards; returns shard corresponding to key. */
uint64_t
Client::key_to_shard(const string &key, uint64_t nshards)
{
uint64_t hash = 5381;
const char* str = key.c_str();
for (unsigned int i = 0; i < key.length(); i++) {
hash = ((hash << 5) + hash) + (uint64_t)str[i];
}
return (hash % nshards);
}
......@@ -17,29 +17,37 @@
class Client
{
public:
Client();
~Client();
Client() {};
virtual ~Client() {};
// Begin a transaction.
virtual void Begin();
virtual void Begin() = 0;
// Get the value corresponding to key.
virtual int Get(const std::string &key, std::string &value);
virtual int Get(const std::string &key, std::string &value) = 0;
// Set the value for the given key.
virtual int Put(const std::string &key, const std::string &value);
virtual int Put(const std::string &key, const std::string &value) = 0;
// Commit all Get(s) and Put(s) since Begin().
virtual bool Commit();
virtual bool Commit() = 0;
// Abort all Get(s) and Put(s) since Begin().
virtual void Abort();
virtual void Abort() = 0;
// Returns statistics (vector of integers) about most recent transaction.
virtual std::vector<int> Stats();
virtual std::vector<int> Stats() = 0;
// Sharding logic: Given key, generates a number b/w 0 to nshards-1
uint64_t key_to_shard(const std::string &key, uint64_t nshards);
uint64_t key_to_shard(const std::string &key, uint64_t nshards) {
uint64_t hash = 5381;
const char* str = key.c_str();
for (unsigned int i = 0; i < key.length(); i++) {
hash = ((hash << 5) + hash) + (uint64_t)str[i];
}
return (hash % nshards);
};
};
#endif /* _CLIENT_API_H_ */
// -*- mode: c++; c-file-style: "k&r"; c-basic-offset: 4 -*-
/***********************************************************************
*
* store/common/frontend/txnclient.cc
* Client interface for a single replicated shard.
*
* Copyright 2015 Irene Zhang <iyzhang@cs.washington.edu>
* Naveen Kr. Sharma <naveenks@cs.washington.edu>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**********************************************************************/
#include "store/common/frontend/txnclient.h"
using namespace std;
TxnClient::TxnClient() { }
TxnClient::~TxnClient() { }
void
TxnClient::Begin(uint64_t id)
{
Panic("Unimplemented BEGIN");
}
void
TxnClient::Get(uint64_t id,
const string &key,
Promise *promise)
{
Panic("Unimplemented GET");
return;
}
void
TxnClient::Get(uint64_t id,
const string &key,
const Timestamp &timestamp,
Promise *promise)
{
Panic("Unimplemented GET");
return;
}
void
TxnClient::Put(uint64_t id,
const string &key,
const string &value,
Promise *promise)
{
Panic("Unimplemented PUT");
return;
}
void
TxnClient::Prepare(uint64_t id,
const Transaction &txn,
const Timestamp &timestamp,
Promise *promise)
{
Panic("Unimplemented PREPARE");
}
void
TxnClient::Commit(uint64_t id,
const Transaction &txn,
uint64_t timestamp,
Promise *promise)
{
Panic("Unimplemented COMMIT");
return;
}
void
TxnClient::Abort(uint64_t id,
const Transaction &txn,
Promise *promise)
{
Panic("Unimplemented ABORT");
return;
}
......@@ -58,44 +58,44 @@
class TxnClient
{
public:
TxnClient();
~TxnClient();
TxnClient() {};
virtual ~TxnClient() {};
// Begin a transaction.
virtual void Begin(uint64_t id);
virtual void Begin(uint64_t id) = 0;
// Get the value corresponding to key (valid at given timestamp).
virtual void Get(uint64_t id,
const std::string &key,
Promise *promise = NULL);
Promise *promise = NULL) = 0;
virtual void Get(uint64_t id,
const std::string &key,
const Timestamp &timestamp,
Promise *promise = NULL);
Promise *promise = NULL) = 0;
// Set the value for the given key.
virtual void Put(uint64_t id,
const std::string &key,
const std::string &value,
Promise *promise = NULL);
Promise *promise = NULL) = 0;
// Prepare the transaction.
virtual void Prepare(uint64_t id,
const Transaction &txn,
const Timestamp &timestamp = Timestamp(),
Promise *promise = NULL);
Promise *promise = NULL) = 0;
// Commit all Get(s) and Put(s) since Begin().
virtual void Commit(uint64_t id,
const Transaction &txn = Transaction(),
uint64_t timestamp = 0,
Promise *promise = NULL);
Promise *promise = NULL) = 0;
// Abort all Get(s) and Put(s) since Begin().
virtual void Abort(uint64_t id,
const Transaction &txn = Transaction(),
Promise *promise = NULL);
Promise *promise = NULL) = 0;
};
#endif /* _TXN_CLIENT_H_ */
......@@ -10,7 +10,7 @@ LIB-strong-store := $(o)occstore.o $(o)lockstore.o
OBJS-strong-store := $(LIB-message) $(LIB-strong-store) $(LIB-store-common) \
$(LIB-store-backend) $(o)strong-proto.o $(o)server.o
OBJS-strong-client := $(OBJS-vr-client) $(o)strong-proto.o $(o)shardclient.o $(o)client.o
OBJS-strong-client := $(OBJS-vr-client) $(LIB-store-frontend) $(LIB-store-common) $(o)strong-proto.o $(o)shardclient.o $(o)client.o
$(d)server: $(LIB-udptransport) $(OBJS-vr-replica) $(OBJS-strong-store)
......
......@@ -149,6 +149,16 @@ ShardClient::Get(uint64_t id, const string &key,
});
}
void
ShardClient::Put(uint64_t id,
const string &key,
const string &value,
Promise *promise)
{
Panic("Unimplemented PUT");
return;
}
void
ShardClient::Prepare(uint64_t id, const Transaction &txn,
const Timestamp &timestamp, Promise *promise)
......
......@@ -77,6 +77,10 @@ public:
const std::string &key,
const Timestamp &timestamp,
Promise *promise = NULL);
void Put(uint64_t id,
const std::string &key,
const std::string &value,
Promise *promise = NULL);
void Prepare(uint64_t id,
const Transaction &txn,
const Timestamp &timestamp = Timestamp(),
......
......@@ -37,7 +37,7 @@ using namespace std;
Client::Client(const string configPath, int nShards,
int closestReplica, TrueTime timeServer)
: transport(0.0, 0.0, 0), timeServer(timeServer)
: nshards(nShards), transport(0.0, 0.0, 0), timeServer(timeServer)
{
// Initialize all state here;
client_id = 0;
......@@ -49,23 +49,24 @@ Client::Client(const string configPath, int nShards,
}
t_id = (client_id/10000)*10000;
nshards = nShards;
bclient.reserve(nshards);
Debug("Initializing Tapir client with id [%lu]", client_id);
Debug("Initializing Tapir client with id [%lu] %lu", client_id, nshards);
/* Start a client for each shard. */
for (int i = 0; i < nShards; i++) {
for (int i = 0; i < nshards; i++) {
string shardConfigPath = configPath + to_string(i) + ".config";
ShardClient *shardclient = new ShardClient(shardConfigPath,
&transport, client_id, i, closestReplica);
bclient[i] = new BufferClient(shardclient);
}
Debug("Tapir client [%lu] created! %lu %lu", client_id, nshards, bclient.size());
/* Run the transport in a new thread. */
clientTransport = new thread(&Client::run_client, this);
Debug("Tapir client [%lu] created!", client_id);
Debug("Tapir client [%lu] created! %lu", client_id, bclient.size());
}
Client::~Client()
......@@ -104,7 +105,7 @@ Client::Get(const string &key, string &value)
Debug("GET Operation [%s]", key.c_str());
// Contact the appropriate shard to get the value.
int i = key_to_shard(key, nshards);
int i = key_to_shard(key, bclient.size());
// If needed, add this shard to set of participants and send BEGIN.
if (participants.find(i) == participants.end()) {
......
......@@ -145,6 +145,16 @@ ShardClient::Get(uint64_t id, const string &key,
});
}
void
ShardClient::Put(uint64_t id,
const string &key,
const string &value,
Promise *promise)
{
Panic("Unimplemented PUT");
return;
}
void
ShardClient::Prepare(uint64_t id, const Transaction &txn,
const Timestamp &timestamp, Promise *promise)
......
......@@ -65,6 +65,10 @@ public:
const std::string &key,
const Timestamp &timestamp,
Promise *promise = NULL);
void Put(uint64_t id,
const std::string &key,
const std::string &value,
Promise *promise = NULL);
void Prepare(uint64_t id,
const Transaction &txn,
const Timestamp &timestamp = Timestamp(),
......
......@@ -8,7 +8,7 @@ OBJS-weak-server := $(LIB-message) $(LIB-udptransport) $(LIB-request) \
$(LIB-store-common) $(LIB-store-backend) \
$(o)weak-proto.o $(o)store.o $(o)server.o
OBJS-weak-client := $(LIB-message) $(LIB-udptransport) $(LIB-request) $(LIB-store-frontend) \
OBJS-weak-client := $(LIB-message) $(LIB-udptransport) $(LIB-request) $(LIB-store-common) $(LIB-store-frontend) \
$(o)weak-proto.o $(o)shardclient.o $(o)client.o
$(d)server: $(OBJS-weak-server)
......
......@@ -115,4 +115,11 @@ Client::Put(const string &key,
return promise.GetReply();
}
vector<int>
Client::Stats()
{
vector<int> v;
return v;
}
} // namespace weakstore
......@@ -62,7 +62,8 @@ public:
int Put(const std::string &key, const std::string &value);
bool Commit() { return true; };
void Abort() {};
std::vector<int> Stats();
private:
/* Private helper functions. */
void run_client(); // Runs the transport event loop.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment