Commit 336b01ae authored by Shane Snyder's avatar Shane Snyder

reorg client cluster & io-context code

parent d1632836
......@@ -102,7 +102,7 @@ enum {
* libmobject_store users must synchronize any of these changes on their own,
* or use separate io contexts for each thread
*/
typedef struct mobject_ioctx *mobject_store_ioctx_t;
typedef struct mobject_store_ioctx *mobject_store_ioctx_t;
/**
* @typedef mobject_store_omap_iter_t
......
noinst_HEADERS += \
src/client/cluster.h \
src/client/aio/completion.h \
src/client/cluster-handle.h \
src/client/io-context.h \
src/io-chain/args-read-actions.h \
src/io-chain/args-write-actions.h \
src/io-chain/prepare-read-op.h \
......@@ -46,12 +45,11 @@ src_io_chain_libio_chain_la_SOURCES = src/io-chain/prepare-read-op.c \
src_client_libmobject_store_la_SOURCES = \
src/client/aio/completion.c \
src/client/io-context.c \
src/client/omap-iter.c \
src/client/cluster.c \
src/client/read-op.c \
src/client/write-op.c \
src/client/libmobject-store.c
src/client/omap-iter.c \
src/client/aio/completion.c
src_client_libmobject_store_la_CPPFLAGS = ${AM_CPPFLAGS} ${CLIENT_CPPFLAGS}
src_client_libmobject_store_la_LIBADD = src/omap-iter/libomap-iter.la \
src/io-chain/libio-chain.la ${CLIENT_LIBS}
......
......@@ -14,16 +14,12 @@
#include <ssg.h>
#include "libmobject-store.h"
#include "src/util/log.h"
#include "src/client/cluster.h"
#include "src/io-chain/prepare-write-op.h"
#include "src/io-chain/prepare-read-op.h"
#include "src/rpc-types/write-op.h"
#include "src/rpc-types/read-op.h"
#include "src/rpc-types/read-op.h"
#include "src/client/io-context.h"
#include "src/io-chain/prepare-read-op.h"
#include "src/io-chain/prepare-write-op.h"
#include "src/client/cluster-handle.h"
#define MOBJECT_CLUSTER_FILE_ENV "MOBJECT_CLUSTER_FILE"
#include "src/util/log.h"
// global variables for RPC ids
......@@ -32,18 +28,18 @@ hg_id_t mobject_read_op_rpc_id;
hg_id_t mobject_shutdown_rpc_id;
static void mobject_store_register(margo_instance_id mid);
static int mobject_store_shutdown_servers(mobject_store_handle_t *cluster_handle);
static int mobject_store_shutdown_servers(struct mobject_store_handle *cluster_handle);
int mobject_store_create(mobject_store_t *cluster, const char * const id)
{
mobject_store_handle_t *cluster_handle;
struct mobject_store_handle *cluster_handle;
char *cluster_file;
int ret;
(void)id; /* XXX: id unused in mobject */
/* allocate a new cluster handle and set some fields */
cluster_handle = (mobject_store_handle_t*)calloc(1,sizeof(*cluster_handle));
cluster_handle = (struct mobject_store_handle*)calloc(1,sizeof(*cluster_handle));
if (!cluster_handle)
return -1;
......@@ -75,12 +71,15 @@ int mobject_store_create(mobject_store_t *cluster, const char * const id)
int mobject_store_connect(mobject_store_t cluster)
{
mobject_store_handle_t *cluster_handle = (mobject_store_handle_t *)cluster;
struct mobject_store_handle *cluster_handle;
char *svr_addr_str;
char proto[24] = {0};
int i;
int ret;
cluster_handle = (struct mobject_store_handle *)cluster;
assert(cluster_handle);
if (cluster_handle->connected)
return 0;
......@@ -95,7 +94,7 @@ int mobject_store_connect(mobject_store_t cluster)
free(cluster_handle);
return -1;
}
/* we only need to the proto portion of the address to initialize */
/* we only need to get the proto portion of the address to initialize */
for(i=0; i<24 && svr_addr_str[i] != '\0' && svr_addr_str[i] != ':'; i++)
proto[i] = svr_addr_str[i];
......@@ -148,11 +147,11 @@ int mobject_store_connect(mobject_store_t cluster)
void mobject_store_shutdown(mobject_store_t cluster)
{
mobject_store_handle_t *cluster_handle =
(mobject_store_handle_t *)cluster;
struct mobject_store_handle *cluster_handle;
char *svr_kill_env_str;
int ret;
cluster_handle = (struct mobject_store_handle *)cluster;
assert(cluster_handle != NULL);
if (!cluster_handle->connected)
......@@ -179,6 +178,23 @@ void mobject_store_shutdown(mobject_store_t cluster)
return;
}
int mobject_store_ioctx_create(
mobject_store_t cluster,
const char * pool_name,
mobject_store_ioctx_t *ioctx)
{
*ioctx = (mobject_store_ioctx_t)calloc(1, sizeof(**ioctx));
(*ioctx)->pool_name = strdup(pool_name);
(*ioctx)->cluster = cluster;
return 0;
}
void mobject_store_ioctx_destroy(mobject_store_ioctx_t ioctx)
{
if(ioctx) free(ioctx->pool_name);
free(ioctx);
}
int mobject_store_write_op_operate(mobject_store_write_op_t write_op,
mobject_store_ioctx_t io,
const char *oid,
......@@ -269,7 +285,7 @@ static void mobject_store_register(margo_instance_id mid)
}
// send a shutdown signal to a server cluster
static int mobject_store_shutdown_servers(mobject_store_handle_t *cluster_handle)
static int mobject_store_shutdown_servers(struct mobject_store_handle *cluster_handle)
{
hg_addr_t svr_addr;
hg_handle_t h;
......
......@@ -3,17 +3,26 @@
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __MOBJECT_STORE_HANDLE_H
#define __MOBJECT_STORE_HANDLE_H
#ifndef __CLUSTER_H
#define __CLUSTER_H
#include <margo.h>
#include <ssg.h>
#include "libmobject-store.h"
typedef struct mobject_store_handle
#define MOBJECT_CLUSTER_FILE_ENV "MOBJECT_CLUSTER_FILE"
struct mobject_store_handle
{
margo_instance_id mid;
ssg_group_id_t gid;
int connected;
} mobject_store_handle_t;
};
struct mobject_store_ioctx
{
mobject_store_t cluster;
char* pool_name;
};
#endif
/*
* (C) 2017 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#include "libmobject-store.h"
#include "src/client/io-context.h"
#include "src/client/cluster-handle.h"
int mobject_store_ioctx_create(
mobject_store_t cluster,
const char * pool_name,
mobject_store_ioctx_t *ioctx)
{
(void)pool_name; /* XXX pool is ignored for now and instead use one global "pool" */
*ioctx = (mobject_store_ioctx_t)calloc(1, sizeof(**ioctx));
(*ioctx)->pool_name = strdup(pool_name);
(*ioctx)->cluster = cluster;
return 0;
}
void mobject_store_ioctx_destroy(mobject_store_ioctx_t ioctx)
{
if(ioctx) free(ioctx->pool_name);
free(ioctx);
}
/*
* (C) 2017 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __MOBJECT_IOCTX_H
#define __MOBJECT_IOCTX_H
#include <margo.h>
#include "mobject-store-config.h"
#include "libmobject-store.h"
typedef struct mobject_ioctx {
mobject_store_t cluster;
char* pool_name;
}* mobject_store_ioctx_t;
#endif
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