add missing methods to thrift server; temporary CMake fix

git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@3535 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
This commit is contained in:
sears 2012-01-09 19:29:17 +00:00
parent 7bb6c3e166
commit 18b58aa484
2 changed files with 63 additions and 21 deletions

View file

@ -11,7 +11,7 @@ Project(Stasis)
SET(PACKAGE_VERSION 1) SET(PACKAGE_VERSION 1)
SUBDIRS(test util benchmarks) SUBDIRS(test util benchmarks main)
# Main decisions # Main decisions
SET(BUILD_SHARED_LIBS ON) SET(BUILD_SHARED_LIBS ON)
@ -79,10 +79,8 @@ ELSE( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" )
ENDIF ( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" ) ENDIF ( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" )
#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
IF ( HAVE_STASIS ) IF ( HAVE_STASIS )
ADD_LIBRARY(logstore requestDispatch.cpp simpleServer.cpp logserver.cpp logstore.cpp diskTreeComponent.cpp memTreeComponent.cpp datapage.cpp merger.cpp tuplemerger.cpp mergeStats.cpp mergeManager.cpp bloomFilter.c) ADD_LIBRARY(logstore requestDispatch.cpp simpleServer.cpp logserver.cpp logstore.cpp diskTreeComponent.cpp memTreeComponent.cpp datapage.cpp merger.cpp tuplemerger.cpp mergeStats.cpp mergeManager.cpp bloomFilter.c)
CREATE_EXECUTABLE(server)
CREATE_EXECUTABLE(newserver)
ENDIF ( HAVE_STASIS ) ENDIF ( HAVE_STASIS )
ADD_LIBRARY(logstore_client tcpclient.cpp) ADD_LIBRARY(logstore_client tcpclient.cpp)

View file

@ -38,6 +38,10 @@ LSMServerHandler(int argc, char **argv)
stasis_buffer_manager_size = (1024LL * 1024LL * 1024LL * 2LL) / PAGE_SIZE; // 10GB total stasis_buffer_manager_size = (1024LL * 1024LL * 1024LL * 2LL) / PAGE_SIZE; // 10GB total
c0_size = 1024LL * 1024LL * 1024LL * 8LL; c0_size = 1024LL * 1024LL * 1024LL * 8LL;
printf("note: running w/ 10GB of memory for benchmarking\n"); // XXX build a separate test server and deployment server? printf("note: running w/ 10GB of memory for benchmarking\n"); // XXX build a separate test server and deployment server?
} else if(!strcmp(argv[i], "--benchmark-small")) {
stasis_buffer_manager_size = (1024LL * 1024LL * 1024LL * 2LL) / PAGE_SIZE; // 5GB total
c0_size = 1024LL * 1024LL * 1024LL * 3LL;
printf("note: running w/ 5GB of memory for benchmarking on small box\n");
} else if(!strcmp(argv[i], "--log-mode")) { } else if(!strcmp(argv[i], "--log-mode")) {
i++; i++;
log_mode = atoi(argv[i]); log_mode = atoi(argv[i]);
@ -47,7 +51,7 @@ LSMServerHandler(int argc, char **argv)
i++; i++;
expiry_delta = atoi(argv[i]); expiry_delta = atoi(argv[i]);
} else { } else {
fprintf(stderr, "Usage: %s [--test|--benchmark] [--log-mode <int>] [--expiry-delta <int>]", argv[0]); fprintf(stderr, "Usage: %s [--test|--benchmark|--benchmark-small] [--log-mode <int>] [--expiry-delta <int>]", argv[0]);
abort(); abort();
} }
} }
@ -162,30 +166,65 @@ addMap(const std::string& databaseName)
return insert(tup); return insert(tup);
} }
/**
* TODO:
* Don't just remove database from databaseIds. You need to delete
* all the records!
*/
ResponseCode::type LSMServerHandler:: ResponseCode::type LSMServerHandler::
dropMap(const std::string& databaseName) dropMap(const std::string& databaseName)
{ {
#if 0 uint32_t id = getDatabaseId(databaseName);
Bdb::ResponseCode rc = databaseIds_.remove(databaseName); if(id == 0) {
if (rc == Bdb::KeyNotFound) { return mapkeeper::ResponseCode::MapNotFound;
return mapkeeper::ResponseCode::MapNotFound; }
} else if (rc != Bdb::Success) { datatuple * tup = buildTuple(0, databaseName);
return mapkeeper::ResponseCode::Error; datatuple * exists = get(tup);
} else {
return mapkeeper::ResponseCode::Success; if(exists) {
datatuple::freetuple(exists);
datatuple * startKey = buildTuple(id, "");
logtable::iterator * itr = new logtable::iterator(ltable_, startKey);
datatuple::freetuple(startKey);
datatuple * current;
// insert tombstone; deletes metadata entry for map; frees tup
insert(tup);
while(NULL != (current = itr->getnext())) {
if(*((uint32_t*)current->strippedkey()) != id) {
datatuple::freetuple(current);
break;
}
datatuple * del = datatuple::create(current->strippedkey(), current->strippedkeylen());
ltable_->insertTuple(del);
datatuple::freetuple(del);
datatuple::freetuple(current);
} }
#endif delete itr;
return mapkeeper::ResponseCode::Success; return mapkeeper::ResponseCode::Success;
} else {
datatuple::freetuple(tup);
return mapkeeper::ResponseCode::MapNotFound;
}
} }
void LSMServerHandler:: void LSMServerHandler::
listMaps(StringListResponse& _return) listMaps(StringListResponse& _return)
{ {
datatuple * startKey = buildTuple(0, "");
logtable::iterator * itr = new logtable::iterator(ltable_, startKey);
datatuple::freetuple(startKey);
datatuple * current;
while(NULL != (current = itr->getnext())) {
if(*((uint32_t*)current->strippedkey()) != 0) {
datatuple::freetuple(current);
break;
}
_return.values.push_back(
std::string((char*)(current->strippedkey()) + sizeof(uint32_t),
current->strippedkeylen() - sizeof(uint32_t)));
datatuple::freetuple(current);
}
delete itr;
_return.responseCode = mapkeeper::ResponseCode::Success;
} }
void LSMServerHandler:: void LSMServerHandler::
@ -308,7 +347,12 @@ put(const std::string& databaseName,
const std::string& recordName, const std::string& recordName,
const std::string& recordBody) const std::string& recordBody)
{ {
return mapkeeper::ResponseCode::Success; uint32_t id = getDatabaseId(databaseName);
if (id == 0) {
return mapkeeper::ResponseCode::MapNotFound;
}
datatuple* tup = buildTuple(id, recordName, recordBody);
return insert(tup);
} }
ResponseCode::type LSMServerHandler:: ResponseCode::type LSMServerHandler::