1 /* Blue Sky: File Systems in the Cloud
3 * Copyright (C) 2009 The Regents of the University of California
4 * Written by Michael Vrable <mvrable@cs.ucsd.edu>
9 /* Interface to John McCullough's simple key/value store. */
16 #include "bluesky-private.h"
17 #include "kvservice.h"
20 using namespace boost;
21 using namespace kvstore;
24 static gpointer kvstore_new()
26 KeyValueClient *client = new KeyValueClient("127.0.0.1", "9090");
30 static void kvstore_destroy(gpointer store)
32 KeyValueClient *client = (KeyValueClient *)store;
36 static void kvstore_submit(gpointer store, BlueSkyStoreAsync *async)
38 KeyValueClient *client = (KeyValueClient *)store;
40 g_return_if_fail(async->status == ASYNC_NEW);
41 g_return_if_fail(async->op != STORE_OP_NONE);
47 if (client->Get(async->key, &value)) {
48 async->data = bluesky_string_new(g_memdup(value.c_str(),
58 string value(async->data->data, async->data->len);
59 client->Put(async->key, value);
64 g_warning("Uknown operation type for MemStore: %d\n", async->op);
68 bluesky_store_async_mark_complete(async);
71 static void kvstore_cleanup(gpointer store, BlueSkyStoreAsync *async)
73 KeyValueClient *client = (KeyValueClient *)store;
76 static BlueSkyStoreImplementation store_impl = {
83 extern "C" void bluesky_store_init_kv(void)
85 bluesky_store_register(&store_impl, "kv");