Package net.tomp2p.futures

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


      // Test setting up relay peers
      unreachablePeer = new PeerBuilder(Number160.createHash(rnd.nextInt())).ports(5000).start();

      // find neighbors
      FutureBootstrap futureBootstrap = unreachablePeer.bootstrap().peerAddress(peers[0].peerAddress()).start();
      futureBootstrap.awaitUninterruptibly();
      Assert.assertTrue(futureBootstrap.isSuccess());

      // setup relay
      PeerNAT uNat = new PeerBuilderNAT(unreachablePeer).relayType(relayType).gcmServerCredentials(gcmServerCredentials).start();
      FutureRelayNAT startRelay = uNat.startRelay(peers[0].peerAddress()).awaitUninterruptibly();
View Full Code Here


      upa = upa.changeFirewalledTCP(true).changeFirewalledUDP(true);
      unreachablePeer.peerBean().serverPeerAddress(upa);

      // find neighbors
      FutureBootstrap futureBootstrap = unreachablePeer.bootstrap().peerAddress(peers[0].peerAddress()).start();
      futureBootstrap.awaitUninterruptibly();
      Assert.assertTrue(futureBootstrap.isSuccess());

      // setup relay
      PeerNAT uNat = new PeerBuilderNAT(unreachablePeer).relayType(relayType).gcmServerCredentials(gcmServerCredentials).peerMapUpdateInterval(5).start();
      FutureRelayNAT startRelay = uNat.startRelay(peers[0].peerAddress()).awaitUninterruptibly();
View Full Code Here

      Assert.assertTrue(startRelay.isSuccess());
      mockGCM(peers, uNat);

      // find neighbors again
      futureBootstrap = unreachablePeer.bootstrap().peerAddress(peers[0].peerAddress()).start();
      futureBootstrap.awaitUninterruptibly();
      Assert.assertTrue(futureBootstrap.isSuccess());

      boolean otherPeersHaveRelay = false;

      for (Peer peer : peers) {
View Full Code Here

      upa = upa.changeFirewalledTCP(true).changeFirewalledUDP(true);
      unreachablePeer.peerBean().serverPeerAddress(upa);

      // find neighbors
      FutureBootstrap futureBootstrap = unreachablePeer.bootstrap().peerAddress(peers[0].peerAddress()).start();
      futureBootstrap.awaitUninterruptibly();
      Assert.assertTrue(futureBootstrap.isSuccess());

      // setup relay and lower the update interval to 5s
      PeerNAT uNat = new PeerBuilderNAT(unreachablePeer).relayType(relayType).gcmServerCredentials(gcmServerCredentials).peerMapUpdateInterval(5).start();
      FutureRelayNAT startRelay = uNat.startRelay(peers[0].peerAddress());
View Full Code Here

        System.err.println("Peer: " + discovery.reporter() + " told us about our address.");
        InetSocketAddress myInetSocketAddress = new InetSocketAddress(myPeer.peerAddress().inetAddress(), port);

        bootstrapServerPeerAddress = discovery.reporter();
        FutureBootstrap bootstrap = myPeer.bootstrap().peerAddress(bootstrapServerPeerAddress).start();
        bootstrap.awaitUninterruptibly();

        if (!bootstrap.isSuccess()) {
            System.err.println("no success!");
        }
       
View Full Code Here

  final private PeerDHT peer;

  public ExampleDNS(int nodeId) throws Exception {
    peer = new PeerBuilderDHT(new PeerBuilder(Number160.createHash(nodeId)).ports(4000 + nodeId).start()).start();
    FutureBootstrap fb = this.peer.peer().bootstrap().broadcast(true).ports(4001).start();
    fb.awaitUninterruptibly();
    if(fb.isSuccess()) {
      peer.peer().discover().peerAddress(fb.bootstrapTo().iterator().next()).start().awaitUninterruptibly();
    }
  }
View Full Code Here

        try {
            master = new PeerBuilder(new Number160(rnd)).ports(4001).start();
            slave = new PeerBuilder(new Number160(rnd)).ports(4002).start();
            FutureBootstrap fb = master.bootstrap().inetAddress(InetAddress.getByName("127.0.0.1"))
                    .ports(3000).start();
            fb.awaitUninterruptibly();
            Assert.assertEquals(false, fb.isSuccess());
            System.err.println(fb.failedReason());
            fb = master.bootstrap().peerAddress(slave.peerAddress()).start();
            fb.awaitUninterruptibly();
            Assert.assertEquals(true, fb.isSuccess());
View Full Code Here

                    .ports(3000).start();
            fb.awaitUninterruptibly();
            Assert.assertEquals(false, fb.isSuccess());
            System.err.println(fb.failedReason());
            fb = master.bootstrap().peerAddress(slave.peerAddress()).start();
            fb.awaitUninterruptibly();
            Assert.assertEquals(true, fb.isSuccess());

        } finally {
            if (master != null) {
                master.shutdown().await();
View Full Code Here

        Peer peer = null;
        try {
            peer = new PeerBuilder(new Number160(rnd)).ports(4000).start();
            PeerAddress pa = new PeerAddress(new Number160(rnd), "192.168.77.77", 4000, 4000);
            FutureBootstrap tmp = peer.bootstrap().peerAddress(pa).start();
            tmp.awaitUninterruptibly();
            Assert.assertEquals(false, tmp.isSuccess());
        } finally {
            if (peer != null) {
                peer.shutdown().await();
            }
View Full Code Here

        final Random rnd = new Random(42);
        Peer peer = null;
        try {
            peer = new PeerBuilder(new Number160(rnd)).ports(4000).start();
            FutureBootstrap tmp = peer.bootstrap().peerAddress(peer.peerAddress()).start();
            tmp.awaitUninterruptibly();
            Assert.assertEquals(true, tmp.isSuccess());
        } finally {
            if (peer != null) {
                peer.shutdown().await();
            }
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.