Package net.tomp2p.futures

Examples of net.tomp2p.futures.FutureChannelCreator


        ChannelCreator cc = null;
        try {
            sender = new PeerBuilder(new Number160("0x9876")).p2pId(55).ports(2424).start();
            recv1 = new PeerBuilder(new Number160("0x1234")).p2pId(55).ports(8088).start();
            List<FutureResponse> list = new ArrayList<FutureResponse>(50);
            FutureChannelCreator fcc = recv1.connectionBean().reservation().create(0, 50);
            fcc.awaitUninterruptibly();
            cc = fcc.channelCreator();
            for (int i = 0; i < 50; i++) {
                FutureResponse fr = sender.pingRPC().pingTCP(recv1.peerAddress(), cc,
                        new DefaultConnectionConfiguration());
                list.add(fr);
            }
View Full Code Here


        Bindings b = new Bindings().addProtocol(StandardProtocolFamily.INET6);
        Peer peer = new PeerBuilder(new Number160(r)).bindings(b).ports(port).start();
        for (int i = 0; i < Integer.MAX_VALUE; i++) {
            for (PeerAddress pa : peer.peerBean().peerMap().all()) {
               
                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()) {
View Full Code Here

            for (int i = 0; i < p.length; i++) {
                p[i] = new PeerBuilder(Number160.createHash(i)).p2pId(55).ports(2424 + i).start();
            }
            List<FutureResponse> list = new ArrayList<FutureResponse>();
            for (int i = 0; i < p.length; i++) {
                FutureChannelCreator fcc = p[0].connectionBean().reservation().create(0, 1);
                fcc.awaitUninterruptibly();
                ChannelCreator cc = fcc.channelCreator();
                FutureResponse fr = p[0].pingRPC().pingTCP(p[i].peerAddress(), cc,
                        new DefaultConnectionConfiguration());
                Utils.addReleaseListener(cc, fr);
                list.add(fr);
            }
View Full Code Here

    System.out.println("Server started Listening to: " + DiscoverNetworks.discoverInterfaces(b));
    System.out.println("address visible to outside is " + master.peerAddress());
    while (true) {
      for (PeerAddress pa : master.peerBean().peerMap().all()) {
        System.out.println("PeerAddress: " + pa);
        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()) {
View Full Code Here

            sender = new PeerBuilder(new Number160("0x9876")).p2pId(55).ports(2424).start();
            recv1 = new PeerBuilder(new Number160("0x1234")).p2pId(55).ports(8088).start();
            long start = System.currentTimeMillis();
            List<FutureResponse> list = new ArrayList<FutureResponse>(100);
            for (int i = 0; i < 20; i++) {
                FutureChannelCreator fcc = recv1.connectionBean().reservation().create(0, 50);
                fcc.awaitUninterruptibly();
                ChannelCreator cc = fcc.channelCreator();
                for (int j = 0; j < 50; j++) {
                    FutureResponse fr = sender.pingRPC().pingTCP(recv1.peerAddress(), cc,
                            new DefaultConnectionConfiguration());
                    list.add(fr);
                }
                for (FutureResponse fr2 : list) {
                    fr2.awaitUninterruptibly();
                    if (!fr2.isSuccess())
                        System.err.println("fail " + fr2.failedReason());
                    Assert.assertEquals(true, fr2.isSuccess());
                }
                list.clear();
                cc.shutdown().await();
            }
            System.out.println("TCP time: " + (System.currentTimeMillis() - start));
            for (FutureResponse fr2 : list) {
                fr2.awaitUninterruptibly();
                Assert.assertEquals(true, fr2.isSuccess());
            }
            //
            start = System.currentTimeMillis();
            list = new ArrayList<FutureResponse>(50);
            for (int i = 0; i < 20; i++) {
                FutureChannelCreator fcc = recv1.connectionBean().reservation().create(50, 0);
                fcc.awaitUninterruptibly();
                ChannelCreator cc = fcc.channelCreator();
                for (int j = 0; j < 50; j++) {
                    FutureResponse fr = sender.pingRPC().pingUDP(recv1.peerAddress(), cc,
                            new DefaultConnectionConfiguration());
                    list.add(fr);
                }
View Full Code Here

        Peer sender = null;
        Peer recv1 = null;
        try {
            sender = new PeerBuilder(new Number160("0x9876")).p2pId(55).ports(2424).start();
            recv1 = new PeerBuilder(new Number160("0x1234")).p2pId(55).ports(8088).start();
            FutureChannelCreator fcc = recv1.connectionBean().reservation().create(0, 1);
            fcc.awaitUninterruptibly();
            ChannelCreator cc = fcc.channelCreator();
            FutureResponse fr = sender.pingRPC().pingTCP(recv1.peerAddress(), cc,
                    new DefaultConnectionConfiguration());
            Utils.addReleaseListener(cc, fr);
            fr.awaitUninterruptibly();
            fr.awaitListeners();
View Full Code Here

      sender.put(locationKey).data(new Data(value)).start().awaitUninterruptibly();
      receiver.put(locationKey).data(new Data(value)).start().awaitUninterruptibly();

      sender.peer().bootstrap().peerAddress(receiver.peerAddress()).start().awaitUninterruptibly();

      FutureChannelCreator futureChannelCreator = sender.peer().connectionBean().reservation().create(0, 1);

      final CountDownLatch latch = new CountDownLatch(1);
      final PeerAddress receiverAddress = receiver.peerAddress();

      futureChannelCreator.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
        @Override
        public void operationComplete(final FutureChannelCreator future2) throws Exception {
          if (future2.isSuccess()) {
            SyncBuilder synchronizationBuilder = new SyncBuilder(senderSync, receiverAddress, 5);
            synchronizationBuilder.dataMap(dataMap);
View Full Code Here

  }

  public FutureDone<Void> peerExchange(final PeerAddress remotePeer, final Number320 key, final TrackerData data,
          final ConnectionConfiguration connectionConfiguration) {
    final FutureDone<Void> futureDone = new FutureDone<Void>();
    FutureChannelCreator futureChannelCreator = peer.connectionBean().reservation().create(1, 0);
    Utils.addReleaseListener(futureChannelCreator, futureDone);
    futureChannelCreator.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
      @Override
      public void operationComplete(FutureChannelCreator future) throws Exception {
        if (future.isSuccess()) {
          final ChannelCreator channelCreator = future.channelCreator();
          FutureResponse futureResponse = peerExchangeRPC.peerExchange(remotePeer, key, channelCreator, data,
View Full Code Here

      sender.put(locationKey).data(new Data(value)).start().awaitUninterruptibly();

      sender.peer().bootstrap().peerAddress(receiver.peerAddress()).start().awaitUninterruptibly();
      final CountDownLatch latch = new CountDownLatch(1);
      final PeerAddress receiverAddress = receiver.peerAddress();
      FutureChannelCreator futureChannelCreator = sender.peer().connectionBean().reservation().create(0, 1);
      futureChannelCreator.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
        @Override
        public void operationComplete(final FutureChannelCreator future2) throws Exception {
          if (future2.isSuccess()) {
            SyncBuilder synchronizationBuilder = new SyncBuilder(senderSync, receiverAddress, 5);
            synchronizationBuilder.dataMap(dataMap);
View Full Code Here

      sender.peer().bootstrap().peerAddress(receiver.peerAddress()).start().awaitUninterruptibly();

      final CountDownLatch latch = new CountDownLatch(1);
      final PeerAddress receiverAddress = receiver.peerAddress();

      FutureChannelCreator futureChannelCreator = sender.peer().connectionBean().reservation().create(0, 1);
      futureChannelCreator.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
        @Override
        public void operationComplete(final FutureChannelCreator future2) throws Exception {
          if (future2.isSuccess()) {
            SyncBuilder synchronizationBuilder = new SyncBuilder(senderSync, receiverAddress, 5);
            synchronizationBuilder.dataMap(dataMap);
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.