Package net.tomp2p.dht

Examples of net.tomp2p.dht.FutureGet.awaitUninterruptibly()


         * @throws ClassNotFoundException .
         */
        public void list(final String nickName) throws IOException, ClassNotFoundException {
            Number160 key = Number160.createHash(nickName);
            FutureGet futureGet = peer.get(key).all().start();
            futureGet.awaitUninterruptibly();
            for (Map.Entry<Number640, Data> entry : futureGet.dataMap().entrySet()) {
                System.out.println("this peers' (" + nickName + ") friend:" + entry.getValue().object());
            }
            System.out.println("DHT reports that " + futureGet.dataMap().size() + " peer(s) are his friends");
        }
View Full Code Here


      ExampleUtils.bootstrap(peers);
      myPeer1.put("This is my location key", "This is my domain", "This is my content key",
              "And here comes the data").awaitUninterruptibly();
      MyPeer myPeer2 = new MyPeer(peers[5]);
      FutureGet futureGet = myPeer2.get("This is my location key", "This is my domain", "This is my content key");
      futureGet.awaitUninterruptibly();
      Map<Number640, Data> map = futureGet.dataMap();
      for (Data data : map.values()) {
        @SuppressWarnings("unchecked")
                MyData<String> myData = (MyData<String>) data.object();
        System.out.println("key: " + myData.key() + ", domain: " + myData.domain() + ", content: "
View Full Code Here

            Number160 key = Number160.createHash(inter2.toString());
            already.add(inter2.toString());
            // get the interval
            System.out.println("get for " + inter2);
            FutureGet futureGet = peer.get(key).all().start();
            futureGet.awaitUninterruptibly();
            dhtCounter.incrementAndGet();
            for (Map.Entry<Number640, Data> entry : futureGet.dataMap().entrySet()) {
                // with each result we get a flag if we should query the children (this should be returned in the
                // future, e.g., partially_ok)
                StringBoolean stringBoolean = (StringBoolean) entry.getValue().object();
View Full Code Here

                }
                peer.put(locationKey).dataMapContent(dataMap).start().awaitUninterruptibly();
            }
        } else if (query.getQueryType() == QueryType.SELECT) {
            FutureGet futureDHT = peer.get(locationKey).all().start();
            futureDHT.awaitUninterruptibly();
            for (Map.Entry<Number640, Data> entry : futureDHT.dataMap().entrySet()) {
                System.out.print("key: " + entry.getKey());
                System.out.println(", value: " + entry.getValue().object());
            }
        }
View Full Code Here

        System.out.println("We got bloomfilter for the first key: " + contentBF);
        //TODO: check keyBF.contains(new Number160(123));
        // query for nr2, but return only those that are in this bloom filter
        FutureGet futureGet1 = peers[peer10].get(nr2).all().keyBloomFilter(contentBF)
                .domainKey(Number160.createHash("my_domain")).start();
        futureGet1.awaitUninterruptibly();
        System.out.println("For the 2nd key we requested with this Bloom filer and we got "
                + futureGet1.dataMap().size() + " items.");
       
        FutureGet futureGet2 = peers[peer10].get(nr2).all().bloomFilterIntersect().keyBloomFilter(contentBF)
                .domainKey(Number160.createHash("my_domain")).start();
View Full Code Here

        System.out.println("For the 2nd key we requested with this Bloom filer and we got "
                + futureGet1.dataMap().size() + " items.");
       
        FutureGet futureGet2 = peers[peer10].get(nr2).all().bloomFilterIntersect().keyBloomFilter(contentBF)
                .domainKey(Number160.createHash("my_domain")).start();
        futureGet2.awaitUninterruptibly();
        System.out.println("For the 2nd key we requested with this Bloom filer and we got "
                + futureGet2.dataMap().size() + " items.");
    }
}
View Full Code Here

      Assert.assertTrue(unreachablePeer.storageLayer().contains(
          new Number640(unreachablePeer.peerID(), Number160.ZERO, Number160.ZERO, Number160.ZERO)));

      FutureGet futureGet = peers[8].get(unreachablePeer.peerID()).routingConfiguration(r).requestP2PConfiguration(rp)
          .start();
      futureGet.awaitUninterruptibly();
      Assert.assertTrue(futureGet.isSuccess());

      // we cannot see the peer in futurePut.rawResult, as the relayed is the slowest and we finish
      // earlier than that.
View Full Code Here

    }
  }

  private String get(String name) throws ClassNotFoundException, IOException {
    FutureGet futureGet = peer.get(Number160.createHash(name)).start();
    futureGet.awaitUninterruptibly();
    if (futureGet.isSuccess()) {
      return futureGet.dataMap().values().iterator().next().object().toString();
    }
    return "not found";
  }
View Full Code Here

                .data(new Data("Test 2")).start();
        futurePut.awaitUninterruptibly();
        System.out.println("stored [Test 2] on " + futurePut.rawResult().keySet());

        FutureGet futureGet = peers[peerGet].get(key1).all().start();
        futureGet.awaitUninterruptibly();
        System.out.println("peer[" + peerGet + "] got [" + futureGet.data().object() + "] should be [Test 2]");
        // peer 11 and 8 joins again
        peers[peerOffline1] = new PeerBuilderDHT(new PeerBuilder(peers[peerOffline1].peerID()).masterPeer(peers[0].peer()).start()).start();
        peers[peerOffline2] = new PeerBuilderDHT(new PeerBuilder(peers[peerOffline2].peerID()).masterPeer(peers[0].peer()).start()).start();
        peers[peerOffline3] = new PeerBuilderDHT(new PeerBuilder(peers[peerOffline3].peerID()).masterPeer(peers[0].peer()).start()).start();
View Full Code Here

                .put(key, new Data("Test 1"), null, false, false);
        peers[peerOffline3].storageLayer()
                .put(key, new Data("Test 1"), null, false, false);
        // we got Test 1
        FutureGet futureGet2 = peers[0].get(key1).requestP2PConfiguration(REQUEST_3).all().start();
        futureGet2.awaitUninterruptibly();
        System.out.println("peer[0] got [" + futureGet2.data().object() + "] should be [Test 2]");
        // we got Test 1!
        FutureGet futureGet3 = peers[peerGet].get(key1).requestP2PConfiguration(REQUEST_3).all().start();
        futureGet3.awaitUninterruptibly();
        System.out.println("peer[" + peerGet + "] got [" + futureGet3.data().object() + "] should be [Test 2]");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.