Package net.tomp2p.dht

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


        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]");
    }

    /**
     * This example shows how to attack an DHT.
View Full Code Here


        //wait for mainenance pings
        Thread.sleep(3000);
       
        // we got attack!
        FutureGet futureGet = peers[0].get(key1).all().requestP2PConfiguration(REQUEST_3).start();
        futureGet.awaitUninterruptibly();
        System.out.println("peer[0] got " + futureGet.data().object());
        for (Entry<PeerAddress, Map<Number640, Data>> entry : futureGet.rawData().entrySet()) {
            System.out.print("got from (3)" + entry.getKey());
            System.out.println(entry.getValue());
        }
View Full Code Here

            System.out.print("got from (3)" + entry.getKey());
            System.out.println(entry.getValue());
        }
        // increase the replicas we fetch
        FutureGet futureGet1 = peers[0].get(key1).all().requestP2PConfiguration(REQUEST_6).start();
        futureGet1.awaitUninterruptibly();
        System.out.println("peer[0] got " + futureGet1.data().object());

        // countermeasure - statistics, pick not closest, but random peer that has the data - freshness vs. load
        // also, check distances!
        Statistics statistics = new Statistics(peers[0].peerBean().peerMap());
View Full Code Here

            throws IOException, ClassNotFoundException {
        FuturePut futurePut = peers[PEER_NR_1].put(nr).data(new Data("hallo")).start();
        futurePut.awaitUninterruptibly();
        System.out.println("peer " + PEER_NR_1 + " stored [key: " + nr + ", value: \"hallo\"]");
        FutureGet futureGet = peers[PEER_NR_2].get(nr).start();
        futureGet.awaitUninterruptibly();
        System.out.println("peer " + PEER_NR_2 + " got: \"" + futureGet.data().object() + "\" for the key " + nr);
        // the output should look like this:
        // peer 30 stored [key: 0xba419d350dfe8af7aee7bbe10c45c0284f083ce4, value: "hallo"]
        // peer 77 got: "hallo" for the key 0xba419d350dfe8af7aee7bbe10c45c0284f083ce4
    }
View Full Code Here

            peers[30].put( nr ).data( new Number160( 11 ), new Data( "hallo" ) ).domainKey( Number160.createHash( "my_domain" ) ).start();
        futurePut.awaitUninterruptibly();
        System.out.println( "peer 30 stored [key: " + nr + ", value: \"hallo\"]" );
        // this will fail, since we did not specify the domain
        FutureGet futureGet = peers[77].get( nr ).all().start();
        futureGet.awaitUninterruptibly();
        System.out.println( "peer 77 got: \"" + futureGet.data() + "\" for the key " + nr );
        // this will succeed, since we specify the domain
        futureGet =
            peers[77].get( nr ).all().domainKey( Number160.createHash( "my_domain" ) ).start().awaitUninterruptibly();
        System.out.println( "peer 77 got: \"" + futureGet.data().object() + "\" for the key " + nr );
View Full Code Here

        System.out.println( "added: " + toStore1 + " (" + futurePut.isSuccess() + ")" );
        futurePut = peers[50].add( nr ).data( data2 ).start();
        futurePut.awaitUninterruptibly();
        System.out.println( "added: " + toStore2 + " (" + futurePut.isSuccess() + ")" );
        FutureGet futureGet = peers[77].get( nr ).all().start();
        futureGet.awaitUninterruptibly();
        System.out.println( "size" + futureGet.dataMap().size() );
        Iterator<Data> iterator = futureGet.dataMap().values().iterator();
        System.out.println( "got: " + iterator.next().object() + " (" + futureGet.isSuccess() + ")" );
        System.out.println( "got: " + iterator.next().object() + " (" + futureGet.isSuccess() + ")" );
    }
View Full Code Here

     */
    private static void exampleGetBlocking(final PeerDHT[] peers, final Number160 nr)
        throws ClassNotFoundException, IOException {
        FutureGet futureGet = peers[PEER_NR_2].get(nr).start();
        // blocking operation
        futureGet.awaitUninterruptibly();
        System.out.println("result blocking: " + futureGet.data().object());
        System.out.println("this may *not* happen before printing the result");
    }

    /**
 
View Full Code Here

        FuturePut futurePut = peers[peer60].put(key).object(TERM).start();
        futurePut.awaitUninterruptibly();

        FutureGet futureGet = peers[peer30].get(key).start();
        futureGet.awaitUninterruptibly();

        System.out.println("got: " + key + " = " + futureGet.data().object());

    }
View Full Code Here

        // search for a keyword
        Number160 termKey = findReference(peers[peer20], "Communication");
        // this will return a reference to the term stored in the method exampleSearch(), next, we have to search for
        // that.
        FutureGet futureGet = peers[peer10].get(termKey).start();
        futureGet.awaitUninterruptibly();
        System.out.println("searched for [Communication], found " + futureGet.data().object());
    }

    /**
     * Finds a reference and returns it.
View Full Code Here

     */
    private static Number160 findReference(final PeerDHT peer, final String keyword) throws ClassNotFoundException,
            IOException {
        Number160 keyKeyword = Number160.createHash(keyword);
        FutureGet futureGet = peer.get(keyKeyword).start();
        futureGet.awaitUninterruptibly();
        Number160 termKey = (Number160) futureGet.data().object();
        return termKey;
    }

}
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.