Commit 811aa9a9 authored by David Rich's avatar David Rich Committed by Rob Latham
Browse files

Create a kvdb subdir for each kv-server in kvgroup.

parent 42c0fef5
// Copyright (c) 2017, Los Alamos National Security, LLC. // Copyright (c) 2017, Los Alamos National Security, LLC.
// All rights reserved. // All rights reserved.
#include "datastore.h" #include "datastore.h"
#include <boost/filesystem.hpp>
#include <chrono> #include <chrono>
#include <boost/filesystem.hpp>
using namespace std::chrono; using namespace std::chrono;
AbstractDataStore::AbstractDataStore() { AbstractDataStore::AbstractDataStore() {
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include <assert.h> #include <assert.h>
#include <iostream> #include <iostream>
#include <boost/filesystem.hpp>
unsigned long server_indexes[CH_MAX_REPLICATION]; unsigned long server_indexes[CH_MAX_REPLICATION];
kvgroup_context_t *kvgroup_client_register(margo_instance_id mid, ssg_group_id_t gid) kvgroup_context_t *kvgroup_client_register(margo_instance_id mid, ssg_group_id_t gid)
...@@ -31,6 +33,12 @@ hg_return_t kvgroup_open(kvgroup_context_t *context, const char *db_name) ...@@ -31,6 +33,12 @@ hg_return_t kvgroup_open(kvgroup_context_t *context, const char *db_name)
char addr_str[addr_str_sz]; char addr_str[addr_str_sz];
hg_return_t ret = HG_SUCCESS; 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 // register and open a connection with each kv-server in the group
hg_size_t gsize = ssg_get_group_size(context->gid); hg_size_t gsize = ssg_get_group_size(context->gid);
context->gsize = gsize; context->gsize = gsize;
...@@ -44,11 +52,11 @@ hg_return_t kvgroup_open(kvgroup_context_t *context, const char *db_name) ...@@ -44,11 +52,11 @@ hg_return_t kvgroup_open(kvgroup_context_t *context, const char *db_name)
ret = margo_addr_to_string(context->mid, addr_str, &addr_str_sz, server_addr); ret = margo_addr_to_string(context->mid, addr_str, &addr_str_sz, server_addr);
assert(ret == HG_SUCCESS); assert(ret == HG_SUCCESS);
margo_addr_free(context->mid, server_addr); margo_addr_free(context->mid, server_addr);
std::string dbname(db_name); std::string server_dbname = basepath + separator + std::string("kvdb.") + std::to_string(i)
dbname += std::string(".") + std::to_string(i); // each session uses unique db name + separator + name; // each session uses unique db name
// open client connection with this server // open client connection with this server
std::cout << "request open of " << dbname << " from server " << addr_str << std::endl; std::cout << "request open of " << server_dbname << " from server " << addr_str << std::endl;
ret = kv_open(context->kv_context[i], addr_str, dbname.c_str()); ret = kv_open(context->kv_context[i], addr_str, server_dbname.c_str());
assert(ret == HG_SUCCESS); assert(ret == HG_SUCCESS);
} }
......
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