2011-08-23 00:10:43 +00:00
|
|
|
#include "MapKeeper.h"
|
2011-05-11 22:27:48 +00:00
|
|
|
#include <protocol/TBinaryProtocol.h>
|
|
|
|
#include <transport/TServerSocket.h>
|
|
|
|
#include <transport/TBufferTransports.h>
|
|
|
|
|
|
|
|
using namespace ::apache::thrift;
|
|
|
|
using namespace ::apache::thrift::protocol;
|
|
|
|
using namespace ::apache::thrift::transport;
|
|
|
|
|
2011-08-23 00:10:43 +00:00
|
|
|
using namespace mapkeeper;
|
2011-05-11 22:27:48 +00:00
|
|
|
using boost::shared_ptr;
|
|
|
|
|
2011-08-23 00:10:43 +00:00
|
|
|
class LSMServerHandler : virtual public MapKeeperIf {
|
2011-05-11 22:27:48 +00:00
|
|
|
public:
|
|
|
|
LSMServerHandler(int argc, char **argv);
|
|
|
|
ResponseCode::type ping();
|
2011-06-08 23:58:29 +00:00
|
|
|
ResponseCode::type shutdown();
|
2011-08-23 00:10:43 +00:00
|
|
|
ResponseCode::type addMap(const std::string& databaseName);
|
|
|
|
ResponseCode::type dropMap(const std::string& databaseName);
|
|
|
|
void listMaps(StringListResponse& _return);
|
2011-05-11 22:27:48 +00:00
|
|
|
void scan(RecordListResponse& _return, const std::string& databaseName, const ScanOrder::type order,
|
|
|
|
const std::string& startKey, const bool startKeyIncluded,
|
|
|
|
const std::string& endKey, const bool endKeyIncluded,
|
|
|
|
const int32_t maxRecords, const int32_t maxBytes);
|
|
|
|
void get(BinaryResponse& _return, const std::string& databaseName, const std::string& recordName);
|
2011-08-23 00:10:43 +00:00
|
|
|
ResponseCode::type put(const std::string& databaseName, const std::string& recordName, const std::string& recordBody);
|
2011-05-11 22:27:48 +00:00
|
|
|
ResponseCode::type insert(const std::string& databaseName, const std::string& recordName, const std::string& recordBody);
|
|
|
|
ResponseCode::type insertMany(const std::string& databaseName, const std::vector<Record> & records);
|
|
|
|
ResponseCode::type update(const std::string& databaseName, const std::string& recordName, const std::string& recordBody);
|
|
|
|
ResponseCode::type remove(const std::string& databaseName, const std::string& recordName);
|
|
|
|
|
|
|
|
private:
|
2011-05-12 00:30:02 +00:00
|
|
|
ResponseCode::type insert(datatuple* tuple);
|
|
|
|
uint32_t getDatabaseId(const std::string& databaseName);
|
2011-05-12 20:41:18 +00:00
|
|
|
uint32_t nextDatabaseId();
|
2011-05-12 00:30:02 +00:00
|
|
|
datatuple* get(uint32_t databaseId, const std::string& recordName);
|
|
|
|
datatuple* get(datatuple* tuple);
|
|
|
|
datatuple* buildTuple(uint32_t databaseId, const std::string& recordName);
|
|
|
|
datatuple* buildTuple(uint32_t databaseId, const std::string& recordName, const std::string& recordBody);
|
|
|
|
datatuple* buildTuple(uint32_t databaseId, const std::string& recordName, const void* body, uint32_t bodySize);
|
2011-05-12 20:41:18 +00:00
|
|
|
void initNextDatabaseId();
|
2011-06-09 01:43:46 +00:00
|
|
|
logtable* ltable_;
|
2011-05-12 00:30:02 +00:00
|
|
|
uint32_t nextDatabaseId_;
|
2011-05-12 20:41:18 +00:00
|
|
|
pthread_mutex_t mutex_;
|
2011-05-11 22:27:48 +00:00
|
|
|
};
|