Commit 0ffce1c0 authored by Matthieu Dorier's avatar Matthieu Dorier

test client fully working

parent 7ed41c2c
...@@ -50,7 +50,7 @@ extern "C" { ...@@ -50,7 +50,7 @@ extern "C" {
*/ */
/* opaque type for a handle for interacting with a mobject store cluster */ /* opaque type for a handle for interacting with a mobject store cluster */
typedef void *mobject_store_t; typedef struct mobject_store_handle *mobject_store_t;
/** /**
* @name Operation Flags * @name Operation Flags
......
noinst_HEADERS += \ noinst_HEADERS += \
src/aio/completion.h \ src/aio/completion.h \
src/client/io-context.h \ src/client/io-context.h \
src/client/cluster-handle.h \
src/io-chain/args-read-actions.h \ src/io-chain/args-read-actions.h \
src/io-chain/args-write-actions.h \ src/io-chain/args-write-actions.h \
src/io-chain/prepare-read-op.h \ src/io-chain/prepare-read-op.h \
......
/*
* (C) 2017 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __MOBJECT_STORE_HANDLE_H
#define __MOBJECT_STORE_HANDLE_H
#include <margo.h>
#include <ssg.h>
typedef struct mobject_store_handle
{
margo_instance_id mid;
ssg_group_id_t gid;
int connected;
} mobject_store_handle_t;
#endif
...@@ -5,15 +5,16 @@ ...@@ -5,15 +5,16 @@
*/ */
#include "libmobject-store.h" #include "libmobject-store.h"
#include "src/client/io-context.h" #include "src/client/io-context.h"
#include "src/client/cluster-handle.h"
int mobject_store_ioctx_create( int mobject_store_ioctx_create(
mobject_store_t cluster, mobject_store_t cluster,
const char * pool_name, const char * pool_name,
mobject_store_ioctx_t *ioctx) mobject_store_ioctx_t *ioctx)
{ {
// TODO take mid from cluster parameter
*ioctx = (mobject_store_ioctx_t)calloc(1, sizeof(**ioctx)); *ioctx = (mobject_store_ioctx_t)calloc(1, sizeof(**ioctx));
(*ioctx)->pool_name = strdup(pool_name); (*ioctx)->pool_name = strdup(pool_name);
(*ioctx)->cluster = cluster;
return 0; return 0;
} }
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
#include "libmobject-store.h" #include "libmobject-store.h"
typedef struct mobject_ioctx { typedef struct mobject_ioctx {
margo_instance_id mid; mobject_store_t cluster;
hg_addr_t svr_addr; // TODO change this to an SSG thingy
char* pool_name; char* pool_name;
}* mobject_store_ioctx_t; }* mobject_store_ioctx_t;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "src/client/io-context.h" #include "src/client/io-context.h"
#include "src/io-chain/prepare-read-op.h" #include "src/io-chain/prepare-read-op.h"
#include "src/io-chain/prepare-write-op.h" #include "src/io-chain/prepare-write-op.h"
#include "src/client/cluster-handle.h"
#define MOBJECT_CLUSTER_FILE_ENV "MOBJECT_CLUSTER_FILE" #define MOBJECT_CLUSTER_FILE_ENV "MOBJECT_CLUSTER_FILE"
...@@ -29,13 +30,6 @@ hg_id_t mobject_write_op_rpc_id; ...@@ -29,13 +30,6 @@ hg_id_t mobject_write_op_rpc_id;
hg_id_t mobject_read_op_rpc_id; hg_id_t mobject_read_op_rpc_id;
hg_id_t mobject_shutdown_rpc_id; hg_id_t mobject_shutdown_rpc_id;
typedef struct mobject_store_handle
{
margo_instance_id mid;
ssg_group_id_t gid;
int connected;
} mobject_store_handle_t;
static void mobject_store_register(margo_instance_id mid); 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(mobject_store_handle_t *cluster_handle);
...@@ -195,10 +189,12 @@ int mobject_store_write_op_operate(mobject_store_write_op_t write_op, ...@@ -195,10 +189,12 @@ int mobject_store_write_op_operate(mobject_store_write_op_t write_op,
in.pool_name = io->pool_name; in.pool_name = io->pool_name;
in.write_op = write_op; in.write_op = write_op;
prepare_write_op(io->mid, write_op); prepare_write_op(io->cluster->mid, write_op);
hg_addr_t svr_addr = ssg_get_addr(io->cluster->gid, 0); // XXX pick other servers using ch-placement
hg_handle_t h; hg_handle_t h;
margo_create(io->mid, io->svr_addr, mobject_write_op_rpc_id, &h); margo_create(io->cluster->mid, svr_addr, mobject_write_op_rpc_id, &h);
margo_forward(h, &in); margo_forward(h, &in);
write_op_out_t resp; write_op_out_t resp;
...@@ -219,12 +215,12 @@ int mobject_store_read_op_operate(mobject_store_read_op_t read_op, ...@@ -219,12 +215,12 @@ int mobject_store_read_op_operate(mobject_store_read_op_t read_op,
in.pool_name = ioctx->pool_name; in.pool_name = ioctx->pool_name;
in.read_op = read_op; in.read_op = read_op;
prepare_read_op(ioctx->mid, read_op); prepare_read_op(ioctx->cluster->mid, read_op);
// TODO: svr_addr should be computed based on the pool name, object name, hg_addr_t svr_addr = ssg_get_addr(ioctx->cluster->gid, 0); // XXX pick other servers using ch-placement
// and SSG structures accessible via the io context
hg_handle_t h; hg_handle_t h;
margo_create(ioctx->mid, ioctx->svr_addr, mobject_read_op_rpc_id, &h); margo_create(ioctx->cluster->mid, svr_addr, mobject_read_op_rpc_id, &h);
margo_forward(h, &in); margo_forward(h, &in);
read_op_out_t resp; read_op_out_t resp;
......
...@@ -3,33 +3,17 @@ ...@@ -3,33 +3,17 @@
#include <margo.h> #include <margo.h>
#include <libmobject-store.h> #include <libmobject-store.h>
#include "src/client/io-context.h" // XXX included because we modify manually the ioctx
// XXX prototype here even though we shouldn't see this function
void mobject_store_register(margo_instance_id mid);
/* Main function. */ /* Main function. */
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
if(argc != 2) { mobject_store_t cluster;
fprintf(stderr,"Usage: %s <server address>\n", argv[0]); mobject_store_create(&cluster, "admin");
exit(0);
}
/* Start Margo */ mobject_store_connect(cluster);
margo_instance_id mid = margo_init("bmi+tcp", MARGO_CLIENT_MODE, 0, 0);
// XXX this should be handled by SSG in mobject_store_connect
hg_addr_t svr_addr;
margo_addr_lookup(mid, argv[1], &svr_addr);
mobject_store_ioctx_t ioctx; mobject_store_ioctx_t ioctx;
mobject_store_ioctx_create(NULL, "my-object-pool", &ioctx); mobject_store_ioctx_create(cluster, "my-object-pool", &ioctx);
// XXX the bellow modifications of ioctx should be done inside
// mobject_store_ioctx_create once we have the rest of the API
ioctx->svr_addr = svr_addr;
ioctx->mid = mid;
char buffer[256]; char buffer[256];
unsigned i; unsigned i;
...@@ -113,11 +97,7 @@ int main(int argc, char** argv) ...@@ -113,11 +97,7 @@ int main(int argc, char** argv)
mobject_store_ioctx_destroy(ioctx); mobject_store_ioctx_destroy(ioctx);
// XXX this should be done through SSG inside mobject_store_shutdown mobject_store_shutdown(cluster);
margo_addr_free(mid, svr_addr);
/* shut down Margo */
margo_finalize(mid);
return 0; return 0;
} }
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