Package net.tomp2p.dht

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


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

    /**
     * Example of a non-blocking operation and what happens after.
View Full Code Here


        futurePut.awaitUninterruptibly();

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

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

    }

    /**
     * Search for a keyword and find a term.
View Full Code Here

        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

        FutureGet fg;
        while (iterator.hasNext()) {
          Data d = iterator.next();
          fg = peer.get(new Number160(((Integer) d.object()).intValue())).start();
          fg.awaitUninterruptibly();
          if (fg.data() != null) {
            allString.append(fg.data().object().toString()).append("\n");
          } else {
            System.err.println("Could not find key for val: " + d.object());
          }
        }
View Full Code Here

        while (iterator.hasNext()) {
          Data d = iterator.next();
          fg = peer.get(new Number160(((Integer) d.object()).intValue())).start();
          fg.awaitUninterruptibly();
          if (fg.data() != null) {
            allString.append(fg.data().object().toString()).append("\n");
          } else {
            System.err.println("Could not find key for val: " + d.object());
          }
        }
        System.out.println("got: " + allString.toString());
View Full Code Here

        // get entry
        final int peerGet = 22;
        FutureGet futureGet = peers[peerGet].get(locationKey).contentKey(contentKey).start();
        futureGet.awaitUninterruptibly();
        System.out
                .println("single fetch for (" + rowKey1 + "," + col1 + "): [" + futureGet.data().object() + "]");
        // get list
       
        Number640 from = new Number640(locationKey, Number160.ZERO, createNr(rowKey1, 0), Number160.ZERO);
        Number640 to = new Number640(locationKey, Number160.ZERO, createNr(rowKey1, -1), Number160.MAX_VALUE);
       
View Full Code Here

        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() );
        shutdown( peers );
    }

    public static void exampleNoneMaster()
        throws NoSuchAlgorithmException, IOException, ClassNotFoundException
View Full Code Here

        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() );
        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 );
    }
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.