-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v14.6.1 Features -------- * New helper to dump and load a cached channel to/from disk `dhtproto.client.helper.ChannelSerializer` The new helper class is designed for use by applications that require a complete copy of some DHT channel before they are able to start operating. In the case of a DHT outage (either partial or complete), getting a fresh copy of a channel is not possible, but many apps can function perfectly well with a copy of the channel that was previously saved to disk. The helper has methods to dump and load from/to associative arrays and `Map`s (see `ocean.util.container.map.Map`), or from/to any arbitrary container that supports iterating over and inserting <`hash_t`, `Contiguous!(S)`> records. Usage examples: see documented unittests in the module. * Simple methods to connect to a node or cluster `dhtproto.client.mixins.NeoSupport` The blocking API now has three additional methods named `connect`. These add either a single node (specified either by address & port or purely by port) or a cluster of nodes (specified by a config file) to the registry, and then blocks the current `Task` until the hash range of all nodes has been fetched. These new methods are intended to simplify use of the DHT client in test code and scripts. * New, ultra-minimal client ctor for use in scripts/tests `dhtproto.client.DhtClient` The existing constructors require an epoll instance and various user-specified configuration settings. The newly added constructor allows a DHT client to be instantiated with no configuration whatsoever: ``` auto dht = new DhtClient; // uses Task-scheduler's epoll instance ``` This greatly reduces the amount of boilerplate required to use a DHT client in a script or test.
- Loading branch information
Showing
99 changed files
with
634 additions
and
17,415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
FROM sociomantictsunami/dlang:v3 | ||
FROM sociomantictsunami/dlang:v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
set -xe | ||
|
||
# Install dependencies | ||
apt-get update | ||
apt-get install -y \ | ||
liblzo2-dev \ | ||
libebtree6-dev \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/******************************************************************************* | ||
Test channel serializer. | ||
Copyright: | ||
Copyright (c) 2019 dunnhumby Germany GmbH. All rights reserved. | ||
License: | ||
Boost Software License Version 1.0. See LICENSE.txt for details. | ||
*******************************************************************************/ | ||
|
||
module integrationtest.channelserializer.main; | ||
|
||
import dhtproto.client.helper.ChannelSerializer; | ||
|
||
import ocean.transition; | ||
import ocean.core.Test; | ||
import ocean.core.DeepCompare; | ||
import ocean.util.serialize.contiguous.Contiguous; | ||
import ocean.util.serialize.contiguous.Deserializer; | ||
import ocean.util.serialize.contiguous.Serializer; | ||
import ocean.util.test.DirectorySandbox; | ||
import ocean.util.container.map.HashMap; | ||
import Path = ocean.io.Path; | ||
|
||
version ( UnitTest ) { } | ||
else | ||
int main ( istring[] args ) | ||
{ | ||
struct S | ||
{ | ||
int i; | ||
bool b; | ||
cstring str; | ||
} | ||
|
||
auto test_dir = DirectorySandbox.create(["ChannelSerializer"]); | ||
scope (exit) test_dir.remove(); | ||
|
||
auto s1_init = S(23, true, "hello"); | ||
auto s2_init = S(42, false, "bonjour"); | ||
Contiguous!(S) s1, s2; | ||
void[] ser_buf; | ||
Deserializer.deserialize(Serializer.serialize(s1_init, ser_buf), s1); | ||
Deserializer.deserialize(Serializer.serialize(s2_init, ser_buf), s2); | ||
|
||
// AA dump / load test | ||
{ | ||
auto ser = new ChannelSerializer!(S)("test_channel"); | ||
Contiguous!(S)[hash_t] out_aa; | ||
out_aa[0] = s1; | ||
out_aa[1] = s2; | ||
ser.dump(out_aa, true); | ||
test(Path.exists("test_channel")); | ||
|
||
Contiguous!(S)[hash_t] in_aa; | ||
ser.load(in_aa); | ||
test!("==")(in_aa.length, 2); | ||
test(deepEquals(*(in_aa[0].ptr), *(s1.ptr))); | ||
test(deepEquals(*(in_aa[1].ptr), *(s2.ptr))); | ||
test!("!=")(in_aa[0].ptr.str.ptr, s1.ptr.str.ptr); | ||
test!("!=")(in_aa[1].ptr.str.ptr, s2.ptr.str.ptr); | ||
} | ||
|
||
// Map dump / load test | ||
{ | ||
auto ser = new ChannelSerializer!(S)("test_channel"); | ||
auto map = new HashMap!(Contiguous!(S))(10); | ||
*map.put(0) = s1; | ||
*map.put(1) = s2; | ||
ser.dump(map, true); | ||
test(Path.exists("test_channel")); | ||
|
||
map.clear(); | ||
ser.load(map); | ||
test!("==")(map.length, 2); | ||
test(deepEquals(*(map[0].ptr), *(s1.ptr))); | ||
test(deepEquals(*(map[1].ptr), *(s2.ptr))); | ||
test!("!=")(map[0].ptr.str.ptr, s1.ptr.str.ptr); | ||
test!("!=")(map[1].ptr.str.ptr, s2.ptr.str.ptr); | ||
} | ||
|
||
// Broken dump test | ||
{ | ||
auto ser = new ChannelSerializer!(S)("failed_channel"); | ||
|
||
void dumpRecord ( void delegate ( hash_t, ref Contiguous!(S) ) record_dg ) | ||
{ | ||
throw new Exception("File write error"); | ||
} | ||
|
||
testThrown!()(ser.dump(&dumpRecord, true)); | ||
test(!Path.exists("failed_channel")); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
### New helper to dump and load a cached channel to/from disk | ||
|
||
`dhtproto.client.helper.ChannelSerializer` | ||
|
||
The new helper class is designed for use by applications that require a complete | ||
copy of some DHT channel before they are able to start operating. In the case of | ||
a DHT outage (either partial or complete), getting a fresh copy of a channel is | ||
not possible, but many apps can function perfectly well with a copy of the | ||
channel that was previously saved to disk. | ||
|
||
The helper has methods to dump and load from/to associative arrays and `Map`s | ||
(see `ocean.util.container.map.Map`), or from/to any arbitrary container that | ||
supports iterating over and inserting <`hash_t`, `Contiguous!(S)`> records. | ||
|
||
Usage examples: see documented unittests in the module. | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.