Commit 644064f8 authored by Shane Snyder's avatar Shane Snyder

implement mobject_store_create

MOBJECT_CLUSTER_FILE env variable must be set to point to a
valid file generated by the mobject server.
parent e759a95d
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "mobject-store-config.h" #include "mobject-store-config.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <margo.h> #include <margo.h>
...@@ -14,47 +15,68 @@ ...@@ -14,47 +15,68 @@
#include "libmobject-store.h" #include "libmobject-store.h"
struct mobject_store_handle #define MOBJECT_CLUSTER_FILE_ENV "MOBJECT_CLUSTER_FILE"
typedef struct mobject_store_handle
{ {
int test; ssg_group_id_t gid;
}; } mobject_store_handle_t;
int mobject_store_create(mobject_store_t *cluster, const char * const id) int mobject_store_create(mobject_store_t *cluster, const char * const id)
{ {
struct mobject_store_handle *cluster_handle; mobject_store_handle_t *cluster_handle;
char *cluster_file;
int ret;
(void)id; /* XXX: id unused in mobject */ (void)id; /* XXX: id unused in mobject */
/* allocate a new cluster handle and set some fields */ /* allocate a new cluster handle and set some fields */
cluster_handle = malloc(sizeof(*cluster_handle)); cluster_handle = malloc(sizeof(*cluster_handle));
if (!cluster_handle) if (!cluster_handle)
return(-1); /* TODO: error codes */ return -1;
cluster_handle->test = 123; memset(cluster_handle, 0, sizeof(cluster_handle));
/* TODO find the SSG group ID for the mobject cluster group */ /* use env variable to determine how to connect to the cluster */
/* NOTE: this is the _only_ method for specifying a cluster for now... */
cluster_file = getenv(MOBJECT_CLUSTER_FILE_ENV);
if (!cluster_file)
{
fprintf(stderr, "Error: %s env variable must point to mobject cluster file\n",
MOBJECT_CLUSTER_FILE_ENV);
return -1;
}
ret = ssg_group_id_load(cluster_file, &cluster_handle->gid);
if (ret != 0)
{
fprintf(stderr, "Error: Unable to load mobject cluster info from file %s\n",
cluster_file);
return -1;
}
/* set the returned cluster handle */ /* set the returned cluster handle */
*cluster = cluster_handle; *cluster = cluster_handle;
return(0); return 0;
} }
#if 0
int mobject_store_connect(mobject_store_t cluster) int mobject_store_connect(mobject_store_t cluster)
{ {
/* TODO ssg attach to mobject cluster group id */ /* TODO ssg attach to mobject cluster group id */
return 0;
} }
#endif
void mobject_store_shutdown(mobject_store_t cluster) void mobject_store_shutdown(mobject_store_t cluster)
{ {
struct mobject_store_handle *cluster_handle = mobject_store_handle_t *cluster_handle =
(struct mobject_store_handle *)cluster; (mobject_store_handle_t *)cluster;
assert(cluster_handle != NULL); assert(cluster_handle != NULL);
/* TODO ssg detatch from mobject cluster group id */ /* TODO ssg detatch from mobject cluster group id. free gid? */
free(cluster_handle); free(cluster_handle);
return; return;
} }
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