Package net.tomp2p.p2p

Examples of net.tomp2p.p2p.Peer.discover()


          masterPeerPort, masterPeerPort);
      logger.info(String.format("Client-Node connecting to master: %s",
          pa));

      // 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"));
View Full Code Here


      futureBootstrap.awaitUninterruptibly();
      logger.info(String.format("Bootstrap of %s %s", pa,
          (futureDiscover.isSuccess()) ? "succeeded" : "failed"));
      if (futureBootstrap.getBootstrapTo() != null) {
        logger.info("Future Bootstrap to ... all known");
        peer.discover()
            .setPeerAddress(
                futureBootstrap.getBootstrapTo().iterator()
                    .next()).start().awaitUninterruptibly();
      }
    } catch (java.net.BindException
View Full Code Here

          cc.maxPermitsTCP(100);
          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);
               
View Full Code Here

        try {
            peer = new PeerBuilder(Number160.createHash(clientId)).ports(clientPort).behindFirewall().start();
            PeerNAT peerNAT = new PeerBuilderNAT(peer).start();
            PeerAddress masterNodeAddress = new PeerAddress(Number160.createHash(seedNodeId), seedNodeIP, seedNodePort,
                                                            seedNodePort);
            FutureDiscover futureDiscover = peer.discover().peerAddress(masterNodeAddress).start();
            FutureNAT futureNAT = peerNAT.startSetupPortforwarding(futureDiscover);
            futureNAT.awaitUninterruptibly();
            if (futureNAT.isSuccess()) {
                log.info("Automatic port forwarding is setup. Now we do a futureDiscover again. Address = " +
                                 futureNAT.peerAddress());
View Full Code Here

            FutureNAT futureNAT = peerNAT.startSetupPortforwarding(futureDiscover);
            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);
View Full Code Here

        try {
            peer = new PeerBuilder(Number160.createHash(clientId)).ports(clientPort).behindFirewall().start();
            PeerNAT peerNAT = new PeerBuilderNAT(peer).start();
            PeerAddress masterNodeAddress = new PeerAddress(Number160.createHash(seedNodeId), seedNodeIP, seedNodePort,
                                                            seedNodePort);
            FutureDiscover futureDiscover = peer.discover().peerAddress(masterNodeAddress).start();
            FutureNAT futureNAT = peerNAT.startSetupPortforwarding(futureDiscover);
            FutureRelayNAT futureRelayNAT = peerNAT.startRelay(futureDiscover, futureNAT);
            futureRelayNAT.awaitUninterruptibly();
            if (futureRelayNAT.isSuccess()) {
                log.info("Bootstrap using relay was successful. Address = " + peer.peerAddress());
View Full Code Here

    PeerAddress pa = new PeerAddress(Number160.ZERO, address, masterPort, masterPort);

    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

        Peer myPeer = new PeerBuilder(Number160.createHash("client peer")).behindFirewall(true).
                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.");
View Full Code Here

    Random r = new Random(43L);
    Peer peer = new PeerBuilder(new Number160(r)).ports(PORT_CLIENT).behindFirewall().start();
    PeerNAT peerNAT = new PeerBuilderNAT(peer).start();
    PeerAddress pa = new PeerAddress(Number160.ZERO, InetAddress.getByName(ip), PORT_SERVER, PORT_SERVER);
   
    FutureDiscover fd = peer.discover().peerAddress(pa).start();
    FutureNAT fn = peerNAT.startSetupPortforwarding(fd);
    FutureRelayNAT frn = peerNAT.startRelay(fd, fn);
   
    frn.awaitUninterruptibly();
    if (fd.isSuccess()) {
View Full Code Here

            Assert.fail();
            return null;
        }
        final FutureBootstrap fb = peer.bootstrap().broadcast().ports(seed.peerAddress().udpPort()).start();
        fb.awaitUninterruptibly();
        peer.discover().peerAddress(fb.bootstrapTo().iterator().next()).start();
        fb.addListener(new BaseFutureListener<BaseFuture>() {
            @Override
            public void operationComplete(BaseFuture future) throws Exception {
                Collection<PeerAddress> addresses = fb.bootstrapTo();
                if (addresses != null && !addresses.isEmpty()) {
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.