Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sds
bake
Commits
cb24ba14
Commit
cb24ba14
authored
May 05, 2016
by
Philip Carns
Browse files
draft of crude instance mgmt
parent
9103133b
Pipeline
#331
skipped
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/bake-bulk.h
View file @
cb24ba14
...
...
@@ -4,6 +4,44 @@
* See COPYRIGHT in top-level directory.
*/
#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
;
/**
* Obtain identifying information for a bake target through the provided
* remote mercury address.
*
* @param [in] mecury_dest Mercury address in string form
* @param [out] bti BAKE target identifier
* @returns 0 on success, -1 on failure
*/
int
bake_probe_instance
(
const
char
*
mercury_dest
,
bake_target_id_t
*
bti
);
/**
* Release resources associated with access to a target
*
* @param [in] bti BAKE target_identifier
*/
void
bake_release_instance
(
bake_target_id_t
bti
);
/**
* Utility function to shut down a remote service
*
* @param [in] bti Bake target identifier
* @returns 0 on success, -1 on fialure
*/
int
bake_shutdown_service
(
bake_target_id_t
bti
);
/* NOTE: code below is a copy of the bulk portion of the proposed BAKE API.
* Commented out for now but leaving it in place for reference
*/
...
...
src/bake-bulk.c
View file @
cb24ba14
...
...
@@ -5,4 +5,113 @@
*/
#include
<bake-bulk.h>
#include
<margo.h>
struct
bake_instance
{
bake_target_id_t
bti
;
/* persistent identifier for this target */
hg_addr_t
dest
;
/* remote Mercury address */
/* TODO: stuff will probably be split out into an hg instance */
margo_instance_id
mid
;
/* Margo instance */
hg_class_t
*
hg_class
;
hg_context_t
*
hg_context
;
};
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 */
int
bake_probe_instance
(
const
char
*
mercury_dest
,
bake_target_id_t
*
bti
)
{
*
bti
=
0
;
/* TODO: use a real id eventually, just a placeholder for now */
hg_return_t
hret
;
memset
(
&
g_binst
,
0
,
sizeof
(
g_binst
));
/* TODO: eventually we will not init HG on every target probe, probably
* separate step so hg instance can be shared. Simple test case is to
* build a single client application that communicates with two distinct
* targets (on different servers) simultaneously.
*/
/* boilerplate HG initialization steps */
/***************************************/
/* NOTE: the listening address is not actually used in this case (the
* na_listen flag is false); but we pass in the *target* server address
* here to make sure that Mercury starts up the correct transport
*/
g_binst
.
hg_class
=
HG_Init
(
mercury_dest
,
HG_FALSE
);
if
(
!
g_binst
.
hg_class
)
{
return
(
-
1
);
}
g_binst
.
hg_context
=
HG_Context_create
(
g_binst
.
hg_class
);
if
(
!
g_binst
.
hg_context
)
{
HG_Finalize
(
g_binst
.
hg_class
);
return
(
-
1
);
}
/* register RPCs */
g_bake_bulk_shutdown_id
=
MERCURY_REGISTER
(
g_binst
.
hg_class
,
"bake_bulk_shutdown_rpc"
,
void
,
void
,
NULL
);
g_binst
.
mid
=
margo_init
(
0
,
0
,
g_binst
.
hg_context
);
if
(
!
g_binst
.
mid
)
{
HG_Context_destroy
(
g_binst
.
hg_context
);
HG_Finalize
(
g_binst
.
hg_class
);
return
(
-
1
);
}
hret
=
margo_addr_lookup
(
g_binst
.
mid
,
mercury_dest
,
&
g_binst
.
dest
);
if
(
hret
!=
HG_SUCCESS
)
{
margo_finalize
(
g_binst
.
mid
);
HG_Context_destroy
(
g_binst
.
hg_context
);
HG_Finalize
(
g_binst
.
hg_class
);
return
(
-
1
);
}
return
(
0
);
}
void
bake_release_instance
(
bake_target_id_t
bti
)
{
HG_Addr_free
(
g_binst
.
hg_class
,
g_binst
.
dest
);
margo_finalize
(
g_binst
.
mid
);
HG_Context_destroy
(
g_binst
.
hg_context
);
HG_Finalize
(
g_binst
.
hg_class
);
memset
(
&
g_binst
,
0
,
sizeof
(
g_binst
));
return
;
}
int
bake_shutdown_service
(
bake_target_id_t
bti
)
{
hg_return_t
hret
;
hg_handle_t
handle
;
/* create handle */
hret
=
HG_Create
(
g_binst
.
hg_context
,
g_binst
.
dest
,
g_bake_bulk_shutdown_id
,
&
handle
);
if
(
hret
!=
HG_SUCCESS
)
{
return
(
-
1
);
}
hret
=
margo_forward
(
g_binst
.
mid
,
handle
,
NULL
);
if
(
hret
!=
HG_SUCCESS
)
{
HG_Destroy
(
handle
);
return
(
-
1
);
}
HG_Destroy
(
handle
);
return
(
0
);
}
src/bb-shutdown.c
View file @
cb24ba14
...
...
@@ -7,26 +7,17 @@
#include
<stdio.h>
#include
<assert.h>
#include
<unistd.h>
#include
<abt.h>
#include
<abt-snoozer.h>
#include
<margo.h>
#include
"bake-bulk-rpc.h"
#include
"abt.h"
#include
"abt-snoozer.h"
#include
"bake-bulk.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
;
bake_target_id_t
bti
;
if
(
argc
!=
2
)
{
...
...
@@ -35,36 +26,13 @@ int main(int argc, char **argv)
return
(
-
1
);
}
/* boilerplate HG initialization steps */
/***************************************/
/* NOTE: the listening address is not actually used in this case (the
* na_listen flag is false); but we pass in the *target* server address
* here to make sure that Mercury starts up the correct transport
*/
hg_class
=
HG_Init
(
argv
[
1
],
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 */
/***************************************/
/* 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
)
{
...
...
@@ -72,51 +40,17 @@ int main(int argc, char **argv)
return
(
-
1
);
}
/* retrieve current pool to use for ULT creation */
ret
=
ABT_xstream_self
(
&
xstream
);
if
(
ret
!=
0
)
ret
=
bake_probe_instance
(
argv
[
1
],
&
bti
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"Error:
ABT_xstream_self
()
\n
"
);
fprintf
(
stderr
,
"Error:
bake_probe_instance
()
\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
(
pool
,
ABT_POOL_NULL
,
hg_context
);
/* 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 */
ret
=
margo_addr_lookup
(
mid
,
argv
[
1
],
&
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
();
/* shutdown server */
bake_shutdown_service
(
bti
);
HG_Context_destroy
(
hg_context
);
HG_Finalize
(
hg_class
);
bake_release_instance
(
bti
);
return
(
0
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment