diff --git a/binding/lua/lua_bplib.c b/binding/lua/lua_bplib.c index 83b3bf8f..6da8a0d9 100644 --- a/binding/lua/lua_bplib.c +++ b/binding/lua/lua_bplib.c @@ -496,7 +496,7 @@ int lbplib_open (lua_State* L) lua_getfield(L, 6, "active_table_size"); lua_getfield(L, 6, "max_fills_per_dacs"); lua_getfield(L, 6, "max_gaps_per_dacs"); - lua_getfield(L, 6, "recover_storage"); + lua_getfield(L, 6, "persistent_storage"); /* Get Attributes from Stack */ attributes.lifetime = luaL_optnumber(L, -16, attributes.lifetime); @@ -514,7 +514,7 @@ int lbplib_open (lua_State* L) attributes.active_table_size = luaL_optnumber(L, -4, attributes.active_table_size); attributes.max_fills_per_dacs = luaL_optnumber(L, -3, attributes.max_fills_per_dacs); attributes.max_gaps_per_dacs = luaL_optnumber(L, -2, attributes.max_gaps_per_dacs); - attributes.recover_storage = luaL_optnumber(L, -1, attributes.recover_storage) != 0.0; + attributes.persistent_storage = luaL_optnumber(L, -1, attributes.persistent_storage) != 0.0; attributes.storage_service_parm = NULL; } diff --git a/binding/lua/test/ut_recover.lua b/binding/lua/test/ut_recover.lua index 088f476a..0ab70d22 100644 --- a/binding/lua/test/ut_recover.lua +++ b/binding/lua/test/ut_recover.lua @@ -15,7 +15,7 @@ local dst_node = 72 local dst_serv = 43 local num_bundles = 128 -local timeout = 10 +local timeout = 2 local receiver = bplib.open(dst_node, dst_serv, src_node, src_serv, store) @@ -52,7 +52,7 @@ sender:close() ----------------------------------------------------------------------- print(string.format('%s/%s: Test 2 - store and recover all bundles', store, src)) -local attributes = { recover_storage = 1 } +local attributes = { persistent_storage = 1 } local sender = bplib.open(src_node, src_serv, dst_node, dst_serv, store, attributes) for i=1,num_bundles do @@ -66,13 +66,57 @@ end sender:close() --- reopen channel, no recovery -- +-- reopen channel, with recovery -- local sender = bplib.open(src_node, src_serv, dst_node, dst_serv, store, attributes) -- check stats -- rc, stats = sender:stats() runner.check(bp.check_stats(stats, {stored_bundles=num_bundles, stored_payloads=0, stored_dacs=0})) +-- do not close channel so that test below +-- can use recovered bundles + +----------------------------------------------------------------------- +print(string.format('%s/%s: Test 3 - store and recover some bundles', store, src)) + +-- load half of the recovered bundles +for i=1,num_bundles/2 do + payload = string.format('HELLO WORLD %d', i) + + -- load bundle -- + rc, bundle, flags = sender:load(1000) + runner.check(rc) + runner.check(bundle ~= nil) + runner.check(bp.check_flags(flags, {}), "flags set on load") + runner.check(bp.find_payload(bundle, payload), string.format('Error - wrong payload when checking for %s', payload)) + + -- process bundle -- + rc, flags = receiver:process(bundle, 1000) + runner.check(rc) + runner.check(bp.check_flags(flags, {}), "flags set on process") +end + +-- load DACS -- +bplib.sleep(timeout) +rc, bundle, flags = receiver:load(1000) +runner.check(rc) +runner.check(bundle ~= nil) +runner.check(bp.check_flags(flags, {"routeneeded"})) + +-- process DACS -- +rc, flags = sender:process(bundle, 1000) +runner.check(rc, string.format('Error(%d) - failed to process DACS: %s', errno, rc)) +runner.check(bp.check_flags(flags, {})) + +sender:close() + +-- reopen channel, with recovery -- +local sender = bplib.open(src_node, src_serv, dst_node, dst_serv, store, attributes) + +-- check stats -- +rc, stats = sender:stats() +runner.check(bp.check_stats(stats, {stored_bundles=num_bundles/2, stored_payloads=0, stored_dacs=0})) + sender:close() -- Clean Up -- diff --git a/inc/bplib.h b/inc/bplib.h index b1fc6852..e3cfbc09 100644 --- a/inc/bplib.h +++ b/inc/bplib.h @@ -135,7 +135,7 @@ extern "C" { #define BP_DEFAULT_ACTIVE_TABLE_SIZE 16384 /* bundles (must be smaller than BP_MAX_INDEX) */ #define BP_DEFAULT_MAX_FILLS_PER_DACS 64 /* constrains size of DACS bundle */ #define BP_DEFAULT_MAX_GAPS_PER_DACS 1028 /* sets size of internal memory used to aggregate custody */ -#define BP_DEFAULT_RECOVER_STORAGE false +#define BP_DEFAULT_PERSISTENT_STORAGE false #define BP_DEFAULT_STORAGE_SERVICE_PARM NULL /****************************************************************************** @@ -208,7 +208,7 @@ typedef struct { int active_table_size; /* number of unacknowledged bundles to keep track of */ int max_fills_per_dacs; /* limits the size of the DACS bundle */ int max_gaps_per_dacs; /* number of gaps in custody IDs that can be kept track of */ - bool recover_storage; /* attempt to recover bundles and payloads from storage service */ + bool persistent_storage; /* attempt to recover bundles and payloads from storage service */ void* storage_service_parm; /* pass through of parameters needed by storage service */ } bp_attr_t; diff --git a/lib/bplib.c b/lib/bplib.c index 64701402..ee6e7ffc 100644 --- a/lib/bplib.c +++ b/lib/bplib.c @@ -95,7 +95,7 @@ static const bp_attr_t default_attributes = { .active_table_size = BP_DEFAULT_ACTIVE_TABLE_SIZE, .max_fills_per_dacs = BP_DEFAULT_MAX_FILLS_PER_DACS, .max_gaps_per_dacs = BP_DEFAULT_MAX_GAPS_PER_DACS, - .recover_storage = BP_DEFAULT_RECOVER_STORAGE, + .persistent_storage = BP_DEFAULT_PERSISTENT_STORAGE, .storage_service_parm = BP_DEFAULT_STORAGE_SERVICE_PARM }; @@ -278,7 +278,7 @@ bp_desc_t* bplib_open(bp_route_t route, bp_store_t store, bp_attr_t attributes) } /* Initialize Bundle Store */ - ch->bundle_handle = ch->store.create(BP_STORE_DATA_TYPE, route.local_node, route.local_service, attributes.recover_storage, attributes.storage_service_parm); + ch->bundle_handle = ch->store.create(BP_STORE_DATA_TYPE, route.local_node, route.local_service, attributes.persistent_storage, attributes.storage_service_parm); if(ch->bundle_handle < 0) { bplog(NULL, BP_FLAG_STORE_FAILURE, "Failed to create storage handle for bundles\n"); @@ -287,7 +287,7 @@ bp_desc_t* bplib_open(bp_route_t route, bp_store_t store, bp_attr_t attributes) } /* Initialize Payload Store */ - ch->payload_handle = ch->store.create(BP_STORE_PAYLOAD_TYPE, route.local_node, route.local_service, attributes.recover_storage, attributes.storage_service_parm); + ch->payload_handle = ch->store.create(BP_STORE_PAYLOAD_TYPE, route.local_node, route.local_service, attributes.persistent_storage, attributes.storage_service_parm); if(ch->payload_handle < 0) { bplog(NULL, BP_FLAG_STORE_FAILURE, "Failed to create storage handle for payloads\n"); @@ -296,7 +296,7 @@ bp_desc_t* bplib_open(bp_route_t route, bp_store_t store, bp_attr_t attributes) } /* Initialize DACS Store */ - ch->dacs_handle = ch->store.create(BP_STORE_DACS_TYPE, route.local_node, route.local_service, attributes.recover_storage, attributes.storage_service_parm); + ch->dacs_handle = ch->store.create(BP_STORE_DACS_TYPE, route.local_node, route.local_service, attributes.persistent_storage, attributes.storage_service_parm); if(ch->dacs_handle < 0) { bplog(NULL, BP_FLAG_STORE_FAILURE, "Failed to create storage handle for dacs\n");