Commit e759a95d authored by Shane Snyder's avatar Shane Snyder

write server cluster info to file

parent b08c700d
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#define MOBJECT_SERVER_GROUP_NAME "mobject-store-servers" #define MOBJECT_SERVER_GROUP_NAME "mobject-store-servers"
int mobject_server_init(margo_instance_id mid); int mobject_server_init(margo_instance_id mid, const char *cluster_file);
/** /**
* Start a mobject server instance * Start a mobject server instance
......
...@@ -12,16 +12,16 @@ ...@@ -12,16 +12,16 @@
void usage(void) void usage(void)
{ {
fprintf(stderr, "Usage: mobject-server-daemon <listen_addr> <gid_file>\n"); fprintf(stderr, "Usage: mobject-server-daemon <listen_addr> <cluster_file>\n");
fprintf(stderr, " <listen_addr> the Mercury address to listen on\n"); fprintf(stderr, " <listen_addr> the Mercury address to listen on\n");
fprintf(stderr, " <gid_file> the file to write the server SSG group ID to\n"); fprintf(stderr, " <cluster_file> the file to write mobject cluster connect info to\n");
exit(-1); exit(-1);
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char *listen_addr; char *listen_addr;
char *gid_file; char *cluster_file;
margo_instance_id mid; margo_instance_id mid;
int ret; int ret;
...@@ -29,7 +29,7 @@ int main(int argc, char *argv[]) ...@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
if (argc != 3) if (argc != 3)
usage(); usage();
listen_addr = argv[1]; listen_addr = argv[1];
gid_file = argv[2]; cluster_file = argv[2];
/* XXX: MPI required for SSG bootstrapping */ /* XXX: MPI required for SSG bootstrapping */
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
...@@ -41,7 +41,7 @@ int main(int argc, char *argv[]) ...@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
return -1; return -1;
} }
ret = mobject_server_init(mid); ret = mobject_server_init(mid, cluster_file);
if (ret != 0) if (ret != 0)
{ {
fprintf(stderr, "Error: Unable to initialize mobject server\n"); fprintf(stderr, "Error: Unable to initialize mobject server\n");
...@@ -49,12 +49,10 @@ int main(int argc, char *argv[]) ...@@ -49,12 +49,10 @@ int main(int argc, char *argv[])
return -1; return -1;
} }
/* XXX write GID to file... where does gid come from? */
/* shutdown */ /* shutdown */
//margo_wait_for_finalize(mid); /* XXX: probably need a conditional here, so we can cleanup after blocking */
mobject_server_shutdown(mid); mobject_server_shutdown(mid);
margo_finalize(mid); margo_finalize(mid);
//margo_wait_for_finalize(mid);
MPI_Finalize(); MPI_Finalize();
return 0; return 0;
......
...@@ -14,16 +14,19 @@ ...@@ -14,16 +14,19 @@
#include "mobject-server.h" #include "mobject-server.h"
typedef struct mobject_server_context typedef struct mobject_server_context
{ {
/* XXX bake, sds-keyval stuff */ /* XXX bake, sds-keyval stuff */
ssg_group_id_t gid; ssg_group_id_t gid;
} mobject_server_context_t; } mobject_server_context_t;
static int mobject_server_store_cluster_info(const char *file_name);
/* XXX one global mobject server state struct */ /* XXX one global mobject server state struct */
mobject_server_context_t *g_srv_ctx = NULL; mobject_server_context_t *g_srv_ctx = NULL;
int mobject_server_init(margo_instance_id mid) int mobject_server_init(margo_instance_id mid, const char *cluster_file)
{ {
int ret; int ret;
...@@ -58,12 +61,25 @@ int mobject_server_init(margo_instance_id mid) ...@@ -58,12 +61,25 @@ int mobject_server_init(margo_instance_id mid)
return -1; return -1;
} }
/* write cluster connect info to file for clients to find later */
ret = mobject_server_store_cluster_info(cluster_file);
if (ret != 0)
{
fprintf(stderr, "Error: unable to store mobject cluster info to file %s\n",
cluster_file);
/* XXX: this call is performed by one process under the covers, and we
* don't currently have a way to propagate this error to the entire cluster
*/
ssg_group_destroy(g_srv_ctx->gid);
ssg_finalize();
return -1;
}
/* XXX cleanup? */ /* XXX cleanup? */
return 0; return 0;
} }
#if 0
int mobject_server_register(margo_instance_id mid, const char *poolname) int mobject_server_register(margo_instance_id mid, const char *poolname)
{ {
int ret=0; int ret=0;
...@@ -90,3 +106,19 @@ void mobject_server_shutdown(margo_instance_id mid) ...@@ -90,3 +106,19 @@ void mobject_server_shutdown(margo_instance_id mid)
return; return;
} }
static int mobject_server_store_cluster_info(const char *file_name)
{
int my_id;
int ret;
assert(g_srv_ctx);
/* only have one group member do this */
my_id = ssg_get_group_self_id(g_srv_ctx->gid);
if (my_id != 0)
return 0;
ret = ssg_group_id_store(file_name, g_srv_ctx->gid);
return ret;
}
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