Package net.tomp2p.futures

Examples of net.tomp2p.futures.FutureChannelCreator


      c.maxPermitsTCP(tcpMax);
      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


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

      c.pipelineFilter(new MyPipeLine());
      c.maxPermitsTCP(tcpMax);
      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 {
            if (future.isFailed()) {
              return;
            }
View Full Code Here

      c.pipelineFilter(new MyPipeLine());
      c.maxPermitsTCP(tcpMax);
      Reservation r = new Reservation(ev, 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 {
            if (future.isFailed()) {
              return;
            }
View Full Code Here

    }
    if (permitsTCP > maxPermitsTCP) {
      throw new IllegalArgumentException("cannot aquire more TCP connections (" + permitsTCP + ") than maximum "
              + maxPermitsTCP);
    }
    final FutureChannelCreator futureChannelCreator = new FutureChannelCreator();
    read.lock();
    try {
      if (shutdown) {
        return futureChannelCreator.failed("shutting down");
      }

      FutureDone<Void> futureChannelCreationDone = new FutureDone<Void>();
      futureChannelCreationDone.addListener(new BaseFutureAdapter<FutureDone<Void>>() {
        @Override
View Full Code Here

  public FutureChannelCreator createPermanent(final int permitsPermanentTCP) {
    if (permitsPermanentTCP > maxPermitsPermanentTCP) {
      throw new IllegalArgumentException("cannot aquire more TCP connections (" + permitsPermanentTCP
              + ") than maximum " + maxPermitsPermanentTCP);
    }
    final FutureChannelCreator futureChannelCreator = new FutureChannelCreator();
    read.lock();
    try {
      if (shutdown) {
        return futureChannelCreator.failed("shutting down");
      }
      FutureDone<Void> futureChannelCreationDone = new FutureDone<Void>();
      futureChannelCreationDone.addListener(new BaseFutureAdapter<FutureDone<Void>>() {
        @Override
        public void operationComplete(final FutureDone<Void> future) throws Exception {
View Full Code Here

        }
        return closeFuture;
    }

    public FutureChannelCreator acquire(final FutureResponse futureResponse) {
        FutureChannelCreator futureChannelCreator = new FutureChannelCreator();
        return acquire(futureChannelCreator, futureResponse);
    }
View Full Code Here

            }
            synchronized (lock) {
                status.put(taskKey, Status.SUCCESS_RESULT_NOT_SENT);
            }
            final Map<Number160, Data> outputData2 = outputData;
            FutureChannelCreator futureChannelCreator = connectionBean.getConnectionReservation().reserve(1);
            futureChannelCreator.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
                @Override
                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);
                                    }
                                } else {
                                    registerException(taskKey, "could not send result back");
                                }
                                connectionBean.getConnectionReservation().release(
                                        futureChannelCreator.getChannelCreator());
                            }
                        });
                    } else {
                        registerException(taskKey, "could not reserve connection");
                    }
View Full Code Here

            sender = new PeerBuilder(new Number160("0x50")).p2pId(55).ports(2424).start();
            recv1 = new PeerBuilder(new Number160("0x20")).p2pId(55).ports(8088).start();
            new NeighborRPC(sender.peerBean(), sender.connectionBean());
            NeighborRPC neighbors2 = new NeighborRPC(recv1.peerBean(), recv1.connectionBean());

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

            SearchValues v = new SearchValues(new Number160("0x30"), null);
            FutureResponse fr = neighbors2.closeNeighbors(sender.peerAddress(), v,
                    Type.REQUEST_2, cc, new DefaultConnectionConfiguration());
            fr.awaitUninterruptibly();
View Full Code Here

            sender = new PeerBuilder(new Number160("0x50")).p2pId(55).ports(2424).start();
            recv1 = new PeerBuilder(new Number160("0x20")).p2pId(55).ports(8088).start();
            new NeighborRPC(sender.peerBean(), sender.connectionBean());
            NeighborRPC neighbors2 = new NeighborRPC(recv1.peerBean(), recv1.connectionBean());

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

            try {
                SearchValues v = new SearchValues(new Number160("0x30"), null);
                neighbors2.closeNeighbors(sender.peerAddress(), v,
                        Type.EXCEPTION, cc, new DefaultConnectionConfiguration());
View Full Code Here

TOP

Related Classes of net.tomp2p.futures.FutureChannelCreator

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.