Hook John's kvstore up to the BlueSky implementation.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Tue, 16 Feb 2010 19:17:45 +0000 (11:17 -0800)
committerMichael Vrable <mvrable@cs.ucsd.edu>
Tue, 16 Feb 2010 19:17:45 +0000 (11:17 -0800)
.gitignore
bluesky/CMakeLists.txt
bluesky/init.c
bluesky/store-kv.cc [new file with mode: 0644]
kvstore/CMakeLists.txt
nfs3/CMakeLists.txt

index 85ddf8e..de1736b 100644 (file)
@@ -7,6 +7,7 @@ bluesky/bluesky-test
 kvstore/*.pb.cc
 kvstore/*.pb.h
 kvstore/lib*.a
+kvstore/lib*.so
 kvstore/kvstore
 microbench/bench
 microbench/readbench
index e380312..93b7cb9 100644 (file)
@@ -1,16 +1,17 @@
-include_directories("${LIBS3_BUILD_DIR}/include")
-link_directories("${LIBS3_BUILD_DIR}/lib")
+set(KVSTORE_DIR "${CMAKE_SOURCE_DIR}/kvstore")
+include_directories("${LIBS3_BUILD_DIR}/include" ${KVSTORE_DIR})
+link_directories("${LIBS3_BUILD_DIR}/lib" ${KVSTORE_DIR})
 
 add_library(bluesky SHARED
             cache.c crypto.c debug.c dir.c file.c init.c inode.c serialize.c
-            store.c s3store.c util.c)
+            store.c store-kv.cc s3store.c util.c)
 add_executable(bluesky-test main.c)
 
 set(CMAKE_C_FLAGS "-Wall -std=gnu99 ${CMAKE_C_FLAGS}")
 set(INSTALL_RPATH_USE_LINK_PATH 1)
 
 include_directories(${GLIB_INCLUDE_DIRS})
-target_link_libraries(bluesky ${GLIB_LIBRARIES} gcrypt s3)
+target_link_libraries(bluesky ${GLIB_LIBRARIES} gcrypt s3 kvclient)
 target_link_libraries(bluesky-test bluesky ${GLIB_LIBRARIES})
 
 #set_target_properties(bluesky PROPERTIES LINK_INTERFACE_LIBRARIES "")
index 6f8737b..9fb9332 100644 (file)
@@ -30,6 +30,7 @@ static struct {
 /* BlueSky library initialization. */
 
 void bluesky_store_init_s3(void);
+void bluesky_store_init_kv(void);
 
 /* Initialize the BlueSky library and dependent libraries. */
 void bluesky_init(void)
@@ -47,5 +48,6 @@ void bluesky_init(void)
     }
 
     bluesky_store_init();
+    bluesky_store_init_kv();
     bluesky_store_init_s3();
 }
diff --git a/bluesky/store-kv.cc b/bluesky/store-kv.cc
new file mode 100644 (file)
index 0000000..7a6ac71
--- /dev/null
@@ -0,0 +1,86 @@
+/* Blue Sky: File Systems in the Cloud
+ *
+ * Copyright (C) 2009  The Regents of the University of California
+ * Written by Michael Vrable <mvrable@cs.ucsd.edu>
+ *
+ * TODO: Licensing
+ */
+
+/* Interface to John McCullough's simple key/value store. */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <string.h>
+
+#include "bluesky-private.h"
+#include "kvservice.h"
+#include "kvclient.h"
+
+using namespace boost;
+using namespace kvstore;
+using namespace std;
+
+static gpointer kvstore_new()
+{
+    KeyValueClient *client = new KeyValueClient("127.0.0.1", "9090");
+    return client;
+}
+
+static void kvstore_destroy(gpointer store)
+{
+    KeyValueClient *client = (KeyValueClient *)store;
+    delete client;
+}
+
+static void kvstore_submit(gpointer store, BlueSkyStoreAsync *async)
+{
+    KeyValueClient *client = (KeyValueClient *)store;
+
+    g_return_if_fail(async->status == ASYNC_NEW);
+    g_return_if_fail(async->op != STORE_OP_NONE);
+
+    switch (async->op) {
+    case STORE_OP_GET:
+    {
+        string value;
+        if (client->Get(async->key, &value)) {
+            async->data = bluesky_string_new(g_memdup(value.c_str(),
+                                                    value.length()),
+                                            value.length());
+            async->result = 0;
+        }
+        break;
+    }
+
+    case STORE_OP_PUT:
+    {
+        string value(async->data->data, async->data->len);
+        client->Put(async->key, value);
+        break;
+    }
+
+    default:
+        g_warning("Uknown operation type for MemStore: %d\n", async->op);
+        return;
+    }
+
+    bluesky_store_async_mark_complete(async);
+}
+
+static void kvstore_cleanup(gpointer store, BlueSkyStoreAsync *async)
+{
+    KeyValueClient *client = (KeyValueClient *)store;
+}
+
+static BlueSkyStoreImplementation store_impl = {
+    kvstore_new,
+    kvstore_destroy,
+    kvstore_submit,
+    kvstore_cleanup,
+};
+
+extern "C" void bluesky_store_init_kv(void)
+{
+    bluesky_store_register(&store_impl, "kv");
+}
index 4d7edad..382ddbc 100644 (file)
@@ -1,14 +1,28 @@
 cmake_minimum_required(VERSION 2.6)
+set(CMAKE_BUILD_TYPE Debug)
 
-add_custom_command(OUTPUT kvstore.pb.cc kvstore.pb.h
-                   COMMAND protoc --cpp_out=. kvstore.proto
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/kvstore.pb.cc
+                          ${CMAKE_CURRENT_BINARY_DIR}/kvstore.pb.h
+                   COMMAND protoc --cpp_out=${CMAKE_CURRENT_BINARY_DIR}
+                                  --proto_path=${CMAKE_CURRENT_SOURCE_DIR}
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/kvstore.proto
                    DEPENDS kvstore.proto)
 
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
 add_library(protobufrpc protobufrpc.cc socket_pool.cc workqueue.cc)
-add_library(kvservice kvservice.cc kvstore.pb.cc backend.cc)
-add_library(kvclient kvclient.cc)
+add_library(kvservice kvservice.cc backend.cc
+            ${CMAKE_CURRENT_BINARY_DIR}/kvstore.pb.cc)
+
 add_executable(kvstore kvstore.cc)
 
+add_library(kvclient SHARED
+            kvclient.cc kvservice.cc backend.cc kvstore.pb.cc
+            protobufrpc.cc socket_pool.cc workqueue.cc)
+target_link_libraries(kvclient
+                      boost_thread-mt boost_regex-mt boost_system-mt
+                      boost_program_options-mt db protobuf pthread)
+
 target_link_libraries(kvstore
                       kvservice
                       boost_thread-mt boost_regex-mt boost_system-mt
index 810eccb..ee5e49b 100644 (file)
@@ -1,5 +1,6 @@
-include_directories("${LIBS3_BUILD_DIR}/include")
-link_directories("${LIBS3_BUILD_DIR}/lib")
+set(KVSTORE_DIR "${CMAKE_SOURCE_DIR}/kvstore")
+include_directories("${LIBS3_BUILD_DIR}/include" ${KVSTORE_DIR})
+link_directories("${LIBS3_BUILD_DIR}/lib" ${KVSTORE_DIR})
 
 add_executable(nfsproxy
                common.c nfsd.c rpc.c mount.c nfs3.c