Commit c8d9ea77 authored by David Rich's avatar David Rich
Browse files

Add kv_protocol helper function and fix up tests.

parent 4fde806b
......@@ -23,6 +23,10 @@ typedef struct kvgroup_context_s {
struct ch_placement_instance *ch_instance;
} kvgroup_context_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;
......
......@@ -15,6 +15,22 @@ typedef struct {
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;
char *protocol = (char*)malloc(psize);
memset(protocol, 0, psize);
/* 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;
}
typedef struct kv_context_s kv_context_t;
// kv-client API
......
......@@ -71,8 +71,9 @@ int main(int argc, char **argv)
size_t items = atoi(argv[1]);
char *server_addr_str = argv[2];
margo_instance_id mid = margo_init(server_addr_str,
MARGO_CLIENT_MODE, 0, -1);
char *proto = kv_protocol(server_addr_str);
margo_instance_id mid = margo_init(proto, MARGO_CLIENT_MODE, 0, -1);
free(proto);
context = kv_client_register(mid);
ret = kv_open(context, server_addr_str, "db/testdb");
......
......@@ -10,7 +10,9 @@ int main(int argc, char **argv) {
assert(argc == 2);
char *server_addr_str = argv[1];
margo_instance_id mid = margo_init(argv[1], MARGO_CLIENT_MODE, 0, -1);
char *proto = kv_protocol(server_addr_str);
margo_instance_id mid = margo_init(proto, MARGO_CLIENT_MODE, 0, -1);
free(proto);
kv_context_t *context = kv_client_register(mid);
/* open */
......
......@@ -109,9 +109,8 @@ int main(int argc, char *argv[])
// kv-client
char *proto = kvgroup_protocol(gid);
kvgroup_context_t *context = kvgroup_client_register(margo_init(proto,
MARGO_CLIENT_MODE, 0, -1),
gid);
kvgroup_context_t *context = kvgroup_client_register(margo_init(proto, MARGO_CLIENT_MODE, 0, -1), gid);
free(proto);
hret = margo_addr_self(context->mid, &client_addr);
DIE_IF(hret != HG_SUCCESS, "margo_addr_self");
......
......@@ -88,8 +88,9 @@ int main(int argc, char *argv[])
printf("client (rank %d): server addr_str: %s\n", rank, server_addr_str);
// kv-client
margo_instance_id mid = margo_init(server_addr_str,
MARGO_CLIENT_MODE, 0, -1);
char *proto = kv_protocol(server_addr_str);
margo_instance_id mid = margo_init(proto, MARGO_CLIENT_MODE, 0, -1);
free(proto);
kv_context_t *context = kv_client_register(mid);
hret = margo_addr_self(mid, &client_addr);
......
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