Commit dc59a4c2 authored by Matthieu Dorier's avatar Matthieu Dorier

externalized initialization of SSG group

parent b1bb6db5
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#define MOBJECT_SERVER_H #define MOBJECT_SERVER_H
#include <margo.h> #include <margo.h>
#include <ssg.h>
#include <bake-client.h> #include <bake-client.h>
#include <sdskv-client.h> #include <sdskv-client.h>
#include <sdskv-server.h> #include <sdskv-server.h>
...@@ -30,6 +31,7 @@ typedef struct mobject_server_context* mobject_provider_t; ...@@ -30,6 +31,7 @@ typedef struct mobject_server_context* mobject_provider_t;
* @param[in] pool Argobots pool for the provider * @param[in] pool Argobots pool for the provider
* @param[in] bake_ph Bake provider handle to use to write/read data * @param[in] bake_ph Bake provider handle to use to write/read data
* @param[in] sdskv_ph SDSKV provider handle to use to access metadata * @param[in] sdskv_ph SDSKV provider handle to use to access metadata
* @param[in] gid SSG group id of the group gathering all mobject providers
* @param[in] cluster_file file name to write cluster connect info to * @param[in] cluster_file file name to write cluster connect info to
* @param[out] provider resulting provider * @param[out] provider resulting provider
* *
...@@ -41,6 +43,7 @@ int mobject_provider_register( ...@@ -41,6 +43,7 @@ int mobject_provider_register(
ABT_pool pool, ABT_pool pool,
bake_provider_handle_t bake_ph, bake_provider_handle_t bake_ph,
sdskv_provider_handle_t sdskv_ph, sdskv_provider_handle_t sdskv_ph,
ssg_group_id_t gid,
const char *cluster_file, const char *cluster_file,
mobject_provider_t* provider); mobject_provider_t* provider);
......
...@@ -39,6 +39,7 @@ typedef struct { ...@@ -39,6 +39,7 @@ typedef struct {
static void finalize_ssg_cb(void* data); static void finalize_ssg_cb(void* data);
static void finalize_bake_client_cb(void* data); static void finalize_bake_client_cb(void* data);
static void finalize_sdskv_client_cb(void* data); static void finalize_sdskv_client_cb(void* data);
static void finalized_ssg_group_cb(void* data);
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
...@@ -117,13 +118,18 @@ int main(int argc, char *argv[]) ...@@ -117,13 +118,18 @@ int main(int argc, char *argv[])
ASSERT(ret == 0, "sdskv_provider_handle_create() failed (ret = %d)\n", ret); ASSERT(ret == 0, "sdskv_provider_handle_create() failed (ret = %d)\n", ret);
margo_push_finalize_callback(mid, &finalize_sdskv_client_cb, (void*)&sdskv_clt_data); margo_push_finalize_callback(mid, &finalize_sdskv_client_cb, (void*)&sdskv_clt_data);
/* SSG group creation */
ssg_group_id_t gid = ssg_group_create_mpi(MOBJECT_SERVER_GROUP_NAME, MPI_COMM_WORLD, NULL, NULL);
ASSERT(gid != SSG_GROUP_ID_NULL, "ssg_group_create_mpi() failed (ret = %s)","SSG_GROUP_ID_NULL");
margo_push_finalize_callback(mid, &finalized_ssg_group_cb, (void*)&gid);
/* Mobject provider initialization */ /* Mobject provider initialization */
mobject_provider_t mobject_prov; mobject_provider_t mobject_prov;
ret = mobject_provider_register(mid, 1, ret = mobject_provider_register(mid, 1,
MOBJECT_ABT_POOL_DEFAULT, MOBJECT_ABT_POOL_DEFAULT,
bake_clt_data.provider_handle, bake_clt_data.provider_handle,
sdskv_clt_data.provider_handle, sdskv_clt_data.provider_handle,
cluster_file, &mobject_prov); gid, cluster_file, &mobject_prov);
if (ret != 0) if (ret != 0)
{ {
fprintf(stderr, "Error: Unable to initialize mobject provider\n"); fprintf(stderr, "Error: Unable to initialize mobject provider\n");
...@@ -159,3 +165,9 @@ static void finalize_sdskv_client_cb(void* data) ...@@ -159,3 +165,9 @@ static void finalize_sdskv_client_cb(void* data)
sdskv_provider_handle_release(clt_data->provider_handle); sdskv_provider_handle_release(clt_data->provider_handle);
sdskv_client_finalize(clt_data->client); sdskv_client_finalize(clt_data->client);
} }
static void finalized_ssg_group_cb(void* data)
{
ssg_group_id_t gid = *((ssg_group_id_t*)data);
ssg_group_destroy(gid);
}
...@@ -40,6 +40,7 @@ int mobject_provider_register( ...@@ -40,6 +40,7 @@ int mobject_provider_register(
ABT_pool pool, ABT_pool pool,
bake_provider_handle_t bake_ph, bake_provider_handle_t bake_ph,
sdskv_provider_handle_t sdskv_ph, sdskv_provider_handle_t sdskv_ph,
ssg_group_id_t gid,
const char *cluster_file, const char *cluster_file,
mobject_provider_t* provider) mobject_provider_t* provider)
{ {
...@@ -67,15 +68,7 @@ int mobject_provider_register( ...@@ -67,15 +68,7 @@ int mobject_provider_register(
srv_ctx->pool = pool; srv_ctx->pool = pool;
srv_ctx->ref_count = 1; srv_ctx->ref_count = 1;
/* server group create */ srv_ctx->gid = gid;
srv_ctx->gid = ssg_group_create_mpi(MOBJECT_SERVER_GROUP_NAME, MPI_COMM_WORLD, NULL, NULL);
/* XXX membership update callbacks unused currently */
if (srv_ctx->gid == SSG_GROUP_ID_NULL)
{
fprintf(stderr, "Error: Unable to create the mobject server group\n");
free(srv_ctx);
return -1;
}
my_id = ssg_get_group_self_id(srv_ctx->gid); my_id = ssg_get_group_self_id(srv_ctx->gid);
/* one proccess writes cluster connect info to file for clients to find later */ /* one proccess writes cluster connect info to file for clients to find later */
...@@ -89,7 +82,6 @@ int mobject_provider_register( ...@@ -89,7 +82,6 @@ int mobject_provider_register(
/* XXX: this call is performed by one process, and we do not currently /* XXX: this call is performed by one process, and we do not currently
* have an easy way to propagate this error to the entire cluster group * have an easy way to propagate this error to the entire cluster group
*/ */
ssg_group_destroy(srv_ctx->gid);
free(srv_ctx); free(srv_ctx);
return -1; return -1;
} }
...@@ -102,12 +94,10 @@ int mobject_provider_register( ...@@ -102,12 +94,10 @@ int mobject_provider_register(
ret = bake_probe(bake_ph, 1, &(srv_ctx->bake_tid), &num_targets); ret = bake_probe(bake_ph, 1, &(srv_ctx->bake_tid), &num_targets);
if(ret != 0) { if(ret != 0) {
fprintf(stderr, "Error: unable to probe bake server for targets\n"); fprintf(stderr, "Error: unable to probe bake server for targets\n");
ssg_group_destroy(srv_ctx->gid);
return -1; return -1;
} }
if(num_targets < 1) { if(num_targets < 1) {
fprintf(stderr, "Error: unable to find a target on bake provider\n"); fprintf(stderr, "Error: unable to find a target on bake provider\n");
ssg_group_destroy(srv_ctx->gid);
free(srv_ctx); free(srv_ctx);
return -1; return -1;
} }
...@@ -117,7 +107,6 @@ int mobject_provider_register( ...@@ -117,7 +107,6 @@ int mobject_provider_register(
ret = sdskv_open(sdskv_ph, "oid_map", &(srv_ctx->oid_db_id)); ret = sdskv_open(sdskv_ph, "oid_map", &(srv_ctx->oid_db_id));
if(ret != SDSKV_SUCCESS) { if(ret != SDSKV_SUCCESS) {
fprintf(stderr, "Error: unable to open oid_map from SDSKV provider\n"); fprintf(stderr, "Error: unable to open oid_map from SDSKV provider\n");
ssg_group_destroy(srv_ctx->gid);
bake_provider_handle_release(srv_ctx->bake_ph); bake_provider_handle_release(srv_ctx->bake_ph);
sdskv_provider_handle_release(srv_ctx->sdskv_ph); sdskv_provider_handle_release(srv_ctx->sdskv_ph);
free(srv_ctx); free(srv_ctx);
...@@ -127,7 +116,6 @@ int mobject_provider_register( ...@@ -127,7 +116,6 @@ int mobject_provider_register(
fprintf(stderr, "Error: unable to open name_map from SDSKV provider\n"); fprintf(stderr, "Error: unable to open name_map from SDSKV provider\n");
bake_provider_handle_release(srv_ctx->bake_ph); bake_provider_handle_release(srv_ctx->bake_ph);
sdskv_provider_handle_release(srv_ctx->sdskv_ph); sdskv_provider_handle_release(srv_ctx->sdskv_ph);
ssg_group_destroy(srv_ctx->gid);
free(srv_ctx); free(srv_ctx);
} }
ret = sdskv_open(sdskv_ph, "seg_map", &(srv_ctx->segment_db_id)); ret = sdskv_open(sdskv_ph, "seg_map", &(srv_ctx->segment_db_id));
...@@ -135,7 +123,6 @@ int mobject_provider_register( ...@@ -135,7 +123,6 @@ int mobject_provider_register(
fprintf(stderr, "Error: unable to open seg_map from SDSKV provider\n"); fprintf(stderr, "Error: unable to open seg_map from SDSKV provider\n");
bake_provider_handle_release(srv_ctx->bake_ph); bake_provider_handle_release(srv_ctx->bake_ph);
sdskv_provider_handle_release(srv_ctx->sdskv_ph); sdskv_provider_handle_release(srv_ctx->sdskv_ph);
ssg_group_destroy(srv_ctx->gid);
free(srv_ctx); free(srv_ctx);
} }
ret = sdskv_open(sdskv_ph, "omap_map", &(srv_ctx->omap_db_id)); ret = sdskv_open(sdskv_ph, "omap_map", &(srv_ctx->omap_db_id));
...@@ -143,7 +130,6 @@ int mobject_provider_register( ...@@ -143,7 +130,6 @@ int mobject_provider_register(
fprintf(stderr, "Error: unable to open omap_map from SDSKV provider\n"); fprintf(stderr, "Error: unable to open omap_map from SDSKV provider\n");
bake_provider_handle_release(srv_ctx->bake_ph); bake_provider_handle_release(srv_ctx->bake_ph);
sdskv_provider_handle_release(srv_ctx->sdskv_ph); sdskv_provider_handle_release(srv_ctx->sdskv_ph);
ssg_group_destroy(srv_ctx->gid);
free(srv_ctx); free(srv_ctx);
} }
...@@ -276,7 +262,6 @@ static void mobject_finalize_cb(void* data) ...@@ -276,7 +262,6 @@ static void mobject_finalize_cb(void* data)
sdskv_provider_handle_release(srv_ctx->sdskv_ph); sdskv_provider_handle_release(srv_ctx->sdskv_ph);
bake_provider_handle_release(srv_ctx->bake_ph); bake_provider_handle_release(srv_ctx->bake_ph);
ssg_group_destroy(srv_ctx->gid);
free(srv_ctx); free(srv_ctx);
} }
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