Commit dc34e6e6 authored by Matthieu Dorier's avatar Matthieu Dorier

removed deprecated files

parent ccbf9bb6
......@@ -96,8 +96,6 @@ include_HEADERS = include/sdskv-client.h \
include/sdskv-common.hpp
noinst_HEADERS = src/bulk.h \
src/sds-keyval.h \
src/sds-keyval-group.h \
src/sdskv-rpc-types.h \
src/datastore/datastore.h \
src/datastore/map_datastore.h \
......@@ -105,11 +103,13 @@ noinst_HEADERS = src/bulk.h \
src/datastore/leveldb_datastore.h \
src/datastore/berkeleydb_datastore.h \
src/datastore/datastore_factory.h \
src/keyval-internal.h \
src/BwTree/src/bwtree.h \
src/BwTree/src/atomic_stack.h\
src/BwTree/src/bloom_filter.h \
src/BwTree/src/sorted_small_set.h
# src/sds-keyval.h \
# src/sds-keyval-group.h \
# src/keyval-internal.h
#lib_libkvgroupserver_la_SOURCES = src/kvgroup-server.cc
......
......@@ -6,7 +6,7 @@ AC_INIT([sds-keyval], [0.1.4], [robl@mcs.anl.gov])
AM_INIT_AUTOMAKE([1.13.4 -Wall -Werror foreign subdir-objects silent-rules])
AM_SILENT_RULES([yes])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src/sds-keyval.h])
AC_CONFIG_SRCDIR([src/sdskv-rpc-types.h])
AC_CONFIG_HEADERS([src/kv-config.h])
LT_PREREQ([2.2])
# LT_INIT needs to know about AR
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#include "keyval-internal.h"
#include "sds-keyval-group.h"
#include "kv-config.h"
#include <stdlib.h>
#include <time.h>
#include <assert.h>
#include <iostream>
#include <boost/filesystem.hpp>
unsigned long server_indexes[CH_MAX_REPLICATION];
extern "C" kv_group_t *kvgroup_client_register(margo_instance_id mid, ssg_group_id_t gid)
{
kv_group_t *group = (kv_group_t*)calloc(1, sizeof(group));
int sret = ssg_init(mid);
assert(sret == SSG_SUCCESS);
sret = ssg_group_attach(gid);
assert(sret == SSG_SUCCESS);
/* update kvgroup_context_t with MID, GID */
group->mid = mid;
group->gid = gid;
return group;
}
extern "C" hg_return_t kvgroup_open(kv_group_t *group, const char *db_name, kv_db_type_t db_type)
{
hg_size_t addr_str_sz = 128;
char addr_str[addr_str_sz];
hg_return_t ret = HG_SUCCESS;
std::string dbname(db_name);
boost::filesystem::path p(dbname);
std::string basepath = p.parent_path().string();
std::string name = p.filename().string();
std::string separator("/");
// register and open a connection with each kv-server in the group
hg_size_t gsize = ssg_get_group_size(group->gid);
group->gsize = gsize;
/* one 'context' for sds-keyval itself; one 'database' per server */
group->kv_context = (kv_context_t *)calloc(1,sizeof(kv_context_t));
group->db = (kv_database_t **) calloc(gsize, sizeof(kv_database_t *));
// register this client context with Margo
group->kv_context = kv_client_register(group->mid);
assert(group->kv_context != NULL);
for (hg_size_t i=0; i<gsize; i++) {
hg_addr_t server_addr = ssg_get_addr(group->gid, i);
hg_size_t str_size = addr_str_sz;
// turn server_addr into string
ret = margo_addr_to_string(group->mid, addr_str, &str_size, server_addr);
assert(ret == HG_SUCCESS);
margo_addr_free(group->mid, server_addr);
std::string server_dbname = basepath + separator + std::string("kvdb.") + std::to_string(i)
+ separator + name; // each session uses unique db name
// open client connection with this server
std::cout << "request open of " << server_dbname << " from server " << addr_str << std::endl;
group->db[i] = kv_open(group->kv_context, addr_str, server_dbname.c_str(), db_type);
assert(ret == HG_SUCCESS);
}
// initialize consistent hash using "hash_lookup3" with gsize servers each with 1 virtual node for now
group->ch_instance = ch_placement_initialize("hash_lookup3", gsize, 4, 0);
return HG_SUCCESS;
}
// oid is unique associated with key
// in ParSplice key is already a uint64_t hashed value
extern "C" hg_return_t kvgroup_put(kv_group_t * group, uint64_t oid,
void *key, hg_size_t ksize,
void *value, hg_size_t vsize)
{
// not using any replication for now (is this right?)
ch_placement_find_closest(group->ch_instance, oid, 1, server_indexes);
std::cout << "kvgroup_put: key=" << oid << ", server_index=" << server_indexes[0] << std::endl;
return kv_put(group->db[server_indexes[0]], key, ksize, value, vsize);
}
// oid is unique associated with key
// in ParSplice key is already a uint64_t hashed value
// vsize is in/out
extern "C" hg_return_t kvgroup_get(kv_group_t *group, uint64_t oid,
void *key, hg_size_t ksize,
void *value, hg_size_t *vsize)
{
// not using any replication for now (is this right?)
ch_placement_find_closest(group->ch_instance, oid, 1, server_indexes);
std::cout << "kvgroup_get: key=" << oid << ", server_index=" << server_indexes[0] << std::endl;
return kv_get(group->db[server_indexes[0]], key, ksize, value, vsize);
}
extern "C" hg_return_t kvgroup_close(kv_group_t * group)
{
hg_return_t ret;
for (hg_size_t i=0; i<group->gsize; i++) {
ret = kv_close(group->db[i]);
assert(ret == HG_SUCCESS);
}
return HG_SUCCESS;
}
extern "C" hg_return_t kvgroup_client_deregister(kv_group_t * group)
{
hg_return_t ret;
ret = kv_client_deregister(group->kv_context);
ch_placement_finalize(group->ch_instance);
ssg_group_detach(group->gid);
ssg_finalize();
margo_diag_dump(group->mid, "-", 0);
//margo_finalize(context->mid); // workaround since we core dump here
ssg_group_id_free(group->gid);
free(group->kv_context);
free(group->db);
free(group);
return ret;
}
// only one client calls shutdown
extern "C" hg_return_t kvgroup_client_signal_shutdown(kv_group_t *group)
{
hg_return_t ret;
for (hg_size_t i=0; i<group->gsize; i++) {
ret = kv_client_signal_shutdown(group->db[i]);
assert(ret == HG_SUCCESS);
}
return HG_SUCCESS;
}
// collective along with kvgroup_server_send_gid
// single server rank calls send, all client ranks call recv
// gid is an output argument
extern "C" void kvgroup_client_recv_gid(ssg_group_id_t *gid, MPI_Comm comm)
{
char *serialized_gid = NULL;
size_t gid_size = 0;
int rank;
MPI_Comm_rank(comm, &rank);
// recv size first
MPI_Bcast(&gid_size, 1, MPI_UNSIGNED_LONG, 0, comm);
std::cout << "kvgroup_client_recv_gid: comm rank " << rank << ", recv'd gid size " << gid_size << std::endl;
assert(gid_size != 0);
// then recv data
serialized_gid = (char*)malloc(gid_size);
MPI_Bcast(serialized_gid, gid_size, MPI_BYTE, 0, comm);
ssg_group_id_deserialize(serialized_gid, gid_size, gid);
free(serialized_gid);
}
#include "sds-keyval-group.h"
#include <stdlib.h>
#include <time.h>
#include <assert.h>
#include <iostream>
/* a stub for now */
static void group_update_cb(ssg_membership_update_t update, void *cb_dat)
{
int my_world_rank = *(int *)cb_dat;
if (update.type == SSG_MEMBER_ADD)
printf("%d SSG update: ADD member %lu\n", my_world_rank, update.member);
else if (update.type == SSG_MEMBER_REMOVE)
printf("%d SSG update: REMOVE member %lu\n", my_world_rank, update.member);
return;
}
/* this is a collective operation */
extern "C" kv_group_t *kvgroup_server_register(margo_instance_id mid,
const char *ssg_name, MPI_Comm ssg_comm)
{
kv_group_t * group = (kv_group_t *)calloc(1, sizeof(kv_group_t));
/* update kvgroup_context_t with MID */
group->mid = mid;
group->db = (kv_database_t **)malloc(sizeof(kv_database_t*)); // just 1
group->kv_context = kv_server_register(mid);
assert(group->kv_context != NULL);
int sret = ssg_init(mid);
assert(sret == SSG_SUCCESS);
int my_world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &my_world_rank);
ssg_group_id_t gid = ssg_group_create_mpi(ssg_name, ssg_comm, &group_update_cb, &my_world_rank);
assert(gid != SSG_GROUP_ID_NULL);
/* update kvgroup_context_t with GID */
group->gid = gid;
return group;
}
extern "C" hg_return_t kvgroup_server_deregister(kv_group_t *group)
{
hg_return_t ret = kv_server_deregister(group->kv_context);
ssg_group_destroy(group->gid);
free(group->kv_context);
free(group);
std::cout << "GROUP_SERVER: deregistered" << std::endl;
return ret;
}
extern "C" hg_return_t kvgroup_server_wait_for_shutdown(kv_group_t *group)
{
hg_return_t ret = kv_server_wait_for_shutdown(group->kv_context);
return ret;
}
// collective along with kvgroup_client_recv_gid
// single server rank calls send, all client ranks call recv
// gid is an input argument
extern "C" void kvgroup_server_send_gid(ssg_group_id_t gid, MPI_Comm comm)
{
char *serialized_gid = NULL;
size_t gid_size = 0;
int rank;
MPI_Comm_rank(comm, &rank);
ssg_group_id_serialize(gid, &serialized_gid, &gid_size);
assert(serialized_gid != NULL && gid_size != 0);
std::cout << "kvgroup_server_send_gid: comm rank " << rank << ", sending gid size " << gid_size << std::endl;
// send size first
MPI_Bcast(&gid_size, 1, MPI_UNSIGNED_LONG, 0, comm);
// then send data
MPI_Bcast(serialized_gid, gid_size, MPI_BYTE, 0, comm);
free(serialized_gid);
}
#include <assert.h>
#include "sds-keyval.h"
/* initial implementation requires MPI */
#include <mpi.h>
#include <ssg.h>
#include <ssg-mpi.h>
#include "ch-placement.h"
#ifndef sds_keyval_group_h
#define sds_keyval_group_h
#if defined(__cplusplus)
extern "C" {
#endif
typedef struct kv_group_s {
kv_context_t *kv_context;
kv_database_t **db;
margo_instance_id mid;
ssg_group_id_t gid; // SSG ID
hg_size_t gsize; // size of SSG
struct ch_placement_instance *ch_instance;
} kv_group_t;
// helper routine for stripping protocol part of address string
// stored in ssg_group_id_t data structure
// clients can use to dynamically match server's protocol
// caller is responsible for freeing up char buffer
static inline char *kvgroup_protocol(ssg_group_id_t gid) {
char *addr_str;
int psize = 24;
char *protocol = (char*)malloc(psize);
memset(protocol, 0, psize);
/* figure out protocol to connect with using address information
* associated with the SSG group ID
*/
addr_str = ssg_group_id_get_addr_str(gid);
assert(addr_str != NULL);
/* we only need to the proto portion of the address to initialize */
for(int i=0; i<psize && addr_str[i] != '\0' && addr_str[i] != ':'; i++)
protocol[i] = addr_str[i];
return protocol;
}
kv_group_t *kvgroup_server_register(margo_instance_id mid,
const char *ssg_name, MPI_Comm ssg_comm);
hg_return_t kvgroup_server_deregister(kv_group_t *group);
hg_return_t kvgroup_server_wait_for_shutdown(kv_group_t *group);
kv_group_t *kvgroup_client_register(margo_instance_id mid, ssg_group_id_t gid);
hg_return_t kvgroup_open(kv_group_t *group, const char *db_name, kv_db_type_t db_type);
hg_return_t kvgroup_put(kv_group_t *group, uint64_t oid,
void *key, hg_size_t ksize,
void *value, hg_size_t vsize);
hg_return_t kvgroup_get(kv_group_t *group, uint64_t oid,
void *key, hg_size_t ksize,
void *value, hg_size_t *vsize);
hg_return_t kvgroup_close(kv_group_t *group);
hg_return_t kvgroup_client_deregister(kv_group_t *group);
hg_return_t kvgroup_client_signal_shutdown(kv_group_t *group);
void kvgroup_server_send_gid(ssg_group_id_t gid, MPI_Comm comm);
void kvgroup_client_recv_gid(ssg_group_id_t *gid, MPI_Comm comm);
#if defined(__cplusplus)
}
#endif
#endif // sds_keyval_group_h
#ifndef sds_keyval_h
#define sds_keyval_h
#if defined(__cplusplus)
extern "C" {
#endif
#include <margo.h>
#include <stdint.h>
typedef enum kv_db_type_t
{
KVDB_MAP,
KVDB_BWTREE,
KVDB_LEVELDB,
KVDB_BERKELEYDB
} kv_db_type_t;
// some setup to support simple benchmarking
typedef struct {
int64_t nkeys;
double insert_time;
double read_time;
double overhead;
} bench_result_t;
// helper routine for stripping protocol part of address string
// e.g. given "ofi+sockets://192.168.101.20:36259" returns "ofi+sockets"
// clients can use to dynamically match server's protocol
// caller is responsible for freeing up char buffer
static inline char *kv_protocol(const char *addr_str) {
int psize = 24;
int i;
char *protocol = (char*)malloc(psize);
memset(protocol, 0, psize);
/* we only need to the proto portion of the address to initialize */
for(i=0; i<psize && addr_str[i] != '\0' && addr_str[i] != ':'; i++)
protocol[i] = addr_str[i];
return protocol;
}
typedef struct kv_context_s kv_context_t;
typedef struct kv_database_s kv_database_t;
// kv-client API
kv_context_t *kv_client_register(const margo_instance_id mid);
kv_context_t *kv_server_register(const margo_instance_id mid);
// both the same: should probably move to common?
hg_return_t kv_client_deregister(kv_context_t *context);
hg_return_t kv_server_deregister(kv_context_t *context);
// server-side routine
// server doesn't have a "database" -- that's a client notion
hg_return_t kv_server_wait_for_shutdown(kv_context_t *context);
// client-side routines wrapping up all the RPC stuff
hg_return_t kv_client_signal_shutdown(kv_database_t *db);
kv_database_t * kv_open(kv_context_t *context,
const char *server, const char *db_name, kv_db_type_t db_type);
hg_return_t kv_put(kv_database_t *db, void *key, hg_size_t ksize,
void *value, hg_size_t vsize);
hg_return_t kv_get(kv_database_t *db, void *key, hg_size_t ksize,
void *value, hg_size_t *vsize);
hg_return_t kv_close(kv_database_t * db);
hg_return_t kv_list_keys(kv_database_t *db, // db instance
const void *start_key, // we want keys strictly after this start_key
hg_size_t start_ksize, // size of the start_key
void **keys, // pointer to an array of void* pointers,
// this array has size *max_keys
hg_size_t* ksizes, // pointer to an array of hg_size_t sizes
// representing sizes allocated in
// keys for each key
hg_size_t* max_keys); // maximum number of keys requested
hg_return_t kv_list_keys_with_prefix(kv_database_t *db,
const void *start_key, // we want keys strictly after this start_key
hg_size_t start_ksize, // size of the start_key
const void *prefix, // return only keys that begin with 'prefix'
hg_size_t prefix_size,
void **keys, // pointer to an array of void* pointers,
// this array has size *max_keys
hg_size_t* ksizes, // pointer to an array of hg_size_t sizes
// representing sizes allocated in
// keys for each key
hg_size_t* max_keys); // maximum number of keys requested
// benchmark routine
bench_result_t *kv_benchmark(kv_database_t *context, int32_t count);
#if defined(__cplusplus)
}
#endif
#endif // sds_keyval_h
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment