Package net.tomp2p.futures

Examples of net.tomp2p.futures.BaseFuture


           
            if(peerConnection!=null && nextDelay <= 0) {
                LOG.debug("sending heart beat to {}, {}", peerConnection.remotePeer(),
                    (peerConnection.channelFuture() != null ? peerConnection.channelFuture().channel() : null));
                PingBuilder builder = pingBuilderFactory.create();
                BaseFuture baseFuture = builder.peerConnection(peerConnection).start();
                builder.notifyAutomaticFutures(baseFuture);
            } else {
              LOG.debug("Not sending heart beat to {}, {}", peerConnection.remotePeer(),
                    (peerConnection.channelFuture() != null ? peerConnection.channelFuture().channel() : null));
            }
View Full Code Here


  @After
  public void shutdown() {
    System.err.println("shutdown initiated!");
    for (Peer ele : peers) {
      BaseFuture bf = ele.shutdown();
      bf.awaitUninterruptibly();
    }
    BaseFuture bf = unreachable.shutdown();
    bf.awaitUninterruptibly();
    System.err.println("shutdown done!");
  }
View Full Code Here

            }
      try {
        if (shutdownNow || ( !(repetitions<0) && counter++ > repetitions)) {
          shutdown();
        } else {
          BaseFuture baseFuture = builder.start();
          peer.notifyAutomaticFutures(baseFuture);
          if (automaticFuture != null) {
            automaticFuture.futureCreated(baseFuture);
          }
        }
View Full Code Here

   * Cancel the future that causes the underlying futures to cancel as well.
   */
  private static void cancel(final AtomicReferenceArray<FutureResponse> futures) {
    int len = futures.length();
    for (int i = 0; i < len; i++) {
      BaseFuture baseFuture = futures.get(i);
      if (baseFuture != null) {
        baseFuture.cancel();
      }
    }
  }
View Full Code Here

  private boolean bootstrap(Peer peer) throws UnknownHostException {
    // bootstrap
    InetAddress bootstrapTo = InetAddress.getLocalHost();
    BootstrapBuilder bootstrapBuilder = peer.bootstrap().inetAddress(bootstrapTo).ports(RELAY_START_PORT);
    BaseFuture bootstrap = bootstrapBuilder.start().awaitUninterruptibly();

    if (bootstrap == null) {
      LOG.error("Cannot bootstrap");
      return false;
    } else if (bootstrap.isFailed()) {
      LOG.error("Cannot bootstrap. Reason: {}", bootstrap.failedReason());
      return false;
    }

    LOG.debug("Peer has bootstrapped");
    return true;
View Full Code Here

        Peer master = null;
        Peer slave = null;
        try {
            master = new PeerBuilder(new Number160(rnd)).ports(4001).start();
            slave = new PeerBuilder(new Number160(rnd)).ports(4002).start();
            BaseFuture res = slave.ping().port(4001).broadcast().start();
            res.awaitUninterruptibly();
            Assert.assertEquals(true, res.isSuccess());
        } finally {
            if (master != null) {
                master.shutdown().await();
            }
            if (slave != null) {
View Full Code Here

     * Cancel the future that causes the underlying futures to cancel as well.
     */
    private static void cancel(final AtomicReferenceArray<FutureResponse> futures) {
        int len = futures.length();
        for (int i = 0; i < len; i++) {
            BaseFuture baseFuture = futures.get(i);
            if (baseFuture != null) {
                baseFuture.cancel();
            }
        }
    }
View Full Code Here

              System.err.println("this test does not work if none of your interfaces supports broadcast");
            } else {
              System.err.println(dr.existingBroadcastAddresses());
            }
           
            BaseFuture tmp = client.ping().broadcast().port(4000).start();
            tmp.awaitUninterruptibly();
            System.err.println(tmp.failedReason());
            Assert.assertEquals(true, tmp.isSuccess());

            Assert.assertEquals(1, client.peerBean().peerMap().size());
        } finally {
            if (client != null) {
                client.shutdown().await();
View Full Code Here

        Peer client = null;
        try {
          Bindings b = new Bindings().addInterface("lo");
          master = new PeerBuilder(new Number160(rnd)).bindings(b).ports(4002).start();
            client = new PeerBuilder(new Number160(rnd)).bindings(b).ports(4001).start();
            BaseFuture tmp = client.ping().broadcast().port(4001).start();
            tmp.awaitUninterruptibly();
            Assert.assertEquals(false, tmp.isSuccess());
            Assert.assertEquals(0, client.peerBean().peerMap().size());
        } finally {
            if (client != null) {
                client.shutdown().await();
            }
View Full Code Here

            for (Maintainable maintainable : maintainables) {
                PeerStatistic peerStatatistic = maintainable.nextForMaintenance(runningFutures.values());
                if(peerStatatistic == null) {
                    continue;
                }
                BaseFuture future = peer.ping().peerAddress(peerStatatistic.peerAddress()).start();
                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

TOP

Related Classes of net.tomp2p.futures.BaseFuture

Copyright © 2018 www.massapicom. 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.