Commit 6eeade93 authored by Philip Carns's avatar Philip Carns

shutdown utility

parent beeb18fc
Pipeline #153 skipped
src_libbake_bulk_a_SOURCES += \
src/bake-bulk.c
bin_PROGRAMS += src/bake-bulk-server
bin_PROGRAMS += src/bake-bulk-server src/bb-shutdown
src_bake_bulk_server_SOURCES = \
src/bake-bulk-server.c \
......
......@@ -11,6 +11,8 @@
#include <abt-snoozer.h>
#include <margo.h>
#include "bake-bulk-rpc.h"
int main(int argc, char **argv)
{
int ret;
......@@ -83,13 +85,9 @@ int main(int argc, char **argv)
mid = margo_init(handler_pool, handler_pool, hg_context, hg_class);
assert(mid);
#if 0
/* register RPC */
MERCURY_REGISTER(hg_class, "my_rpc", my_rpc_in_t, my_rpc_out_t,
my_rpc_ult_handler);
MERCURY_REGISTER(hg_class, "my_shutdown_rpc", void, void,
my_rpc_shutdown_ult_handler);
#endif
MERCURY_REGISTER(hg_class, "bake_bulk_shutdown_rpc", void, void,
bake_bulk_shutdown_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
......
/*
* (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 <margo.h>
#include "bake-bulk-rpc.h"
/* client program that will shut down a BAKE bulk server. */
static hg_id_t bake_bulk_shutdown_id;
int main(int argc, char **argv)
{
int ret;
ABT_xstream xstream;
ABT_pool pool;
margo_instance_id mid;
hg_context_t *hg_context;
hg_class_t *hg_class;
hg_addr_t svr_addr = HG_ADDR_NULL;
hg_handle_t handle;
/* boilerplate HG initialization steps */
/***************************************/
/* TODO: fix addr */
hg_class = HG_Init("tcp://localhost:1234", HG_FALSE);
if(!hg_class)
{
fprintf(stderr, "Error: HG_Init()\n");
return(-1);
}
hg_context = HG_Context_create(hg_class);
if(!hg_context)
{
fprintf(stderr, "Error: HG_Context_create()\n");
HG_Finalize(hg_class);
return(-1);
}
/* set up argobots */
/***************************************/
ret = ABT_init(argc, argv);
if(ret != 0)
{
fprintf(stderr, "Error: ABT_init()\n");
return(-1);
}
/* set primary ES to idle without polling */
ret = ABT_snoozer_xstream_self_set();
if(ret != 0)
{
fprintf(stderr, "Error: ABT_snoozer_xstream_self_set()\n");
return(-1);
}
/* retrieve current pool to use for ULT creation */
ret = ABT_xstream_self(&xstream);
if(ret != 0)
{
fprintf(stderr, "Error: ABT_xstream_self()\n");
return(-1);
}
ret = ABT_xstream_get_main_pools(xstream, 1, &pool);
if(ret != 0)
{
fprintf(stderr, "Error: ABT_xstream_get_main_pools()\n");
return(-1);
}
/* actually start margo */
/* provide argobots pools for driving communication progress and
* executing rpc handlers as well as class and context for Mercury
* communication. The rpc handler pool is null in this example program
* because this is a pure client that will not be servicing rpc requests.
*/
/***************************************/
mid = margo_init(pool, ABT_POOL_NULL, hg_context, hg_class);
/* register RPC */
bake_bulk_shutdown_id = MERCURY_REGISTER(hg_class, "bake_bulk_shutdown_rpc", void, void,
NULL);
/* send one rpc to server to shut it down */
/* find addr for server */
/* TODO: fix addr */
ret = margo_addr_lookup(mid, hg_context, "tcp://localhost:1234", &svr_addr);
assert(ret == 0);
/* create handle */
ret = HG_Create(hg_context, svr_addr, bake_bulk_shutdown_id, &handle);
assert(ret == 0);
margo_forward(mid, handle, NULL);
/* shut down everything */
margo_finalize(mid);
ABT_finalize();
HG_Context_destroy(hg_context);
HG_Finalize(hg_class);
return(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