Commit 36af0abf authored by Philip Carns's avatar Philip Carns

project target id from server to client

parent 405d122f
Pipeline #985 skipped
......@@ -7,15 +7,16 @@
#ifndef __BAKE_BULK_H
#define __BAKE_BULK_H
#include <uuid.h>
#include <stdint.h>
/**
* Persistent, universal, opaque identifier for a BAKE target.
* Remains constant if instance is opened, closed, or migrated.
*
* Think of this like you would a UUID for a storage volume.
*/
typedef uint64_t bake_target_id_t;
typedef struct {
uuid_t id;
} bake_target_id_t;
/**
* Persistent, opaque identifier for a bulk region within a BAKE target.
......
......@@ -13,6 +13,7 @@
* to multiple targets
*/
extern PMEMobjpool *g_pmem_pool;
extern struct bake_bulk_root *g_bake_bulk_root;
/* definition of internal region_id_t identifier for libpmemobj back end */
typedef struct {
......@@ -322,4 +323,22 @@ static void bake_bulk_read_ult(hg_handle_t handle)
}
DEFINE_MARGO_RPC_HANDLER(bake_bulk_read_ult)
/* service a remote RPC that probes for a target id */
static void bake_bulk_probe_ult(hg_handle_t handle)
{
bake_bulk_probe_out_t out;
printf("Got RPC request to probe bulk region.\n");
memset(&out, 0, sizeof(out));
out.ret = 0;
out.bti = g_bake_bulk_root->target_id;
HG_Respond(handle, NULL, NULL, &out);
HG_Destroy(handle);
return;
}
DEFINE_MARGO_RPC_HANDLER(bake_bulk_probe_ult)
......@@ -63,6 +63,20 @@ MERCURY_GEN_PROC(bake_bulk_read_out_t,
((int32_t)(ret)))
DECLARE_MARGO_RPC_HANDLER(bake_bulk_read_ult)
/* bulk probe */
MERCURY_GEN_PROC(bake_bulk_probe_out_t,
((int32_t)(ret))\
((bake_target_id_t)(bti)))
DECLARE_MARGO_RPC_HANDLER(bake_bulk_probe_ult)
/* TODO: this should be somewhere else, just putting in this header for
* convenience right now. The type should only be visible to the server
* daemon and the rpc handlers.
*/
struct bake_bulk_root
{
bake_target_id_t target_id;
};
/* TODO: where should the encoder defs live? Not in bake-bulk-rpc.c because
......@@ -87,10 +101,8 @@ static inline hg_return_t hg_proc_bake_bulk_region_id_t(hg_proc_t proc, bake_bul
static inline hg_return_t hg_proc_bake_target_id_t(hg_proc_t proc, bake_target_id_t *bti)
{
/* TODO: will probably have to update this later when we have a better
* idea of what the target identifier will look like.
*/
return(hg_proc_uint64_t(proc, bti));
/* TODO: make this portable; just raw encoding for now */
return(hg_proc_raw(proc, bti->id, sizeof(bti->id)));
}
#endif /* __BAKE_BULK_RPC */
......@@ -15,11 +15,6 @@
#include "bake-bulk-rpc.h"
struct bake_bulk_root
{
/* TODO: sync up types with bake-bulk.h; for now using uuid directly */
uuid_t target_id;
};
/* TODO: this should not be global in the long run; server may provide access
* to multiple targets
......@@ -59,12 +54,12 @@ int main(int argc, char **argv)
/* find root */
root_oid = pmemobj_root(g_pmem_pool, sizeof(*g_bake_bulk_root));
g_bake_bulk_root = pmemobj_direct(root_oid);
if(uuid_is_null(g_bake_bulk_root->target_id))
if(uuid_is_null(g_bake_bulk_root->target_id.id))
{
uuid_generate(g_bake_bulk_root->target_id);
uuid_generate(g_bake_bulk_root->target_id.id);
pmemobj_persist(g_pmem_pool, g_bake_bulk_root, sizeof(*g_bake_bulk_root));
}
uuid_unparse(g_bake_bulk_root->target_id, target_string);
uuid_unparse(g_bake_bulk_root->target_id.id, target_string);
fprintf(stderr, "BAKE target ID: %s\n", target_string);
/* boilerplate HG initialization steps */
......@@ -141,6 +136,9 @@ int main(int argc, char **argv)
MERCURY_REGISTER(hg_class, "bake_bulk_read_rpc", bake_bulk_read_in_t,
bake_bulk_read_out_t,
bake_bulk_read_ult_handler);
MERCURY_REGISTER(hg_class, "bake_bulk_probe_rpc", void,
bake_bulk_probe_out_t,
bake_bulk_probe_ult_handler);
/* NOTE: at this point this server ULT has two options. It can wait on
* whatever mechanism it wants to (however long the daemon should run and
......
......@@ -20,6 +20,7 @@ struct hg_instance
hg_context_t *hg_context;
int refct;
hg_id_t bake_bulk_probe_id;
hg_id_t bake_bulk_shutdown_id;
hg_id_t bake_bulk_create_id;
hg_id_t bake_bulk_write_id;
......@@ -37,7 +38,6 @@ struct bake_instance
/* TODO: replace later, hard coded global instance */
struct bake_instance g_binst = {
.bti = 0,
.dest = HG_ADDR_NULL,
};
......@@ -73,6 +73,10 @@ static int hg_instance_init(const char *mercury_dest)
}
/* register RPCs */
g_hginst.bake_bulk_probe_id =
MERCURY_REGISTER(g_hginst.hg_class,
"bake_bulk_probe_rpc", void, bake_bulk_probe_out_t,
NULL);
g_hginst.bake_bulk_shutdown_id =
MERCURY_REGISTER(g_hginst.hg_class,
"bake_bulk_shutdown_rpc", void, void,
......@@ -139,8 +143,9 @@ int bake_probe_instance(
bake_target_id_t *bti)
{
hg_return_t hret;
*bti = 0; /* TODO: use a real id eventually, just a placeholder for now */
int ret;
bake_bulk_probe_out_t out;
hg_handle_t handle;
ret = hg_instance_init(mercury_dest);
if(ret < 0)
......@@ -153,7 +158,35 @@ int bake_probe_instance(
return(-1);
}
return(0);
/* create handle */
hret = HG_Create(g_hginst.hg_context, g_binst.dest,
g_hginst.bake_bulk_probe_id, &handle);
if(hret != HG_SUCCESS)
{
return(-1);
}
hret = margo_forward(g_hginst.mid, handle, NULL);
if(hret != HG_SUCCESS)
{
HG_Destroy(handle);
return(-1);
}
hret = HG_Get_output(handle, &out);
if(hret != HG_SUCCESS)
{
HG_Destroy(handle);
return(-1);
}
ret = out.ret;
*bti = out.bti;
HG_Free_output(handle, &out);
HG_Destroy(handle);
return(ret);
}
void bake_release_instance(
......
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