Commit 4f8196f7 authored by Philip Carns's avatar Philip Carns

skeleton rpc and testcase for region create

parent 0794492b
......@@ -4,6 +4,9 @@
* See COPYRIGHT in top-level directory.
*/
#ifndef __BAKE_BULK_H
#define __BAKE_BULK_H
#include <stdint.h>
/**
......@@ -278,3 +281,5 @@ bake_return_t bake_bulk_gc(
bake_instance_t *target,
bake_request_t *req);
#endif
#endif /* __BAKE_BULK_H */
src_libbake_bulk_a_SOURCES += \
src/bake-bulk.c
bin_PROGRAMS += src/bake-bulk-server src/bb-shutdown
bin_PROGRAMS += \
src/bake-bulk-server \
src/bb-shutdown \
src/bb-copy-to
src_bake_bulk_server_SOURCES = \
src/bake-bulk-server.c \
......
......@@ -14,7 +14,7 @@ static void bake_bulk_shutdown_ult(hg_handle_t handle)
struct hg_info *hgi;
margo_instance_id mid;
printf("Got RPC request to shutdown\n");
printf("Got RPC request to shutdown.\n");
hgi = HG_Get_info(handle);
assert(hgi);
......@@ -34,3 +34,22 @@ static void bake_bulk_shutdown_ult(hg_handle_t handle)
return;
}
DEFINE_MARGO_RPC_HANDLER(bake_bulk_shutdown_ult)
/* service a remote RPC that creates a bulk region */
static void bake_bulk_create_ult(hg_handle_t handle)
{
bake_bulk_create_out_t out;
printf("Got RPC request to create bulk region.\n");
memset(&out, 0, sizeof(out));
out.ret = -1;
HG_Respond(handle, NULL, NULL, &out);
HG_Destroy(handle);
return;
}
DEFINE_MARGO_RPC_HANDLER(bake_bulk_create_ult)
......@@ -4,11 +4,53 @@
* See COPYRIGHT in top-level directory.
*/
#ifndef __BAKE_BULK
#define __BAKE_BULK
#ifndef __BAKE_BULK_RPC
#define __BAKE_BULK_RPC
#include <margo.h>
#include <bake-bulk.h>
/* encoders for bake-specific types */
static inline hg_return_t hg_proc_bake_target_id_t(hg_proc_t proc, bake_target_id_t *bti);
static inline hg_return_t hg_proc_bake_bulk_region_id_t(hg_proc_t proc, bake_bulk_region_id_t *rid);
/* shutdown */
DECLARE_MARGO_RPC_HANDLER(bake_bulk_shutdown_ult)
#endif /* __BAKE_BULK */
/* bulk create */
MERCURY_GEN_PROC(bake_bulk_create_in_t,
((bake_target_id_t)(bti))\
((uint64_t)(region_size)))
MERCURY_GEN_PROC(bake_bulk_create_out_t,
((int32_t)(ret))\
((bake_bulk_region_id_t)(rid)))
DECLARE_MARGO_RPC_HANDLER(bake_bulk_create_ult)
/* TODO: where should these live? Not in bake-bulk-rpc.c because we don't
* really need the rpc handlers to be linked into clients...
*/
static inline hg_return_t hg_proc_bake_bulk_region_id_t(hg_proc_t proc, bake_bulk_region_id_t *rid)
{
/* TODO: update later depending on final region_id_t type */
int i;
hg_return_t ret;
for(i=0; i<BAKE_BULK_REGION_ID_SIZE; i++)
{
ret = hg_proc_hg_uint8_t(proc, (uint8_t*)&rid->data[i]);
if(ret != HG_SUCCESS)
return(ret);
}
return(HG_SUCCESS);
}
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));
}
#endif /* __BAKE_BULK_RPC */
......@@ -95,9 +95,12 @@ int main(int argc, char **argv)
mid = margo_init_pool(handler_pool, handler_pool, hg_context);
assert(mid);
/* register RPC */
/* register RPCs */
MERCURY_REGISTER(hg_class, "bake_bulk_shutdown_rpc", void, void,
bake_bulk_shutdown_ult_handler);
MERCURY_REGISTER(hg_class, "bake_bulk_create_rpc", bake_bulk_create_in_t,
bake_bulk_create_out_t,
bake_bulk_create_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
......
......@@ -6,6 +6,7 @@
#include <bake-bulk.h>
#include <margo.h>
#include "bake-bulk-rpc.h"
struct bake_instance
{
......@@ -20,6 +21,7 @@ struct bake_instance
struct bake_instance g_binst; /* TODO: replace later, hard coded global instance */
static hg_id_t g_bake_bulk_shutdown_id; /* TODO: probably not global in the long run either */
static hg_id_t g_bake_bulk_create_id; /* TODO: probably not global in the long run either */
int bake_probe_instance(
const char *mercury_dest,
......@@ -59,6 +61,12 @@ int bake_probe_instance(
MERCURY_REGISTER(g_binst.hg_class,
"bake_bulk_shutdown_rpc", void, void,
NULL);
g_bake_bulk_create_id =
MERCURY_REGISTER(g_binst.hg_class,
"bake_bulk_create_rpc",
bake_bulk_create_in_t,
bake_bulk_create_out_t,
NULL);
g_binst.mid = margo_init(0, 0, g_binst.hg_context);
if(!g_binst.mid)
......@@ -120,8 +128,43 @@ int bake_bulk_create(
uint64_t region_size,
bake_bulk_region_id_t *rid)
{
hg_return_t hret;
hg_handle_t handle;
bake_bulk_create_in_t in;
bake_bulk_create_out_t out;
int ret;
/* create handle */
hret = HG_Create(g_binst.hg_context, g_binst.dest,
g_bake_bulk_create_id, &handle);
if(hret != HG_SUCCESS)
{
return(-1);
}
in.bti = bti;
in.region_size = region_size;
hret = margo_forward(g_binst.mid, handle, &in);
if(hret != HG_SUCCESS)
{
HG_Destroy(handle);
return(-1);
}
return(-1);
hret = HG_Get_output(handle, &out);
if(hret != HG_SUCCESS)
{
HG_Destroy(handle);
return(-1);
}
ret = out.ret;
*rid = out.rid;
HG_Free_output(handle, &out);
HG_Destroy(handle);
return(ret);
}
/*
* (C) 2015 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include "abt.h"
#include "abt-snoozer.h"
#include "bake-bulk.h"
/* client program that will shut down a BAKE bulk server. */
int main(int argc, char **argv)
{
int ret;
bake_target_id_t bti;
bake_bulk_region_id_t rid;
if(argc != 2)
{
fprintf(stderr, "Usage: bb-copy-to <server addr>\n");
fprintf(stderr, " Example: ./bb-copy-to tcp://localhost:1234\n");
return(-1);
}
/* set up Argobots */
ret = ABT_init(argc, argv);
if(ret != 0)
{
fprintf(stderr, "Error: ABT_init()\n");
return(-1);
}
ret = ABT_snoozer_xstream_self_set();
if(ret != 0)
{
fprintf(stderr, "Error: ABT_snoozer_xstream_self_set()\n");
return(-1);
}
ret = bake_probe_instance(argv[1], &bti);
if(ret < 0)
{
fprintf(stderr, "Error: bake_probe_instance()\n");
return(-1);
}
/* TODO: find local file, check it's size */
/* TODO: create appropriate size region */
ret = bake_bulk_create(bti, 1024, &rid);
{
fprintf(stderr, "Error: bake_bulk_create()\n");
return(-1);
}
/* TODO: a way to print region id */
/* TODO: data transfer */
bake_release_instance(bti);
ABT_finalize();
return(0);
}
......@@ -52,6 +52,8 @@ int main(int argc, char **argv)
bake_release_instance(bti);
ABT_finalize();
return(0);
}
TESTS += \
tests/basic.sh
tests/basic.sh \
tests/copy-to.sh
EXTRA_DIST += \
tests/basic.sh
tests/basic.sh \
tests/copy-to.sh
#!/bin/bash -x
if [ -z $srcdir ]; then
echo srcdir variable not set.
exit 1
fi
source $srcdir/tests/test-util.sh
# start 1 server with 2 second wait, 20s timeout
test_start_servers 1 2 20
# actual test case
#####################
run_to 10 src/bb-copy-to $svr1
if [ $? -ne 0 ]; then
run_to 10 src/bb-shutdown $svr1 &> /dev/null
wait
exit 1
fi
sleep 1
#####################
# tear down
run_to 10 src/bb-shutdown $svr1 &> /dev/null
if [ $? -ne 0 ]; then
wait
exit 1
fi
wait
echo cleaning up $TMPBASE
rm -rf $TMPBASE
exit 0
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