Package net.tomp2p.futures

Examples of net.tomp2p.futures.FutureDiscover.awaitUninterruptibly()


      // Future Discover
      FutureDiscover futureDiscover = peer.discover()
          .setInetAddress(masterPeerAddress).setPorts(masterPeerPort)
          .start();
      futureDiscover.awaitUninterruptibly();
      logger.info(String.format("Discover of %s %s", pa,
          (futureDiscover.isSuccess()) ? "succeeded" : "failed"));
      // Future Bootstrap - slave
      FutureBootstrap futureBootstrap = peer.bootstrap()
          .setInetAddress(masterPeerAddress).setPorts(masterPeerPort)
View Full Code Here


    if (!connect()) {
      return false;
    }

    FutureDiscover futureDiscover = peer.discover().inetAddress(bootstrapAddress).ports(port).start();
    futureDiscover.awaitUninterruptibly();

    if (futureDiscover.isSuccess()) {
      logger.debug("Discovery successful: Outside address is '{}'.", futureDiscover.getPeerAddress());
    } else {
      logger.warn("Discovery failed: {}.", futureDiscover.getFailedReason());
View Full Code Here

          cc.maxPermitsUDP(100);
            peer = new PeerBuilder(peerId).channelClientConfiguration(cc).ports(clientPort).peerMap(pm).start();
            PeerAddress masterNodeAddress = new PeerAddress(Number160.createHash(seedNodeId), seedNodeIP, seedNodePort,
                                                            seedNodePort);
            FutureDiscover futureDiscover = peer.discover().peerAddress(masterNodeAddress).start();
            futureDiscover.awaitUninterruptibly();
            if (futureDiscover.isSuccess()) {
                log.info("Discover with direct connection successful. Address = " + futureDiscover.peerAddress());
                //cachedPeers.put(id, peer);
               
                //bootstrap
View Full Code Here

            futureNAT.awaitUninterruptibly();
            if (futureNAT.isSuccess()) {
                log.info("Automatic port forwarding is setup. Now we do a futureDiscover again. Address = " +
                                 futureNAT.peerAddress());
                futureDiscover = peer.discover().peerAddress(masterNodeAddress).start();
                futureDiscover.awaitUninterruptibly();
                if (futureDiscover.isSuccess()) {
                    log.info("Discover with automatic port forwarding was successful. Address = " + futureDiscover
                            .peerAddress());
                    //cachedPeers.put(id, peer);
                    return peer;
View Full Code Here

    System.out.println("PeerAddress: " + pa);
   
    // Future Discover
    FutureDiscover futureDiscover = client.discover().inetAddress(address).ports(masterPort).start();
    futureDiscover.awaitUninterruptibly();

    // Future Bootstrap - slave
    FutureBootstrap futureBootstrap = client.bootstrap().inetAddress(address).ports(masterPort).start();
    futureBootstrap.awaitUninterruptibly();
View Full Code Here

                ports(port).enableMaintenance(false).start();
        PeerAddress bootstrapServerPeerAddress = new PeerAddress(Number160.ZERO, new InetSocketAddress(
                InetAddress.getByName(ipSuperPeer), port));

        FutureDiscover discovery = myPeer.discover().peerAddress(bootstrapServerPeerAddress).start();
        discovery.awaitUninterruptibly();
        if (!discovery.isSuccess()) {
            System.err.println("no success!");
        }
        System.err.println("Peer: " + discovery.reporter() + " told us about our address.");
        InetSocketAddress myInetSocketAddress = new InetSocketAddress(myPeer.peerAddress().inetAddress(), port);
View Full Code Here

        Peer slave = null;
        try {
            master = new PeerBuilder(new Number160(rnd)).ports(4001).start();
            slave = new PeerBuilder(new Number160(rnd)).ports(4002).start();
            FutureDiscover fd = master.discover().peerAddress(slave.peerAddress()).start();
            fd.awaitUninterruptibly();
            System.err.println(fd.failedReason());
            Assert.assertEquals(true, fd.isSuccess());
        } finally {
            if (master != null) {
                master.shutdown().await();
View Full Code Here

    Random r = new Random(43L);
    PeerDHT peer = new PeerBuilderDHT(new PeerBuilder(new Number160(r)).ports(clientPort).behindFirewall().start()).start();
    PeerAddress bootStrapServer = new PeerAddress(Number160.ZERO, InetAddress.getByName(ip), serverPort, serverPort);
    FutureDiscover fd = peer.peer().discover().peerAddress(bootStrapServer).start();
    System.out.println("About to wait...");
    fd.awaitUninterruptibly();
    if (fd.isSuccess()) {
      System.out.println("*** FOUND THAT MY OUTSIDE ADDRESS IS " + fd.peerAddress());
    } else {
      System.out.println("*** FAILED " + fd.failedReason());
    }
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.