Package net.tomp2p.dht

Examples of net.tomp2p.dht.FutureGet


         * @throws IOException .
         * @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


      MyPeer myPeer1 = new MyPeer(peers[0]);
      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: "
                + myData.content() + ", data: " + myData.data());
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();
                result.add(stringBoolean.string);
                if (!stringBoolean.bool && inter2.size() > bagSize) {
View Full Code Here

                    dataMap.put(Number160.createHash(entry.getKey()), new Data(entry.getValue()));
                }
                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

        SimpleBloomFilter<Number160> contentBF = futureDigest.digest().contentBloomFilter();
               
        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();
        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(futurePut.isSuccess());
      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.

      System.err.println("DONE!");
View Full Code Here

      Assert.assertTrue(futurePut.isSuccess());
      Assert.assertTrue(unreachablePeer2.storageLayer().contains(
          new Number640(unreachablePeer2.peerID(), Number160.ZERO, Number160.ZERO, Number160.ZERO)));

      FutureGet futureGet = unreachablePeer1.get(unreachablePeer2.peerID()).routingConfiguration(r)
          .requestP2PConfiguration(rp).fastGet(false).start().awaitUninterruptibly();
      // TODO: try peers even if no data found with fastget
      System.err.println(futureGet.failedReason());
      Assert.assertTrue(futureGet.isSuccess());

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

      System.err.println("DONE!");
View Full Code Here

             System.err.println(futurePut.failedReason());
            
             Assert.assertTrue(futurePut.isSuccess());
             Assert.assertTrue(unreachablePeer2.storageLayer().contains(new Number640(unreachablePeer2.peerID(), Number160.ZERO, Number160.ZERO, Number160.ZERO)));
            
             FutureGet futureGet = unreachablePeer1.get(unreachablePeer2.peerID()).routingConfiguration(r).sign().requestP2PConfiguration(rp).fastGet(false).start().awaitUninterruptibly();
             //TODO: try peers even if no data found with fastget
             System.err.println(futureGet.failedReason());
             Assert.assertTrue(futureGet.isSuccess());
            
             //we cannot see the peer in futurePut.rawResult, as the relayed is the slowest and we finish earlier than that.
            
             System.err.println("DONE!");
            
View Full Code Here

      System.out.println("Name:" + args[1] + " IP:" + dns.get(args[1]));
    }
  }

  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

    LOG.debug("Got {} bytes", byteArray.length);
  }

  public Data get(Number640 key) {
    getStats.start();
    FutureGet futureGet = peerDHT.get(key.locationKey()).contentKey(key.contentKey()).domainKey(key.domainKey())
        .versionKey(key.versionKey()).routingConfiguration(routingConfig).requestP2PConfiguration(requestConfig)
        .start().awaitUninterruptibly();
    getStats.finished(futureGet.isSuccess());
    LOG.debug("Get is success {}. Reason: {}", futureGet.isSuccess(), futureGet.failedReason());

    if (futureGet.data() != null) {
      return futureGet.data();
    } else {
      return null;
    }
  }
View Full Code Here

TOP

Related Classes of net.tomp2p.dht.FutureGet

Copyright © 2018 www.massapicom. 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.