Commit 56a13b9a authored by Shane Snyder's avatar Shane Snyder

add server opts for sdskv/bake target paths

parent c5b6ac0e
......@@ -51,12 +51,15 @@ int mobject_provider_register(
* Helper function that sets up the appropriate databases
* in a given SDSKV provider.
*
* @param sdskv_prov SDSKV provider
* @param sdskv_prov SDSKV provider
* @param sdskv_path Path to store SDSKV files
* @param sdskv_backend Type of SDSKV backend to use
*
* @return 0 on success, negative error code on failure
*/
int mobject_sdskv_provider_setup(
sdskv_provider_t sdskv_prov,
const char *sdskv_path,
sdskv_database_id_t sdskv_backend);
#ifdef __cplusplus
......
......@@ -19,7 +19,7 @@ static int seg_map_compare(const void*, size_t, const void*, size_t);
static int omap_map_compare(const void*, size_t, const void*, size_t);
int mobject_sdskv_provider_setup(
sdskv_provider_t sdskv_prov, sdskv_database_id_t sdskv_backend)
sdskv_provider_t sdskv_prov, const char *sdskv_path, sdskv_database_id_t sdskv_backend)
{
int ret;
/* SDSKV provider initialization */
......@@ -33,28 +33,28 @@ int mobject_sdskv_provider_setup(
memset(&config,0,sizeof(config));
config.db_name = "oid_map";
config.db_path = "";
config.db_path = sdskv_path;
config.db_type = sdskv_backend;
config.db_comp_fn_name = "mobject_oid_map_compare";
ret = sdskv_provider_attach_database(sdskv_prov, &config, &oid_map_id);
ASSERT(ret == 0, "sdskv_provider_attach_database() failed to add database \"oid_map\" (ret = %d)\n", ret);
config.db_name = "name_map";
config.db_path = "";
config.db_path = sdskv_path;
config.db_type = sdskv_backend;
config.db_comp_fn_name = "mobject_name_map_compare";
ret = sdskv_provider_attach_database(sdskv_prov, &config, &name_map_id);
ASSERT(ret == 0, "sdskv_provider_attach_database() failed to add database \"name_map\" (ret = %d)\n", ret);
config.db_name = "seg_map";
config.db_path = "";
config.db_path = sdskv_path;
config.db_type = sdskv_backend;
config.db_comp_fn_name = "mobject_seg_map_compare";
ret = sdskv_provider_attach_database(sdskv_prov, &config, &seg_map_id);
ASSERT(ret == 0, "sdskv_provider_attach_database() failed to add database \"seg_map\" (ret = %d)\n", ret);
config.db_name = "omap_map";
config.db_path = "";
config.db_path = sdskv_path;
config.db_type = sdskv_backend;
config.db_comp_fn_name = "mobject_omap_map_compare";
ret = sdskv_provider_attach_database(sdskv_prov, &config, &omap_map_id);
......
......@@ -32,8 +32,10 @@ typedef struct {
typedef struct {
char* listen_addr;
char* cluster_file;
sdskv_db_type_t kv_backend;
char * pool_path;
size_t pool_size;
char * kv_path;
sdskv_db_type_t kv_backend;
} mobject_server_options;
static void usage(void)
......@@ -42,24 +44,37 @@ static void usage(void)
fprintf(stderr, " <listen_addr> the Mercury address to listen on\n");
fprintf(stderr, " <cluster_file> the file to write mobject cluster connect info to\n");
fprintf(stderr, " OPTIONS:\n");
fprintf(stderr, " --pool-path Bake pool location [default: /dev/shm]\n");
fprintf(stderr, " --pool-size Bake pool size for each server [default: 1GiB]\n");
fprintf(stderr, " --kv-backend SDSKV backend to use (mapdb, leveldb, berkeleydb) [default: stdmap]\n");
fprintf(stderr, " --kv-path SDSKV storage location [default: /dev/shm]\n");
exit(-1);
}
static void parse_args(int argc, char **argv, mobject_server_options *opts)
{
int c;
char *short_options = "p:";
char *short_options = "p:s:a:k:";
struct option long_options[] = {
{"pool-path", required_argument, 0, 'p'},
{"pool-size", required_argument, 0, 's'},
{"kv-path", required_argument, 0, 'a'},
{"kv-backend", required_argument, 0, 'k'},
{"pool-size", required_argument, 0, 'p'},
};
while ((c = getopt_long(argc, argv, short_options, long_options, NULL)) != -1)
{
switch (c)
{
case 'p':
opts->pool_path = optarg;
break;
case 's':
opts->pool_size = strtoul(optarg, NULL, 0);
break;
case 'a':
opts->kv_path = optarg;
break;
case 'k':
if(strcmp(optarg, "mapdb") == 0)
opts->kv_backend = KVDB_MAP;
......@@ -70,9 +85,6 @@ static void parse_args(int argc, char **argv, mobject_server_options *opts)
else
usage();
break;
case 'p':
opts->pool_size = strtoul(optarg, NULL, 0);
break;
default:
usage();
}
......@@ -94,8 +106,10 @@ static void finalized_ssg_group_cb(void* data);
int main(int argc, char *argv[])
{
mobject_server_options server_opts = {
.kv_backend = KVDB_MAP,
.pool_path = "/dev/shm", /* default bake pool path */
.pool_size = 1*1024*1024*1024, /* 1 GiB default */
.kv_path = "/dev/shm", /* default sdskv path */
.kv_backend = KVDB_MAP, /* in-memory map default */
};
margo_instance_id mid;
int ret;
......@@ -127,7 +141,7 @@ int main(int argc, char *argv[])
/* XXX mplex id and target name should be taken from config file */
uint8_t bake_mplex_id = 1;
char bake_target_name[128];
sprintf(bake_target_name, "/dev/shm/mobject.%d.dat", rank);
sprintf(bake_target_name, "%s/mobject.%d.dat", server_opts.pool_path, rank);
/* create the bake target if it does not exist */
if(-1 == access(bake_target_name, F_OK)) {
// XXX creating a pool of 10MB - this should come from a config file
......@@ -162,7 +176,7 @@ int main(int argc, char *argv[])
ret = sdskv_provider_register(mid, sdskv_mplex_id, SDSKV_ABT_POOL_DEFAULT, &sdskv_prov);
ASSERT(ret == 0, "sdskv_provider_register() failed (ret = %d)\n", ret);
ret = mobject_sdskv_provider_setup(sdskv_prov, server_opts.kv_backend);
ret = mobject_sdskv_provider_setup(sdskv_prov, server_opts.kv_path, server_opts.kv_backend);
/* SDSKV provider handle initialization from self addr */
sdskv_client_data sdskv_clt_data;
......
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