Examples of addListener()


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

                LOG.debug("maintenance ping from {} to {}", peer.peerAddress(), peerStatatistic.peerAddress());
               
                peer.notifyAutomaticFutures(future);
                runningFutures.put(future, peerStatatistic.peerAddress());
                COUNTER.incrementAndGet();
                future.addListener(new BaseFutureAdapter<BaseFuture>() {
                    @Override
                    public void operationComplete(BaseFuture future) throws Exception {
                      synchronized (lock) {
                            runningFutures.remove(future);
                            COUNTER.decrementAndGet();
View Full Code Here

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

            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()) {
                    peer.discover().peerAddress(addresses.iterator().next()).start().awaitUninterruptibly();
View Full Code Here

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

      c.pipelineFilter(new MyPipeLine());
      Reservation r = new Reservation(workerGroup, c);
      List<FutureChannelCreator> fcc = new ArrayList<FutureChannelCreator>();
      for (int j = 0; j < inner; j++) {
        FutureChannelCreator fc = r.create(0, conn);
        fc.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
          @Override
          public void operationComplete(final FutureChannelCreator future) throws Exception {
            final ChannelCreator cc = future.channelCreator();
            final int timeout = 2000;
            final CountDownLatch countDownLatch = new CountDownLatch(conn);
View Full Code Here

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

  }

  public NavigableMap<Number640, Number160> getDigest(IParameters parameters) {
    FutureDigest futureDigest = getDigestUnblocked(parameters);
    FutureDigestListener listener = new FutureDigestListener(parameters);
    futureDigest.addListener(listener);
    return listener.awaitAndGet();
  }

  public FutureDigest getDigestUnblocked(IParameters parameters) {
    logger.debug("Get digest. {}", parameters.toString());
View Full Code Here

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

    // send message directly to the peer with the given peer address
    FutureDirect futureDirect = networkManager.getConnection().getPeer()
        .sendDirect(message.getTargetAddress()).setObject(encryptedMessage).start();
    // attach a future listener to log, handle and notify events
    FutureDirectListener listener = new FutureDirectListener(message, targetPublicKey, this);
    futureDirect.addListener(listener);
    boolean success = listener.await();

    if (success) {
      logger.debug("Message (direct) sent. Message ID = '{}', Target address = '{}', Sender address = '{}'.",
          message.getMessageID(), message.getTargetAddress(), message.getSenderAddress());
View Full Code Here

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

  @Override
  public NetworkContent get(IParameters parameters) {
    FutureGet futureGet = getUnblocked(parameters);
    FutureGetListener listener = new FutureGetListener(parameters);
    futureGet.addListener(listener);
    return listener.awaitAndGet();
  }

  public NetworkContent getVersion(IParameters parameters) {
    FutureGet futureGet = getUnblocked(parameters);
View Full Code Here

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

    if (!message.neighborsSetList().isEmpty()) {
      // extract the PeerAddress from the reachable peer
      final PeerAddress originalSender = (PeerAddress) message.neighborsSetList().get(0).neighbors().toArray()[0];
      // create new PeerConnectin to the reachable peer
      final FuturePeerConnection fpc = peer.createPeerConnection(originalSender);
      fpc.addListener(new BaseFutureAdapter<FuturePeerConnection>() {
        @Override
        public void operationComplete(final FuturePeerConnection future) throws Exception {
          if (future.isSuccess() && future.peerConnection() != null) {
            // successfully created a connection from unreachable to the requester
            final PeerConnection peerConnection = future.peerConnection();
View Full Code Here

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

    }

    private FutureWrappedBootstrap<FutureBootstrap> bootstrapPing(PeerAddress address) {
        final FutureWrappedBootstrap<FutureBootstrap> result = new FutureWrappedBootstrap<FutureBootstrap>();
        final FuturePing futurePing = peer.ping().peerAddress(address).tcpPing().start();
        futurePing.addListener(new BaseFutureAdapter<FuturePing>() {
            @Override
            public void operationComplete(final FuturePing future) throws Exception {
                if (future.isSuccess()) {
                    peerAddress = future.remotePeer();
                    bootstrapTo = new ArrayList<PeerAddress>(1);
View Full Code Here

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

    if (putFuture == null) {
      return false;
    }

    FuturePutListener listener = new FuturePutListener(parameters, this);
    putFuture.addListener(listener);
    return listener.await();
  }

  @Override
  public boolean changeProtectionKey(IParameters parameters) {
View Full Code Here

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

  @Override
  public boolean remove(IParameters parameters) {
    FutureRemove futureRemove = removeUnblocked(parameters);
    FutureRemoveListener listener = new FutureRemoveListener(parameters, false, this);
    futureRemove.addListener(listener);
    return listener.await();
  }

  @Override
  public boolean removeVersion(IParameters parameters) {
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.