Package net.tomp2p.futures

Examples of net.tomp2p.futures.FutureResponse.addListener()


                public void operationComplete(final FutureChannelCreator futureChannelCreator) throws Exception {
                    if (futureChannelCreator.isSuccess()) {
                        FutureResponse futureResponse = getTaskRPC().sendResult(senderAddress,
                                futureChannelCreator.getChannelCreator(), taskId, outputData2,
                                peer.getPeerBean().getKeyPair(), false, sign);
                        futureResponse.addListener(new BaseFutureAdapter<FutureResponse>() {
                            @Override
                            public void operationComplete(FutureResponse future) throws Exception {
                                if (future.isSuccess()) {
                                    synchronized (lock) {
                                        status.put(taskKey, Status.SUCCESS_RESULT_SENT);
View Full Code Here


            }
        });
        tasks.put(taskKey, futureAsyncTask);
        FutureResponse futureResponse = taskRPC.sendTask(remotePeer, channelCreator, taskId, dataMap, mapper,
                peerBean.getKeyPair(), forceUDP, sign);
        futureResponse.addListener(new BaseFutureAdapter<FutureResponse>() {
            @Override
            public void operationComplete(FutureResponse future) throws Exception {
                if (future.isSuccess()) {
                    // keep track of it and poll to see if its still alive
                    scheduler.keepTrack(remotePeer, taskId, (TaskResultListener) AsyncTask.this);
View Full Code Here

        .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

            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

      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

            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 {
View Full Code Here

          final PeerConnection peerConnection = futurePeerConnection.object();

          // send the message
          FutureResponse response = RelayUtils.send(peerConnection, peer.peerBean(), peer.connectionBean(),
              config, message);
          response.addListener(new BaseFutureAdapter<FutureResponse>() {
            public void operationComplete(FutureResponse future) throws Exception {
              if (future.isSuccess()) {
                // finialize the relay setup
                setupAddRelays(candidate, peerConnection, gcmServerCredentials);
                futureDone.done(peerConnection);
View Full Code Here

    // holds the message that will be returned to he requester
    final FutureDone<Message> futureDone = new FutureDone<Message>();

    // Forward a message through the open peer connection to the unreachable peer.
    FutureResponse fr = RelayUtils.send(peerConnection, peerBean(), connectionBean(), config, envelope);
    fr.addListener(new BaseFutureAdapter<FutureResponse>() {
      public void operationComplete(FutureResponse future) throws Exception {
        if (future.isSuccess()) {
          InetSocketAddress senderSocket = message.recipientSocket();
          if (senderSocket == null) {
            senderSocket = unreachablePeerAddress().createSocketTCP();
View Full Code Here

        return;
      }
     
      LOG.debug("Sending late response {} in an envelope {}", responseMessage, envelope);
      FutureResponse futureResponse = RelayUtils.connectAndSend(peer, envelope, connectionConfig);
      futureResponse.addListener(new BaseFutureAdapter<FutureResponse>() {
        @Override
        public void operationComplete(FutureResponse future) throws Exception {
          if(future.isSuccess()) {
            LOG.debug("Successfully sent late response to requester");
          } else {
View Full Code Here

      public void operationComplete(FutureChannelCreator future) throws Exception {
        if (future.isSuccess()) {
          final ChannelCreator channelCreator = future.channelCreator();
          FutureResponse futureResponse = peerExchangeRPC.peerExchange(remotePeer, key, channelCreator, data,
                  connectionConfiguration);
          futureResponse.addListener(new BaseFutureAdapter<FutureResponse>() {
            @Override
            public void operationComplete(FutureResponse future) throws Exception {
              if (future.isSuccess()) {
                futureDone.done();
              } else {
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.