Package net.tomp2p.dht

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


        System.out.println( "stored: " + futurePut.isSuccess()
            + " -> because no one can claim domains except the owner, storage ok but no protection" );
        // peer 2 claims this domain
        futurePut =
            peer2.put( Number160.ONE ).data( new Data( "MINE!" ) ).protectDomain().domainKey( peer2Owner ).start();
        futurePut.awaitUninterruptibly();
        System.out.println( "stored: " + futurePut.isSuccess() + " -> becaues peer2 is the owner" );
        // get the data!
        FutureGet futureGet = peer1.get( Number160.ONE ).domainKey( peer2Owner ).start();
        futureGet.awaitUninterruptibly();
        System.out.println( "we got " + futureGet.data().object() );
View Full Code Here


        // get the data!
        FutureGet futureGet = peer1.get( Number160.ONE ).domainKey( peer2Owner ).start();
        futureGet.awaitUninterruptibly();
        System.out.println( "we got " + futureGet.data().object() );
        futurePut = peer3.put( Number160.ONE ).domainKey( peer2Owner ).data( new Data( "hello" ) ).start();
        futurePut.awaitUninterruptibly();
        System.out.println( "stored: " + futurePut.isSuccess() + " -> because this domain is claimed by peer2" );
        shutdown( peers );
    }

    private static void shutdown( PeerDHT[] peers )
View Full Code Here

        sortedMap.put(vKey, data);

        // put test data (prepare)
        FuturePut fput = peers[rnd.nextInt(10)].put(locationKey)
            .data(contentKey, sortedMap.get(vKey)).domainKey(domainKey).versionKey(vKey).start();
        fput.awaitUninterruptibly();
        fput.futureRequests().awaitUninterruptibly();
        fput.futureRequests().awaitListenersUninterruptibly();
        Assert.assertEquals(true, fput.isSuccess());

        // confirm put
View Full Code Here

        Assert.assertEquals(true, fput.isSuccess());

        // confirm put
        FuturePut futurePutConfirm = peers[rnd.nextInt(10)].put(locationKey).domainKey(domainKey)
            .data(contentKey, new Data()).versionKey(vKey).putConfirm().start();
        futurePutConfirm.awaitUninterruptibly();
        futurePutConfirm.awaitListenersUninterruptibly();

        // get latest version with digest
        FutureGet fget = peers[rnd.nextInt(10)].get(locationKey).domainKey(domainKey)
            .contentKey(contentKey).getLatest().withDigest().start();
View Full Code Here

    UtilsReplication.perfectRouting(peers);
   
    RoutingConfiguration r = new RoutingConfiguration(6, 10, 2);
    RequestP2PConfiguration p = new RequestP2PConfiguration(6, 10, 0);
    FuturePut fp = peers[5].put(Number160.MAX_VALUE).routingConfiguration(r).requestP2PConfiguration(p).data(new Data("test")).start();
    fp.awaitUninterruptibly();
    //now it is stored on 6 peers: 0, 1 , 2, 4, 5, 8
    for(PeerDHT p1:peers) {
      System.err.println(p1.peer().peerAddress()+":"+p1.storageLayer().get());
    }
    checkIfPresent(peers, 0, 1 , 2, 4, 5, 8);
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.