Commit 2a06194c authored by Rob Latham's avatar Rob Latham
Browse files

initial skeleton of margo-based keyval

parents
Makefile.in
aclocal.m4
ar-lib
autom4te.cache/
compile
config.guess
config.sub
configure
depcomp
install-sh
ltmain.sh
m4/
missing
build/
test-driver
ACLOCAL_AMFLAGS="-Im4"
#bin_PROGRAMS = kv-client\
# kv-server
lib_LTLIBRARIES = libkvclient.la \
libkvserver.la
libkvclient_la_SOURCES = src/kv-client.c
libkvserver_la_SOURCES = src/kv-server.cc
include_HEADERS = src/sds-keyval.h
check_PROGRAMS = test/test-client \
test/test-server
TESTS = test/test-client \
test/test-server
test_test_client_CPPFLAGS = ${CPPFLAGS} -I${srcdir}/src
test_test_client_LDADD = ${LIBS} -lkvclient
test_test_server_CPPFLAGS = ${CPPFLAGS} -I${srcdir}/src
test_test_server_LDADD = ${LIBS} -lkvserver
= mochi service for keyvals
- implement any old keyval in the backend
- project key-val interface out to clients
- server does the store/retrieve
= Build requirements
- the ''mercury suite'': `mercury`, `margo`, `argobots`, `abt-snoozer`, and friends.
- autotools
- the [https://github.com/wangziqi2013/BwTree BwTree] implementation
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([sds-keyval], [0.1], [robl@mcs.anl.gov])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects silent-rules])
AM_SILENT_RULES([yes])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src/sds-keyval.h])
LT_PREREQ([2.2])
# LT_INIT needs to know about AR
AM_PROG_AR
LT_INIT([dlopen])
# Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
# Checks for libraries.
# Checks for header files.
#pkg-config and libraries supporting that
PKG_PROG_PKG_CONFIG
if test "x$PKG_CONFIG" == "x"; then
AC_MSG_ERROR([Could not find pkg-config utility!])
fi
PKG_CHECK_MODULES([MARGO],[margo],[],
[AC_MSG_ERROR([Could not find working margo installation!])])
LIBS="$MARGO_LIBS $LIBS"
CPPFLAGS="$MARGO_CFLAGS $CPPFLAGS"
CFLAGS="$MARGO_CFLAGS $CFLAGS"
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_INT64_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
#include "sds-keyval.h"
#include <mercury.h>
#include <margo.h>
#include <abt-snoozer.h>
#include <abt.h>
/* probably ends up in a standalone test program */
kv_context *kv_client_register(int argc, char **argv) {
int ret;
kv_context * context;
context = malloc(sizeof(kv_context));
context->hg_class = HG_Init("cci+tcp://localhost:1234", HG_FALSE);
context->hg_context = HG_Context_create(context->hg_class);
ABT_init(argc, argv);
ABT_snoozer_xstream_self_set();
ret = ABT_xstream_self(&(context->xstream));
context->mid = margo_init(0, 0, context->hg_context);
context->put_id = MERCURY_REGISTER(context->hg_class, "put",
put_in_t, put_out_t, NULL);
context->get_id = MERCURY_REGISTER(context->hg_class, "get",
get_in_t, get_out_t, NULL);
context->open_id = MERCURY_REGISTER(context->hg_class, "open",
open_in_t, open_out_t, NULL);
context->close_id = MERCURY_REGISTER(context->hg_class, "close",
close_in_t, close_out_t, NULL);
return context;
}
int kv_client_deregister(kv_context *context) {
margo_finalize(context->mid);
ABT_finalize();
HG_Context_destroy(context->hg_context);
HG_Finalize(context->hg_class);
free(context);
return 0;
}
#if 0
#include "bwtree.h"
#endif
#include "sds-keyval.h"
#include <mercury.h>
#include <margo.h>
#include <abt-snoozer.h>
#include <abt.h>
static hg_return_t open_handler(hg_handle_t h)
{
printf("SERVER: OPEN\n");
return HG_SUCCESS;
}
static hg_return_t close_handler(hg_handle_t h)
{
printf("SERVER: CLOSE\n");
return HG_SUCCESS;
}
static hg_return_t put_handler(hg_handle_t h)
{
printf("SERVER: PUT\n");
return HG_SUCCESS;
}
static hg_return_t get_handler(hg_handle_t h)
{
printf("SERVER: GET\n");
return HG_SUCCESS;
}
kv_context * kv_server_register(int argc, char **argv)
{
int ret;
hg_addr_t addr_self;
char addr_self_string[128];
hg_size_t addr_self_string_sz = 128;
kv_context *context;
context = (kv_context *)malloc(sizeof(*context));
/* sds keyval server init */
context->hg_class = HG_Init("cci+tcp://localhost:52345", HG_TRUE);
context->hg_context = HG_Context_create(context->hg_class);
ABT_init(argc, argv);
ABT_snoozer_xstream_self_set();
context->mid = margo_init(0, 0, context->hg_context);
/* figure out what address this server is listening on */
ret = HG_Addr_self(context->hg_class, &addr_self);
if(ret != HG_SUCCESS)
{
fprintf(stderr, "Error: HG_Addr_self()\n");
HG_Context_destroy(context->hg_context);
HG_Finalize(context->hg_class);
return(NULL);
}
ret = HG_Addr_to_string(context->hg_class, addr_self_string,
&addr_self_string_sz, addr_self);
if(ret != HG_SUCCESS)
{
fprintf(stderr, "Error: HG_Addr_self()\n");
HG_Context_destroy(context->hg_context);
HG_Finalize(context->hg_class);
HG_Addr_free(context->hg_class, addr_self);
return(NULL);
}
HG_Addr_free(context->hg_class, addr_self);
printf("# accepting RPCs on address \"%s\"\n", addr_self_string);
context->open_id = MERCURY_REGISTER(context->hg_class, "open",
open_in_t, open_out_t, open_handler);
context->close_id = MERCURY_REGISTER(context->hg_class, "close",
close_in_t, close_out_t, close_handler);
context->put_id = MERCURY_REGISTER(context->hg_class, "put",
put_in_t, put_out_t, put_handler);
context->get_id = MERCURY_REGISTER(context->hg_class, "get",
get_in_t, get_out_t, get_handler);
return context;
}
/* this is the same as client. should be moved to common utility library */
int kv_server_deregister(kv_context *context) {
margo_wait_for_finalize(context->mid);
margo_finalize(context->mid);
ABT_finalize();
HG_Context_destroy(context->hg_context);
HG_Finalize(context->hg_class);
free(context);
return 0;
}
#include <mercury.h>
#include <mercury_macros.h>
#include <margo.h>
#include <abt.h>
#include <abt-snoozer.h>
#if defined(__cplusplus)
extern "C" {
#endif
#if 0
sdskeyval_put();
sdskeyval_get();
#endif
/* do we need one for server, one for client? */
typedef struct kv_context_s {
hg_class_t * hg_class;
hg_context_t *hg_context;
margo_instance_id mid;
hg_addr_t svr_addr;
ABT_xstream xstream;
hg_id_t put_id;
hg_id_t get_id;
hg_id_t open_id;
hg_id_t close_id;
} kv_context;
MERCURY_GEN_PROC(put_in_t,
((int32_t)(x))\
((int32_t)(y)))
MERCURY_GEN_PROC(put_out_t, ((int32_t)(ret)))
MERCURY_GEN_PROC(get_in_t,
((int32_t)(x))\
((int32_t)(y)))
MERCURY_GEN_PROC(get_out_t, ((int32_t)(ret)))
MERCURY_GEN_PROC(open_in_t,
((int32_t)(x))\
((int32_t)(y)))
MERCURY_GEN_PROC(open_out_t, ((int32_t)(ret)))
MERCURY_GEN_PROC(close_in_t,
((int32_t)(x))\
((int32_t)(y)))
MERCURY_GEN_PROC(close_out_t, ((int32_t)(ret)))
kv_context *kv_client_register(int argc, char **argv);
kv_context * kv_server_register(int argc, char **argv);
/* both the same: should probably move to common */
int kv_client_deregister(kv_context *context);
int kv_server_deregister(kv_context *context);
#if defined(__cplusplus)
}
#endif
#include "sds-keyval.h"
#include <assert.h>
int main(int argc, char **argv) {
int ret;
kv_context * context = kv_client_register(argc, argv);
hg_handle_t handle;
open_in_t open_in;
open_out_t open_out;
get_in_t get_in;
get_in_t get_out;
put_in_t put_in;
put_out_t put_out;
close_in_t close_in;
close_out_t close_out;
ret = margo_addr_lookup(context->mid, argv[1], &(context->svr_addr));
assert(ret == HG_SUCCESS);
ret = HG_Create(context->hg_context, context->svr_addr,
context->open_id, &handle);
assert(ret == HG_SUCCESS);
ret = margo_forward(context->mid, handle, &open_in);
assert(ret == HG_SUCCESS);
ret = HG_Get_output(handle, &open_out);
assert(ret == HG_SUCCESS);
ret = margo_forward(context->mid, handle, &put_in);
assert(ret == HG_SUCCESS);
ret = HG_Get_output(handle, &put_out);
assert(ret == HG_SUCCESS);
ret = margo_forward(context->mid, handle, &get_in);
assert(ret == HG_SUCCESS);
ret = HG_Get_output(handle, &get_out);
assert(ret == HG_SUCCESS);
ret = margo_forward(context->mid, handle, &close_in);
assert(ret == HG_SUCCESS);
ret = HG_Get_output(handle, &close_out);
assert(ret == HG_SUCCESS);
kv_client_deregister(context);
}
#include "sds-keyval.h"
int main(int argc, char **argv) {
kv_context * context = kv_server_register(argc, argv);
margo_wait_for_finalize(context->mid);
kv_server_deregister(context);
}
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