StorageMemory storeRecv = new StorageMemory();
PeerDHT sender = null;
PeerDHT recv1 = null;
ChannelCreator cc = null;
try {
PeerBuilder pm1 = new PeerBuilder(new Number160("0x50")).p2pId(55).ports(2424);
ChannelServerConfiguration css = PeerBuilder.createDefaultChannelServerConfiguration();
css.idleTCPSeconds(Integer.MAX_VALUE);
pm1.channelServerConfiguration(css);
sender = new PeerBuilderDHT(pm1.start()).storage(storeSender).start();
PeerBuilder pm2 = new PeerBuilder(new Number160("0x20")).p2pId(55).ports(8088);
pm2.channelServerConfiguration(css);
recv1 = new PeerBuilderDHT(pm2.start()).storage(storeRecv).start();
StorageRPC smmSender = sender.storeRPC();
Map<Number160, Data> tmp = new HashMap<Number160, Data>();
byte[] me1 = new byte[50 * 1024 * 1024];
tmp.put(new Number160(77), new Data(me1));
FutureChannelCreator fcc = sender.peer().connectionBean().reservation().create(0, 1);
fcc.awaitUninterruptibly();
cc = fcc.channelCreator();
PutBuilder putBuilder = new PutBuilder(sender, new Number160(33));
putBuilder.domainKey(Number160.createHash("test"));
putBuilder.dataMapContent(tmp);
putBuilder.idleTCPSeconds(Integer.MAX_VALUE);
putBuilder.versionKey(Number160.ZERO);
FutureResponse fr = smmSender.put(recv1.peerAddress(), putBuilder, cc);
fr.awaitUninterruptibly();
Assert.assertEquals(true, fr.isSuccess());
//
GetBuilder getBuilder = new GetBuilder(recv1, new Number160(33));
getBuilder.domainKey(Number160.createHash("test"));
getBuilder.idleTCPSeconds(Integer.MAX_VALUE);
getBuilder.versionKey(Number160.ZERO);
fr = smmSender.get(recv1.peerAddress(), getBuilder, cc);
fr.awaitUninterruptibly();
System.err.println(fr.failedReason());
Assert.assertEquals(true, fr.isSuccess());
Number640 key = new Number640(new Number160(33), Number160.createHash("test"), new Number160(77), Number160.ZERO);
Assert.assertEquals(50 * 1024 * 1024, fr.responseMessage().dataMap(0).dataMap().get(key)
.length());
} finally {
if (cc != null) {
cc.shutdown().awaitListenersUninterruptibly();