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

test client fully working

parent 7ed41c2c
......@@ -50,7 +50,7 @@ extern "C" {
*/
/* 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
......
noinst_HEADERS += \
src/aio/completion.h \
src/client/io-context.h \
src/client/cluster-handle.h \
src/io-chain/args-read-actions.h \
src/io-chain/args-write-actions.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 @@
*/
#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)
{
// TODO take mid from cluster parameter
*ioctx = (mobject_store_ioctx_t)calloc(1, sizeof(**ioctx));
(*ioctx)->pool_name = strdup(pool_name);
(*ioctx)->cluster = cluster;
return 0;
}
......
......@@ -11,8 +11,7 @@
#include "libmobject-store.h"
typedef struct mobject_ioctx {
margo_instance_id mid;
hg_addr_t svr_addr; // TODO change this to an SSG thingy
mobject_store_t cluster;
char* pool_name;
}* mobject_store_ioctx_t;
......
......@@ -20,6 +20,7 @@
#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"
......@@ -29,13 +30,6 @@ hg_id_t mobject_write_op_rpc_id;
hg_id_t mobject_read_op_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 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,
in.pool_name = io->pool_name;
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;
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);
write_op_out_t resp;
......@@ -219,12 +215,12 @@ int mobject_store_read_op_operate(mobject_store_read_op_t read_op,
in.pool_name = ioctx->pool_name;
in.read_op = read_op;
prepare_read_op(ioctx->mid, read_op);
prepare_read_op(ioctx->cluster->mid, read_op);
hg_addr_t svr_addr = ssg_get_addr(ioctx->cluster->gid, 0); // XXX pick other servers using ch-placement
// TODO: svr_addr should be computed based on the pool name, object name,
// and SSG structures accessible via the io context
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);
read_op_out_t resp;
......
......@@ -3,33 +3,17 @@
#include <margo.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. */
int main(int argc, char** argv)
{
if(argc != 2) {
fprintf(stderr,"Usage: %s <server address>\n", argv[0]);
exit(0);
}
mobject_store_t cluster;
mobject_store_create(&cluster, "admin");
/* Start Margo */
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_connect(cluster);
mobject_store_ioctx_t ioctx;
mobject_store_ioctx_create(NULL, "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;
mobject_store_ioctx_create(cluster, "my-object-pool", &ioctx);
char buffer[256];
unsigned i;
......@@ -113,11 +97,7 @@ int main(int argc, char** argv)
mobject_store_ioctx_destroy(ioctx);
// XXX this should be done through SSG inside mobject_store_shutdown
margo_addr_free(mid, svr_addr);
/* shut down Margo */
margo_finalize(mid);
mobject_store_shutdown(cluster);
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