Examples of FutureRouting


Examples of net.tomp2p.futures.FutureRouting

            routingBuilder.setMaxNoNewInfo(0);
            routingBuilder.maxFailures(0);
            routingBuilder.maxSuccess(100);
            routingBuilder.parallel(2);

            FutureRouting fr = peers[0].distributedRouting().route(routingBuilder, request, cc);

            fr.awaitUninterruptibly();
            // do verification
            Assert.assertEquals(true, fr.isSuccess());
            SortedSet<PeerAddress> ns = fr.potentialHits();
            Assert.assertEquals(peers[5].peerAddress(), ns.first());
            Assert.assertEquals(true, ns.contains(peers[0].peerAddress()));
            Assert.assertEquals(true, ns.contains(peers[1].peerAddress()));
            Assert.assertEquals(true, ns.contains(peers[2].peerAddress()));
            Assert.assertEquals(false, ns.contains(peers[3].peerAddress()));
View Full Code Here

Examples of net.tomp2p.futures.FutureRouting

            routingBuilder.setMaxNoNewInfo(0);
            routingBuilder.maxFailures(0);
            routingBuilder.maxSuccess(100);
            routingBuilder.parallel(3);

            FutureRouting fr = peers[0].distributedRouting().route(routingBuilder, request, cc);

            fr.awaitUninterruptibly();
            // do verification
            Assert.assertEquals(true, fr.isSuccess());
            SortedSet<PeerAddress> ns = fr.potentialHits();
            Assert.assertEquals(peers[5].peerAddress(), ns.first());
            Assert.assertEquals(true, ns.contains(peers[3].peerAddress()));
            Assert.assertEquals(true, ns.contains(peers[4].peerAddress()));
            Assert.assertEquals(6, ns.size());
        } finally {
View Full Code Here

Examples of net.tomp2p.futures.FutureRouting

            routingBuilder.setMaxNoNewInfo(0);
            routingBuilder.maxFailures(0);
            routingBuilder.maxSuccess(100);
            routingBuilder.parallel(1);

            FutureRouting fr = peers[500].distributedRouting().route(routingBuilder, request, cc);

            fr.awaitUninterruptibly();
            // do verification
            Assert.assertEquals(true, fr.isSuccess());
            SortedSet<PeerAddress> ns = fr.potentialHits();
            Assert.assertEquals(peers[20].peerAddress(), ns.first());
        } finally {
            if (cc != null) {
                cc.shutdown().awaitListenersUninterruptibly();
            }
View Full Code Here

Examples of net.tomp2p.futures.FutureRouting

                routingBuilder.setMaxNoNewInfo(0);
                routingBuilder.maxFailures(0);
                routingBuilder.maxSuccess(100);
                routingBuilder.parallel(res);

                FutureRouting frr = peers[rnd2.nextInt(peers.length)].distributedRouting().route(
                        routingBuilder, request, cc);

                frs.add(frr);
                Utils.addReleaseListener(cc, frr);
            }
View Full Code Here

Examples of net.tomp2p.futures.FutureRouting

                routingBuilder.setMaxNoNewInfo(5);
                routingBuilder.maxFailures(10);
                routingBuilder.maxSuccess(20);
                routingBuilder.parallel(2);

                FutureRouting frr = peers[50].distributedRouting().route(routingBuilder, Type.REQUEST_1,
                        cc);

                frr.awaitUninterruptibly();
                SortedSet<PeerAddress> ss2 = frr.potentialHits();
                // test the first 5 peers, because we set noNewInformation to 5,
                // which means we find at least 5 entries.
                for (int i = 0; i < 5; i++) {
                    PeerAddress pa = ss.first();
                    PeerAddress pa2 = ss2.first();
View Full Code Here

Examples of net.tomp2p.futures.FutureRouting

            public void operationComplete(final FutureChannelCreator futureChannelCreator) throws Exception {
              if (futureChannelCreator.isSuccess()) {
                ChannelCreator cc = futureChannelCreator.channelCreator();
                RoutingBuilder routingBuilder = BootstrapBuilder.createBuilder(routingConfiguration, forceRoutingOnlyToSelf);
                routingBuilder.locationKey(peer.peerID());
                FutureRouting futureRouting = peer.distributedRouting().quit(routingBuilder, cc);
                futureRouting.addListener(new BaseFutureAdapter<FutureRouting>() {
            @Override
                        public void operationComplete(FutureRouting future) throws Exception {
                         if(future.isSuccess()) {
                           futureShutdown.done();
                         } else {
View Full Code Here

Examples of net.tomp2p.futures.FutureRouting

        final FutureDone<Pair<FutureRouting,FutureRouting>> futureDone = new FutureDone<Pair<FutureRouting,FutureRouting>>();

        // first we find close peers to us
        routingBuilder.bootstrap(true);

        final FutureRouting futureRouting0 = routing(peerAddresses, routingBuilder, Type.REQUEST_1, cc);
        // to not become a Fachidiot (expert idiot), we need to know other peers
        // as well. This is important if this peer is passive and only replies on requests from other peers
        futureRouting0.addListener(new BaseFutureAdapter<FutureRouting>() {
            @Override
            public void operationComplete(final FutureRouting future) throws Exception {
                // setting this to null causes to search for a random number
              if(future.isSuccess()) {
                routingBuilder.locationKey(null);
                final FutureRouting futureRouting1 = routing(peerAddresses, routingBuilder, Type.REQUEST_1, cc);
                futureRouting1.addListener(new BaseFutureAdapter<FutureRouting>() {
                  @Override
                  public void operationComplete(FutureRouting future) throws Exception {
                    final Pair<FutureRouting,FutureRouting> pair = new Pair<FutureRouting, FutureRouting>(futureRouting0, futureRouting1);
                    futureDone.done(pair);
                  }
View Full Code Here

Examples of net.tomp2p.futures.FutureRouting

            if (digestInfo.size() > 0) {
                directHits.put(peerBean.serverPeerAddress(), digestInfo);
            }
        }
       
        final FutureRouting futureRouting = new FutureRouting();
        if (peerAddresses.size() == 0) {
            futureRouting.neighbors(directHits, potentialHits, alreadyAsked, routingBuilder.isBootstrap(),
                    false);
        } else {
            // if a peer bootstraps to itself, then the size of peerAddresses
            // is 1 and it contains itself. Check for that because we need to
            // know if we are routing, bootstrapping and bootstrapping to
View Full Code Here

Examples of net.tomp2p.futures.FutureRouting

            startLoop(builder, futureTracker, queue, futureChannelCreator2.channelCreator());
          }

          else {
           
            final FutureRouting futureRouting = createRouting(builder, Type.REQUEST_3,
                    futureChannelCreator2.channelCreator());

            futureRouting.addListener(new BaseFutureAdapter<FutureRouting>() {
              @Override
              public void operationComplete(FutureRouting future) throws Exception {
                if (futureRouting.isSuccess()) {
                  LOG.debug("found direct hits for tracker get: {}", futureRouting.directHits());
                  startLoop(builder, futureTracker, futureRouting.directHits(),
                          futureChannelCreator2.channelCreator());
                } else {
                  futureTracker.failed(futureRouting);
                }
              }
View Full Code Here

Examples of net.tomp2p.futures.FutureRouting

    builder.futureChannelCreator().addListener(new BaseFutureAdapter<FutureChannelCreator>() {
      @Override
      public void operationComplete(final FutureChannelCreator futureChannelCreator2) throws Exception {
        if (futureChannelCreator2.isSuccess()) {

          final FutureRouting futureRouting = createRouting(builder, Type.REQUEST_1,
                  futureChannelCreator2.channelCreator());

          futureRouting.addListener(new BaseFutureAdapter<FutureRouting>() {
            @Override
            public void operationComplete(FutureRouting future) throws Exception {
              if (futureRouting.isSuccess()) {
                LOG.debug("found potential hits for tracker add: {}", futureRouting.potentialHits());
                loop(builder.locationKey(), builder.domainKey(), futureRouting.potentialHits(),
                        builder.trackerConfiguration(), futureTracker, false,
                        builder.knownPeers(), new Operation() {
                          @Override
                          public FutureResponse create(PeerAddress remotePeer, boolean primary) {
                            LOG.debug("tracker add (me={}): {} location={}",
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.