.makeAndListen();
p2.bootstrap().setPeerAddress(p1.getPeerAddress()).start().awaitUninterruptibly();
p1.bootstrap().setPeerAddress(p2.getPeerAddress()).start().awaitUninterruptibly();
Number160 lKey = Number160.createHash("location");
Number160 dKey = Number160.createHash("domain");
List<Long> timeStamps = new ArrayList<Long>();
for (int i = 0; i < 5; i++) {
long timeStamp = new Date().getTime();
timeStamps.add(timeStamp);
// to guarantee different time stamps
Thread.sleep(10);
}
// shuffle to change the order for put
List<Long> shuffledTimeStamps = new ArrayList<Long>(timeStamps);
Collections.shuffle(shuffledTimeStamps);
for (Long timeStamp : shuffledTimeStamps) {
Number160 contentKey = new Number160(timeStamp);
logger.debug("{}, {}", timeStamp, contentKey);
p2.put(lKey).setData(contentKey, new Data(timeStamp)).setDomainKey(dKey).start()
.awaitUninterruptibly();
}
// fetch time stamps from network, respectively the implicit queue
List<Long> downloadedTimestamps = new ArrayList<Long>();
while (true) {
FutureGet futureGet = p1.get(lKey)
.from(new Number640(lKey, dKey, Number160.ZERO, Number160.ZERO))
.to(new Number640(lKey, dKey, Number160.MAX_VALUE, Number160.MAX_VALUE)).ascending()
.returnNr(1).start();
futureGet.awaitUninterruptibly();
if (futureGet.getData() != null) {
long timeStamp = (Long) futureGet.getData().object();
Number160 contentKey = new Number160(timeStamp);
logger.debug("{}, {}", timeStamp, contentKey);
downloadedTimestamps.add(timeStamp);
// remove fetched time stamp from network
p2.remove(lKey).setDomainKey(dKey).contentKey(contentKey).start().awaitUninterruptibly();
} else {