Commit 4ab5867f authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

write_op fully tested and working

parent d9dc798a
...@@ -6,7 +6,7 @@ TESTS = ...@@ -6,7 +6,7 @@ TESTS =
EXTRA_DIST = prepare.sh EXTRA_DIST = prepare.sh
AM_CPPFLAGS = -I$(top_srcdir)/include AM_CPPFLAGS = -I$(top_srcdir)/include
AM_CFLAGS = AM_CFLAGS =
AM_CXXFLAGS = $(AM_CFLAGS) AM_CXXFLAGS = $(AM_CFLAGS)
lib_LTLIBRARIES = src/libmobject-store.la lib_LTLIBRARIES = src/libmobject-store.la
......
...@@ -79,6 +79,9 @@ enum { ...@@ -79,6 +79,9 @@ enum {
}; };
/** @} */ /** @} */
#define LIBMOBJECT_CREATE_EXCLUSIVE 1
#define LIBMOBJECT_CREATE_IDEMPOTENT 0
/** /**
* @typedef mobject_store_ioctx_t * @typedef mobject_store_ioctx_t
* *
...@@ -294,9 +297,9 @@ void mobject_store_write_op_write_full(mobject_store_write_op_t write_op, ...@@ -294,9 +297,9 @@ void mobject_store_write_op_write_full(mobject_store_write_op_t write_op,
*/ */
void mobject_store_write_op_writesame(mobject_store_write_op_t write_op, void mobject_store_write_op_writesame(mobject_store_write_op_t write_op,
const char *buffer, const char *buffer,
size_t data_len, size_t data_len,
size_t write_len, size_t write_len,
uint64_t offset); uint64_t offset);
/** /**
* Append to end of object. * Append to end of object.
...@@ -305,8 +308,8 @@ void mobject_store_write_op_writesame(mobject_store_write_op_t write_op, ...@@ -305,8 +308,8 @@ void mobject_store_write_op_writesame(mobject_store_write_op_t write_op,
* @param len length of buffer * @param len length of buffer
*/ */
void mobject_store_write_op_append(mobject_store_write_op_t write_op, void mobject_store_write_op_append(mobject_store_write_op_t write_op,
const char *buffer, const char *buffer,
size_t len); size_t len);
/** /**
* Remove object * Remove object
* @param write_op operation to add this action to * @param write_op operation to add this action to
......
...@@ -31,7 +31,10 @@ static void convert_append(uint64_t* cur_offset, ...@@ -31,7 +31,10 @@ static void convert_append(uint64_t* cur_offset,
void prepare_write_op(margo_instance_id mid, mobject_store_write_op_t write_op) void prepare_write_op(margo_instance_id mid, mobject_store_write_op_t write_op)
{ {
if(write_op->ready == 1) return; if(write_op->ready == 1) return;
if(write_op->num_actions == 0) return; if(write_op->num_actions == 0) {
write_op->ready = 1;
return;
}
wr_action_base_t action; wr_action_base_t action;
......
...@@ -113,7 +113,7 @@ hg_return_t hg_proc_mobject_store_read_op_t(hg_proc_t proc, mobject_store_read_o ...@@ -113,7 +113,7 @@ hg_return_t hg_proc_mobject_store_read_op_t(hg_proc_t proc, mobject_store_read_o
// for each action ... // for each action ...
DL_FOREACH((*read_op)->actions,elem) { DL_FOREACH((*read_op)->actions,elem) {
read_op_code_t opcode = elem->type; read_op_code_t opcode = elem->type;
MOBJECT_ASSERT((opcode <= 0 || opcode >= _READ_OPCODE_END_ENUM_), MOBJECT_ASSERT((opcode > 0 || opcode < _READ_OPCODE_END_ENUM_),
"Invalid read_op opcode"); "Invalid read_op opcode");
// encode the type of action // encode the type of action
ret = hg_proc_memcpy(proc, &opcode, sizeof(opcode)); ret = hg_proc_memcpy(proc, &opcode, sizeof(opcode));
...@@ -143,11 +143,12 @@ hg_return_t hg_proc_mobject_store_read_op_t(hg_proc_t proc, mobject_store_read_o ...@@ -143,11 +143,12 @@ hg_return_t hg_proc_mobject_store_read_op_t(hg_proc_t proc, mobject_store_read_o
read_op_code_t opcode; read_op_code_t opcode;
ret = hg_proc_memcpy(proc, &opcode, sizeof(opcode)); ret = hg_proc_memcpy(proc, &opcode, sizeof(opcode));
if(ret != HG_SUCCESS) return ret; if(ret != HG_SUCCESS) return ret;
MOBJECT_ASSERT((opcode <= 0 || opcode >= _READ_OPCODE_END_ENUM_), MOBJECT_ASSERT((opcode > 0 || opcode < _READ_OPCODE_END_ENUM_),
"Invalid write_op opcode"); "Invalid write_op opcode");
// decode the action's arguments // decode the action's arguments
ret = decode_read_action[opcode](proc, &position, &next_action); ret = decode_read_action[opcode](proc, &position, &next_action);
if(ret != HG_SUCCESS) return ret; if(ret != HG_SUCCESS) return ret;
next_action->type = opcode;
// append to the list // append to the list
DL_APPEND((*read_op)->actions, next_action); DL_APPEND((*read_op)->actions, next_action);
} }
......
...@@ -163,7 +163,7 @@ hg_return_t hg_proc_mobject_store_write_op_t(hg_proc_t proc, mobject_store_write ...@@ -163,7 +163,7 @@ hg_return_t hg_proc_mobject_store_write_op_t(hg_proc_t proc, mobject_store_write
// for each action ... // for each action ...
DL_FOREACH((*write_op)->actions,elem) { DL_FOREACH((*write_op)->actions,elem) {
write_op_code_t opcode = elem->type; write_op_code_t opcode = elem->type;
MOBJECT_ASSERT((opcode <= 0 || opcode >= _WRITE_OPCODE_END_ENUM_), MOBJECT_ASSERT((opcode > 0 && opcode < _WRITE_OPCODE_END_ENUM_),
"Invalid write_op opcode"); "Invalid write_op opcode");
// encode the type of action // encode the type of action
ret = hg_proc_memcpy(proc, &opcode, sizeof(opcode)); ret = hg_proc_memcpy(proc, &opcode, sizeof(opcode));
...@@ -194,11 +194,12 @@ hg_return_t hg_proc_mobject_store_write_op_t(hg_proc_t proc, mobject_store_write ...@@ -194,11 +194,12 @@ hg_return_t hg_proc_mobject_store_write_op_t(hg_proc_t proc, mobject_store_write
write_op_code_t opcode; write_op_code_t opcode;
ret = hg_proc_memcpy(proc, &opcode, sizeof(opcode)); ret = hg_proc_memcpy(proc, &opcode, sizeof(opcode));
if(ret != HG_SUCCESS) return ret; if(ret != HG_SUCCESS) return ret;
MOBJECT_ASSERT((opcode <= 0 || opcode >= _WRITE_OPCODE_END_ENUM_), MOBJECT_ASSERT((opcode > 0 && opcode < _WRITE_OPCODE_END_ENUM_),
"Invalid write_op opcode"); "Invalid write_op opcode");
// decode the action's arguments // decode the action's arguments
ret = decode_write_action[opcode](proc, &position, &next_action); ret = decode_write_action[opcode](proc, &position, &next_action);
if(ret != HG_SUCCESS) return ret; if(ret != HG_SUCCESS) return ret;
next_action->type = opcode;
// append to the list // append to the list
DL_APPEND((*write_op)->actions, next_action); DL_APPEND((*write_op)->actions, next_action);
} }
......
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
#include "read-op-impl.h" #include "read-op-impl.h"
#include "utlist.h" #include "utlist.h"
static void execute_read_op_visitor_on_stat(read_op_visitor_t visitor, rd_action_stat_t a); static void execute_read_op_visitor_on_stat(read_op_visitor_t visitor, rd_action_stat_t a, void* uargs);
static void execute_read_op_visitor_on_read(read_op_visitor_t visitor, rd_action_read_t a); static void execute_read_op_visitor_on_read(read_op_visitor_t visitor, rd_action_read_t a, void* uargs);
static void execute_read_op_visitor_on_omap_get_keys(read_op_visitor_t visitor, rd_action_omap_get_keys_t a); static void execute_read_op_visitor_on_omap_get_keys(read_op_visitor_t visitor, rd_action_omap_get_keys_t a, void* uargs);
static void execute_read_op_visitor_on_omap_get_vals(read_op_visitor_t visitor, rd_action_omap_get_vals_t a); static void execute_read_op_visitor_on_omap_get_vals(read_op_visitor_t visitor, rd_action_omap_get_vals_t a, void* uargs);
static void execute_read_op_visitor_on_omap_get_vals_by_keys(read_op_visitor_t visitor, rd_action_omap_get_vals_by_keys_t a); static void execute_read_op_visitor_on_omap_get_vals_by_keys(read_op_visitor_t visitor, rd_action_omap_get_vals_by_keys_t a, void* uargs);
typedef void (*dispatch_fn)(read_op_visitor_t, rd_action_base_t); typedef void (*dispatch_fn)(read_op_visitor_t, rd_action_base_t, void*);
static dispatch_fn visitor_dispatch[_READ_OPCODE_END_ENUM_] = { static dispatch_fn visitor_dispatch[_READ_OPCODE_END_ENUM_] = {
NULL, NULL,
...@@ -25,15 +25,14 @@ static dispatch_fn visitor_dispatch[_READ_OPCODE_END_ENUM_] = { ...@@ -25,15 +25,14 @@ static dispatch_fn visitor_dispatch[_READ_OPCODE_END_ENUM_] = {
(dispatch_fn)execute_read_op_visitor_on_omap_get_vals_by_keys, (dispatch_fn)execute_read_op_visitor_on_omap_get_vals_by_keys,
}; };
void execute_read_op_visitor(read_op_visitor_t visitor, mobject_store_read_op_t read_op) void execute_read_op_visitor(read_op_visitor_t visitor, mobject_store_read_op_t read_op, void* uargs)
{ {
void* uargs = visitor->uargs;
rd_action_base_t a; rd_action_base_t a;
visitor->visit_begin(uargs); visitor->visit_begin(uargs);
DL_FOREACH((read_op->actions), a) { DL_FOREACH((read_op->actions), a) {
visitor_dispatch[a->type](visitor, a); visitor_dispatch[a->type](visitor, a, uargs);
} }
visitor->visit_end(uargs); visitor->visit_end(uargs);
...@@ -43,31 +42,31 @@ void execute_read_op_visitor(read_op_visitor_t visitor, mobject_store_read_op_t ...@@ -43,31 +42,31 @@ void execute_read_op_visitor(read_op_visitor_t visitor, mobject_store_read_op_t
// STATIC FUNCTIONS BELOW // // STATIC FUNCTIONS BELOW //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static void execute_read_op_visitor_on_stat(read_op_visitor_t visitor, rd_action_stat_t a) static void execute_read_op_visitor_on_stat(read_op_visitor_t visitor, rd_action_stat_t a, void* uargs)
{ {
if(visitor->visit_stat) if(visitor->visit_stat)
visitor->visit_stat(visitor->uargs, a->psize, a->pmtime, a->prval); visitor->visit_stat(uargs, a->psize, a->pmtime, a->prval);
} }
static void execute_read_op_visitor_on_read(read_op_visitor_t visitor, rd_action_read_t a) static void execute_read_op_visitor_on_read(read_op_visitor_t visitor, rd_action_read_t a, void* uargs)
{ {
if(visitor->visit_read) if(visitor->visit_read)
visitor->visit_read(visitor->uargs, a->offset, a->len, a->buffer, a->bytes_read, a->prval); visitor->visit_read(uargs, a->offset, a->len, a->buffer, a->bytes_read, a->prval);
} }
static void execute_read_op_visitor_on_omap_get_keys(read_op_visitor_t visitor, rd_action_omap_get_keys_t a) static void execute_read_op_visitor_on_omap_get_keys(read_op_visitor_t visitor, rd_action_omap_get_keys_t a, void* uargs)
{ {
if(visitor->visit_omap_get_keys) if(visitor->visit_omap_get_keys)
visitor->visit_omap_get_keys(visitor->uargs, a->start_after, a->max_return, a->iter, a->prval); visitor->visit_omap_get_keys(uargs, a->start_after, a->max_return, a->iter, a->prval);
} }
static void execute_read_op_visitor_on_omap_get_vals(read_op_visitor_t visitor, rd_action_omap_get_vals_t a) static void execute_read_op_visitor_on_omap_get_vals(read_op_visitor_t visitor, rd_action_omap_get_vals_t a, void* uargs)
{ {
if(visitor->visit_omap_get_vals) if(visitor->visit_omap_get_vals)
visitor->visit_omap_get_vals(visitor->uargs, a->start_after, a->filter_prefix, a->max_return, a->iter, a->prval); visitor->visit_omap_get_vals(uargs, a->start_after, a->filter_prefix, a->max_return, a->iter, a->prval);
} }
static void execute_read_op_visitor_on_omap_get_vals_by_keys(read_op_visitor_t visitor, rd_action_omap_get_vals_by_keys_t a) static void execute_read_op_visitor_on_omap_get_vals_by_keys(read_op_visitor_t visitor, rd_action_omap_get_vals_by_keys_t a, void* uargs)
{ {
if(visitor->visit_omap_get_vals_by_keys == NULL) return; if(visitor->visit_omap_get_vals_by_keys == NULL) return;
...@@ -78,6 +77,6 @@ static void execute_read_op_visitor_on_omap_get_vals_by_keys(read_op_visitor_t v ...@@ -78,6 +77,6 @@ static void execute_read_op_visitor_on_omap_get_vals_by_keys(read_op_visitor_t v
keys[i] = ptr; keys[i] = ptr;
ptr += strlen(keys[i])+1; ptr += strlen(keys[i])+1;
} }
visitor->visit_omap_get_vals_by_keys(visitor->uargs, keys, a->num_keys, a->iter, a->prval); visitor->visit_omap_get_vals_by_keys(uargs, keys, a->num_keys, a->iter, a->prval);
} }
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "buffer-union.h" #include "buffer-union.h"
typedef struct read_op_visitor { typedef struct read_op_visitor {
void* uargs;
void (*visit_begin)(void*); void (*visit_begin)(void*);
void (*visit_stat)(void*, uint64_t*, time_t*, int*); void (*visit_stat)(void*, uint64_t*, time_t*, int*);
void (*visit_read)(void*, uint64_t, size_t, buffer_u, size_t*, int*); void (*visit_read)(void*, uint64_t, size_t, buffer_u, size_t*, int*);
...@@ -20,6 +19,6 @@ typedef struct read_op_visitor { ...@@ -20,6 +19,6 @@ typedef struct read_op_visitor {
void (*visit_end)(void*); void (*visit_end)(void*);
}* read_op_visitor_t; }* read_op_visitor_t;
void execute_read_op_visitor(read_op_visitor_t visitor, mobject_store_read_op_t read_op); void execute_read_op_visitor(read_op_visitor_t visitor, mobject_store_read_op_t read_op, void* uarg);
#endif #endif
...@@ -195,6 +195,7 @@ void mobject_store_write_op_truncate(mobject_store_write_op_t write_op, ...@@ -195,6 +195,7 @@ void mobject_store_write_op_truncate(mobject_store_write_op_t write_op,
wr_action_truncate_t action = (wr_action_truncate_t)calloc(1, sizeof(*action)); wr_action_truncate_t action = (wr_action_truncate_t)calloc(1, sizeof(*action));
action->base.type = WRITE_OPCODE_TRUNCATE; action->base.type = WRITE_OPCODE_TRUNCATE;
action->offset = offset;
WRITE_ACTION_UPCAST(base, action); WRITE_ACTION_UPCAST(base, action);
DL_APPEND(write_op->actions, base); DL_APPEND(write_op->actions, base);
......
...@@ -7,19 +7,20 @@ ...@@ -7,19 +7,20 @@
#include "write-op-visitor.h" #include "write-op-visitor.h"
#include "write-op-impl.h" #include "write-op-impl.h"
#include "utlist.h" #include "utlist.h"
#include "log.h"
static void execute_write_op_visitor_on_create(write_op_visitor_t visitor, wr_action_create_t a); static void execute_write_op_visitor_on_create(write_op_visitor_t visitor, wr_action_create_t a, void* uargs);
static void execute_write_op_visitor_on_write(write_op_visitor_t visitor, wr_action_write_t a); static void execute_write_op_visitor_on_write(write_op_visitor_t visitor, wr_action_write_t a, void* uargs);
static void execute_write_op_visitor_on_write_full(write_op_visitor_t visitor, wr_action_write_full_t a); static void execute_write_op_visitor_on_write_full(write_op_visitor_t visitor, wr_action_write_full_t a, void* uargs);
static void execute_write_op_visitor_on_write_same(write_op_visitor_t visitor, wr_action_write_same_t a); static void execute_write_op_visitor_on_write_same(write_op_visitor_t visitor, wr_action_write_same_t a, void* uargs);
static void execute_write_op_visitor_on_append(write_op_visitor_t visitor, wr_action_append_t a); static void execute_write_op_visitor_on_append(write_op_visitor_t visitor, wr_action_append_t a, void* uargs);
static void execute_write_op_visitor_on_remove(write_op_visitor_t visitor, wr_action_remove_t a); static void execute_write_op_visitor_on_remove(write_op_visitor_t visitor, wr_action_remove_t a, void* uargs);
static void execute_write_op_visitor_on_truncate(write_op_visitor_t visitor, wr_action_truncate_t a); static void execute_write_op_visitor_on_truncate(write_op_visitor_t visitor, wr_action_truncate_t a, void* uargs);
static void execute_write_op_visitor_on_zero(write_op_visitor_t visitor, wr_action_zero_t a); static void execute_write_op_visitor_on_zero(write_op_visitor_t visitor, wr_action_zero_t a, void* uargs);
static void execute_write_op_visitor_on_omap_set(write_op_visitor_t visitor, wr_action_omap_set_t a); static void execute_write_op_visitor_on_omap_set(write_op_visitor_t visitor, wr_action_omap_set_t a, void* uargs);
static void execute_write_op_visitor_on_omap_rm_keys(write_op_visitor_t visitor, wr_action_omap_rm_keys_t a); static void execute_write_op_visitor_on_omap_rm_keys(write_op_visitor_t visitor, wr_action_omap_rm_keys_t a, void* uargs);
typedef void (*dispatch_fn)(write_op_visitor_t, wr_action_base_t); typedef void (*dispatch_fn)(write_op_visitor_t, wr_action_base_t, void* uargs);
static dispatch_fn visitor_dispatch[_WRITE_OPCODE_END_ENUM_] = { static dispatch_fn visitor_dispatch[_WRITE_OPCODE_END_ENUM_] = {
NULL, NULL,
...@@ -35,15 +36,16 @@ static dispatch_fn visitor_dispatch[_WRITE_OPCODE_END_ENUM_] = { ...@@ -35,15 +36,16 @@ static dispatch_fn visitor_dispatch[_WRITE_OPCODE_END_ENUM_] = {
(dispatch_fn)execute_write_op_visitor_on_omap_rm_keys (dispatch_fn)execute_write_op_visitor_on_omap_rm_keys
}; };
void execute_write_op_visitor(write_op_visitor_t visitor, mobject_store_write_op_t write_op) void execute_write_op_visitor(write_op_visitor_t visitor, mobject_store_write_op_t write_op, void* uargs)
{ {
void* uargs = visitor->uargs;
wr_action_base_t a; wr_action_base_t a;
visitor->visit_begin(uargs); visitor->visit_begin(uargs);
DL_FOREACH((write_op->actions), a) { DL_FOREACH((write_op->actions), a) {
visitor_dispatch[a->type](visitor, a); MOBJECT_ASSERT(a->type > 0 && a->type < _WRITE_OPCODE_END_ENUM_,
"Invalid action type");
visitor_dispatch[a->type](visitor, a, uargs);
} }
visitor->visit_end(uargs); visitor->visit_end(uargs);
...@@ -53,55 +55,55 @@ void execute_write_op_visitor(write_op_visitor_t visitor, mobject_store_write_op ...@@ -53,55 +55,55 @@ void execute_write_op_visitor(write_op_visitor_t visitor, mobject_store_write_op
// STATIC FUNCTIONS BELOW // // STATIC FUNCTIONS BELOW //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static void execute_write_op_visitor_on_create(write_op_visitor_t visitor, wr_action_create_t a) static void execute_write_op_visitor_on_create(write_op_visitor_t visitor, wr_action_create_t a, void* uargs)
{ {
if(visitor->visit_create) if(visitor->visit_create)
visitor->visit_create(visitor->uargs, a->exclusive); visitor->visit_create(uargs, a->exclusive);
} }
static void execute_write_op_visitor_on_write(write_op_visitor_t visitor, wr_action_write_t a) static void execute_write_op_visitor_on_write(write_op_visitor_t visitor, wr_action_write_t a, void* uargs)
{ {
if(visitor->visit_write) if(visitor->visit_write)
visitor->visit_write(visitor->uargs, a->buffer, a->len, a->offset); visitor->visit_write(uargs, a->buffer, a->len, a->offset);
} }
static void execute_write_op_visitor_on_write_full(write_op_visitor_t visitor, wr_action_write_full_t a) static void execute_write_op_visitor_on_write_full(write_op_visitor_t visitor, wr_action_write_full_t a, void* uargs)
{ {
if(visitor->visit_write_full) if(visitor->visit_write_full)
visitor->visit_write_full(visitor->uargs, a->buffer, a->len); visitor->visit_write_full(uargs, a->buffer, a->len);
} }
static void execute_write_op_visitor_on_write_same(write_op_visitor_t visitor, wr_action_write_same_t a) static void execute_write_op_visitor_on_write_same(write_op_visitor_t visitor, wr_action_write_same_t a, void* uargs)
{ {
if(visitor->visit_writesame) if(visitor->visit_writesame)
visitor->visit_writesame(visitor->uargs, a->buffer, a->data_len, a->write_len, a->offset); visitor->visit_writesame(uargs, a->buffer, a->data_len, a->write_len, a->offset);
} }
static void execute_write_op_visitor_on_append(write_op_visitor_t visitor, wr_action_append_t a) static void execute_write_op_visitor_on_append(write_op_visitor_t visitor, wr_action_append_t a, void* uargs)
{ {
if(visitor->visit_append) if(visitor->visit_append)
visitor->visit_append(visitor->uargs, a->buffer, a->len); visitor->visit_append(uargs, a->buffer, a->len);
} }
static void execute_write_op_visitor_on_remove(write_op_visitor_t visitor, wr_action_remove_t a) static void execute_write_op_visitor_on_remove(write_op_visitor_t visitor, wr_action_remove_t a, void* uargs)
{ {
if(visitor->visit_remove) if(visitor->visit_remove)
visitor->visit_remove(visitor->uargs); visitor->visit_remove(uargs);
} }
static void execute_write_op_visitor_on_truncate(write_op_visitor_t visitor, wr_action_truncate_t a) static void execute_write_op_visitor_on_truncate(write_op_visitor_t visitor, wr_action_truncate_t a, void* uargs)
{ {
if(visitor->visit_truncate) if(visitor->visit_truncate)
visitor->visit_truncate(visitor->uargs, a->offset); visitor->visit_truncate(uargs, a->offset);
} }
static void execute_write_op_visitor_on_zero(write_op_visitor_t visitor, wr_action_zero_t a) static void execute_write_op_visitor_on_zero(write_op_visitor_t visitor, wr_action_zero_t a, void* uargs)
{ {
if(visitor->visit_zero) if(visitor->visit_zero)
visitor->visit_zero(visitor->uargs, a->offset, a->len); visitor->visit_zero(uargs, a->offset, a->len);
} }
static void execute_write_op_visitor_on_omap_set(write_op_visitor_t visitor, wr_action_omap_set_t a) static void execute_write_op_visitor_on_omap_set(write_op_visitor_t visitor, wr_action_omap_set_t a, void* uargs)
{ {
if(visitor->visit_omap_set == NULL) return; if(visitor->visit_omap_set == NULL) return;
...@@ -126,12 +128,12 @@ static void execute_write_op_visitor_on_omap_set(write_op_visitor_t visitor, wr_ ...@@ -126,12 +128,12 @@ static void execute_write_op_visitor_on_omap_set(write_op_visitor_t visitor, wr_
ptr += lens[i]; ptr += lens[i];
} }
visitor->visit_omap_set(visitor->uargs, keys, vals, lens, num); visitor->visit_omap_set(uargs, keys, vals, lens, num);
} }
static void execute_write_op_visitor_on_omap_rm_keys(write_op_visitor_t visitor, wr_action_omap_rm_keys_t a) static void execute_write_op_visitor_on_omap_rm_keys(write_op_visitor_t visitor, wr_action_omap_rm_keys_t a, void* uargs)
{ {
if(visitor->visit_omap_rm_keys != NULL) return; if(visitor->visit_omap_rm_keys == NULL) return;
size_t num_keys = a->num_keys; size_t num_keys = a->num_keys;
const char* keys[num_keys]; const char* keys[num_keys];
...@@ -143,5 +145,5 @@ static void execute_write_op_visitor_on_omap_rm_keys(write_op_visitor_t visitor, ...@@ -143,5 +145,5 @@ static void execute_write_op_visitor_on_omap_rm_keys(write_op_visitor_t visitor,
ptr += strlen(keys[i])+1; ptr += strlen(keys[i])+1;
} }
visitor->visit_omap_rm_keys(visitor->uargs, keys, num_keys); visitor->visit_omap_rm_keys(uargs, keys, num_keys);
} }
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "buffer-union.h" #include "buffer-union.h"
typedef struct write_op_visitor { typedef struct write_op_visitor {
void* uargs;
void (*visit_begin)(void*); void (*visit_begin)(void*);
void (*visit_create)(void*, int); void (*visit_create)(void*, int);
void (*visit_write)(void*, buffer_u, size_t, uint64_t); void (*visit_write)(void*, buffer_u, size_t, uint64_t);
...@@ -25,6 +24,6 @@ typedef struct write_op_visitor { ...@@ -25,6 +24,6 @@ typedef struct write_op_visitor {
void (*visit_end)(void*); void (*visit_end)(void*);
}* write_op_visitor_t; }* write_op_visitor_t;
void execute_write_op_visitor(write_op_visitor_t visitor, mobject_store_write_op_t write_op); void execute_write_op_visitor(write_op_visitor_t visitor, mobject_store_write_op_t write_op, void* uargs);
#endif #endif
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <margo.h> #include <margo.h>
#include <libmobject-store.h>
#include "types.h" #include "types.h"
#include "src/prepare-write-op.h"
/* Main function. */ /* Main function. */
int main(int argc, char** argv) int main(int argc, char** argv)
...@@ -16,21 +18,53 @@ int main(int argc, char** argv) ...@@ -16,21 +18,53 @@ int main(int argc, char** argv)
/* Register a RPC function */ /* Register a RPC function */
hg_id_t write_op_rpc_id = MARGO_REGISTER(mid, "mobject_write_op", write_op_in_t, write_op_out_t, NULL); hg_id_t write_op_rpc_id = MARGO_REGISTER(mid, "mobject_write_op", write_op_in_t, write_op_out_t, NULL);
hg_id_t read_op_rpc_id = MARGO_REGISTER(mid, "mobject_read_op", read_op_in_t, read_op_out_t, NULL); hg_id_t read_op_rpc_id = MARGO_REGISTER(mid, "mobject_read_op", read_op_in_t, read_op_out_t, NULL);
/* Lookup the address of the server */ /* Lookup the address of the server */
hg_addr_t svr_addr; hg_addr_t svr_addr;
margo_addr_lookup(mid, argv[1], &svr_addr); margo_addr_lookup(mid, argv[1], &svr_addr);
char buffer[256];
unsigned i;
for(i=0; i<256; i++) buffer[i] = 'A'+(i % 26);
{ // WRITE OP TEST { // WRITE OP TEST
write_op_in_t in; write_op_in_t in;
in.object_name = "test-write-object";
// TODO fill the write_op_in_t
mobject_store_write_op_t write_op = mobject_store_create_write_op();
in.chain = write_op;
// Add a "create" operation
mobject_store_write_op_create(write_op, LIBMOBJECT_CREATE_EXCLUSIVE, NULL);
// Add a "write" operation
mobject_store_write_op_write(write_op, buffer, 128, 32);
// Add a "write_full" operation
mobject_store_write_op_write_full(write_op, buffer, 256);
// Add a "writesame" operation
mobject_store_write_op_writesame(write_op, buffer, 32, 64, 256);
// Add a "append" operation
mobject_store_write_op_append(write_op, buffer, 64);
// Add a "remove" operation
mobject_store_write_op_remove(write_op);
// Add a "truncate" operation
mobject_store_write_op_truncate(write_op, 32);
// Add a "zero" operation
mobject_store_write_op_zero(write_op, 16, 48);
// Add a "omap_set" operation
const char* keys[] = { "matthieu", "rob", "shane", "phil", "robl" };
const char* values[] = { "mdorier@anl.gov", "rross@anl.gov", "ssnyder@anl.gov", "carns@anl.gov", "robl@anl.gov" };
size_t val_sizes[] = { 16, 14, 16, 14, 13 };