Examples of FutureResponse


Examples of net.tomp2p.futures.FutureResponse

            FutureChannelCreator fcc = recv1.connectionBean().reservation().create(0, 3);
            fcc.awaitUninterruptibly();
            cc = fcc.channelCreator();

            for (int i = 0; i < 1000; i++) {
                FutureResponse fr1 = sender.pingRPC().pingTCP(recv1.peerAddress(), cc, new DefaultConnectionConfiguration());
                FutureResponse fr2 = sender.pingRPC().pingTCP(recv1.peerAddress(), cc, new DefaultConnectionConfiguration());
                FutureResponse fr3 = sender.pingRPC().pingTCP(recv1.peerAddress(), cc, new DefaultConnectionConfiguration());
                fr1.awaitUninterruptibly();
                fr2.awaitUninterruptibly();
                fr3.awaitUninterruptibly();
                System.err.println(fr1.failedReason() + " / " + fr2.failedReason() + " / "
                        + fr3.failedReason());
                Assert.assertEquals(true, fr1.isSuccess());
                Assert.assertEquals(true, fr2.isSuccess());
                Assert.assertEquals(true, fr3.isSuccess());
            }
        } catch (Throwable t) {
            t.printStackTrace();
        } finally {
            if (cc != null) {
View Full Code Here

Examples of net.tomp2p.futures.FutureResponse

            FutureChannelCreator fcc = recv1.connectionBean().reservation().create(3, 0);
            fcc.awaitUninterruptibly();
            cc = fcc.channelCreator();

            for (int i = 0; i < 1000; i++) {
                FutureResponse fr1 = sender.pingRPC().pingUDP(recv1.peerAddress(), cc, new DefaultConnectionConfiguration());
                FutureResponse fr2 = sender.pingRPC().pingUDP(recv1.peerAddress(), cc, new DefaultConnectionConfiguration());
                FutureResponse fr3 = sender.pingRPC().pingUDP(recv1.peerAddress(), cc, new DefaultConnectionConfiguration());
                fr1.awaitUninterruptibly();
                fr2.awaitUninterruptibly();
                fr3.awaitUninterruptibly();
                System.err.println(fr1.failedReason() + " / " + fr2.failedReason() + " / "
                        + fr3.failedReason());
                Assert.assertEquals(true, fr1.isSuccess());
                Assert.assertEquals(true, fr2.isSuccess());
                Assert.assertEquals(true, fr3.isSuccess());
            }
        } catch (Throwable t) {
            t.printStackTrace();
        } finally {
            if (cc != null) {
View Full Code Here

Examples of net.tomp2p.futures.FutureResponse

    final Message message = relayRPC
        .createMessage(connection.relayAddress(), RPC.Commands.RELAY.getNr(), Type.REQUEST_3);
    // TODO: neighbor size limit is 256, we might have more here
    message.neighborsSet(new NeighborSet(-1, RelayUtils.flatten(map)));

    final FutureResponse fr = connection.sendToRelay(message);
    fr.addListener(new BaseFutureAdapter<BaseFuture>() {
      public void operationComplete(BaseFuture future) throws Exception {
        if (future.isFailed()) {
          LOG.warn("Failed to update routing table on relay peer {}. Reason: {}", connection.relayAddress(),
              future.failedReason());
          connection.onMapUpdateFailed();
View Full Code Here

Examples of net.tomp2p.futures.FutureResponse

          if (future.isSuccess() && future.peerConnection() != null) {
            // successfully created a connection from unreachable to the requester
            final PeerConnection peerConnection = future.peerConnection();
           
            final Message readyMessage = createReadyForRequestMessage(message, peerConnection.remotePeer());
            FutureResponse futureResponse = RelayUtils.send(peerConnection, peer.peerBean(),
                peer.connectionBean(), config, readyMessage);
            futureResponse.addListener(new BaseFutureAdapter<FutureResponse>() {
              @Override
              public void operationComplete(final FutureResponse future) throws Exception {
                // ready message is sent to reachable peer
                if (future.isSuccess()) {
                  // store the connection if necessary
View Full Code Here

Examples of net.tomp2p.futures.FutureResponse

      LOG.debug("This reverse connection is used permanently. Store it!");
      storePeerConnection(message, peerConnection);
      responder.response(createResponseMessage(message, Type.OK).keepAlive(true));
    } else {
      ConcurrentHashMap<Integer, FutureResponse> cachedRequests = peer.connectionBean().sender().cachedRequests();
      final FutureResponse cachedRequest = cachedRequests.remove(message.intAt(0));
      final Message cachedMessage = cachedRequest.request();
      LOG.debug("This reverse connection is only used for sending a direct message {}", cachedMessage);

      // send the message to the unreachable peer through the open channel
      FutureResponse futureResponse = RelayUtils.send(peerConnection, peer.peerBean(), peer.connectionBean(), config,
          cachedMessage);
      futureResponse.addListener(new BaseFutureAdapter<FutureResponse>() {
        @Override
        public void operationComplete(final FutureResponse future) throws Exception {
          if (future.isSuccess()) {
            LOG.debug("Successfully transmitted request message {} to unreachablePeer {}", cachedMessage,
                peerConnection.remotePeer());
View Full Code Here

Examples of net.tomp2p.futures.FutureResponse

               
                FutureChannelCreator fcc = peer.connectionBean().reservation().create(1, 1);
                fcc.awaitUninterruptibly();
                ChannelCreator cc = fcc.channelCreator();
               
                FutureResponse fr1 = peer.pingRPC().pingTCP(pa, cc, new DefaultConnectionConfiguration());
                fr1.awaitUninterruptibly();

                if (fr1.isSuccess()) {
                    System.out.println("peer online TCP:" + pa);
                } else {
                    System.out.println("offline " + pa);
                }
                FutureResponse fr2 = peer.pingRPC().pingUDP(pa, cc, new DefaultConnectionConfiguration());
                fr2.awaitUninterruptibly();
                cc.shutdown().awaitUninterruptibly();
                if (fr2.isSuccess()) {
                    System.out.println("peer online UDP:" + pa);
                } else {
                    System.out.println("offline " + pa);
                }
            }
View Full Code Here

Examples of net.tomp2p.futures.FutureResponse

        FutureChannelCreator fcc = master.connectionBean().reservation().create(1, 1);
        fcc.awaitUninterruptibly();

        ChannelCreator cc = fcc.channelCreator();

        FutureResponse fr1 = master.pingRPC().pingTCP(pa, cc, new DefaultConnectionConfiguration());
        fr1.awaitUninterruptibly();

        if (fr1.isSuccess()) {
          System.out.println("peer online T:" + pa);
        } else {
          System.out.println("offline " + pa);
        }

        FutureResponse fr2 = master.pingRPC().pingUDP(pa, cc, new DefaultConnectionConfiguration());
        fr2.awaitUninterruptibly();

        cc.shutdown();

        if (fr2.isSuccess()) {
          System.out.println("peer online U:" + pa);
        } else {
          System.out.println("offline " + pa);
        }
      }
View Full Code Here

Examples of net.tomp2p.futures.FutureResponse

            FutureChannelCreator fcc = recv1.connectionBean().reservation().create(0, 1);
            fcc.awaitUninterruptibly();
            cc = fcc.channelCreator();

            FutureResponse fr = sender.pingRPC().pingTCP(recv1.peerAddress(), cc,
                    new DefaultConnectionConfiguration());
            fr.awaitUninterruptibly();
            Assert.assertEquals(true, fr.isSuccess());
        } finally {
            if (cc != null) {
                cc.shutdown().await();
            }
            if (sender != null) {
View Full Code Here

Examples of net.tomp2p.futures.FutureResponse

            FutureChannelCreator fcc = recv1.connectionBean().reservation().create(0, 1);
            fcc.awaitUninterruptibly();
            cc = fcc.channelCreator();

            FutureResponse fr = sender.pingRPC().pingTCP(recv1.peerAddress(), cc,
                    new DefaultConnectionConfiguration());
            fr.awaitUninterruptibly();
            FutureResponse fr2 = recv1.pingRPC().pingTCP(sender.peerAddress(), cc,
                    new DefaultConnectionConfiguration());
            fr2.awaitUninterruptibly();
            Assert.assertEquals(true, fr2.isSuccess());
            Assert.assertEquals(true, fr.isSuccess());
        } finally {
            if (cc != null) {
                cc.shutdown().await();
            }
View Full Code Here

Examples of net.tomp2p.futures.FutureResponse

            FutureChannelCreator fcc = recv1.connectionBean().reservation().create(0, 1);
            fcc.awaitUninterruptibly();
            cc = fcc.channelCreator();
            final ChannelCreator cc1 = cc;

            FutureResponse fr = sender.pingRPC().pingTCP(recv1.peerAddress(), cc,
                    new DefaultConnectionConfiguration());
            fr.awaitUninterruptibly();

            fr.addListener(new BaseFutureAdapter<FutureResponse>() {
                @Override
                public void operationComplete(final FutureResponse future) throws Exception {
                    FutureResponse fr2 = sender.pingRPC().pingTCP(recv1.peerAddress(), cc1,
                            new DefaultConnectionConfiguration());
                    try {
                        fr2.await();
                    } catch (IllegalStateException ise) {
                        Assert.fail();
                    }
                }
            });
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.