Package net.tomp2p.futures

Examples of net.tomp2p.futures.FutureChannelCreator


            System.err.println("do routing.");
            List<FutureRouting> frs = new ArrayList<FutureRouting>();
            for (int i = 0; i < peers.length; i++) {

                if (tcp) {
                    FutureChannelCreator fcc = peers[0].connectionBean().reservation().create(0, res);
                    fcc.awaitUninterruptibly();
                    cc = fcc.channelCreator();
                } else {
                    FutureChannelCreator fcc = peers[0].connectionBean().reservation().create(res, 0);
                    fcc.awaitUninterruptibly();
                    cc = fcc.channelCreator();
                }

                RoutingBuilder routingBuilder = new RoutingBuilder();
                if (tcp) {
                    routingBuilder.forceTCP(true);
View Full Code Here


            Collection<PeerAddress> peerAddresses = new ArrayList<PeerAddress>(1);
            peerAddresses.add(master.peerAddress());
            for (int i = 1; i < peers.length; i++) {

                if (tcp) {
                    FutureChannelCreator fcc = peers[0].connectionBean().reservation().create(0, 1);
                    fcc.awaitUninterruptibly();
                    cc = fcc.channelCreator();
                } else {
                    FutureChannelCreator fcc = peers[0].connectionBean().reservation().create(1, 0);
                    fcc.awaitUninterruptibly();
                    cc = fcc.channelCreator();
                }

                RoutingBuilder routingBuilder = new RoutingBuilder();
                if (tcp) {
                    routingBuilder.forceTCP(true);
View Full Code Here

                for (int i = 0; i < peers.length; i++) {
                    ss.add(peers[i].peerAddress());
                }
                // do testing
                if (tcp) {
                    FutureChannelCreator fcc = peers[0].connectionBean().reservation().create(0, 2);
                    fcc.awaitUninterruptibly();
                    cc = fcc.channelCreator();
                } else {
                    FutureChannelCreator fcc = peers[0].connectionBean().reservation().create(2, 0);
                    fcc.awaitUninterruptibly();
                    cc = fcc.channelCreator();
                }

                RoutingBuilder routingBuilder = new RoutingBuilder();
                if (tcp) {
                    routingBuilder.forceTCP(true);
View Full Code Here

            }
            new NeighborRPC(sender.peerBean(), sender.connectionBean());
            recv1 = new PeerBuilder(new Number160("0x20")).p2pId(55).ports(8088).start();
            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("0x1"), null);
            FutureResponse fr = neighbors2.closeNeighbors(sender.peerAddress(), v,
                    Type.REQUEST_2, cc, new DefaultConnectionConfiguration());
View Full Code Here

                sender.peerBean().peerMap().peerFound(pa[i], null, null);
            }
            new NeighborRPC(sender.peerBean(), sender.connectionBean());
            recv1 = new PeerBuilder(new Number160("0x20")).p2pId(55).ports(8088).start();
            NeighborRPC neighbors2 = new NeighborRPC(recv1.peerBean(), recv1.connectionBean());
            FutureChannelCreator fcc = recv1.connectionBean().reservation().create(0, 1);

            fcc.awaitUninterruptibly();
            ChannelCreator cc = fcc.channelCreator();

            SearchValues v = new SearchValues(new Number160("0x1"), null);
            DefaultConnectionConfiguration d = new DefaultConnectionConfiguration();
            d.forceTCP();
            FutureResponse fr = neighbors2.closeNeighbors(sender.peerAddress(), v,
View Full Code Here

     *            The peer address. Since pings are used the peer ID can be Number160.ZERO
     * @return The future discover. This future holds also the real ID of the peer we send the discover request
     */
    private FutureDiscover discover(final PeerAddress peerAddress, final ConnectionConfiguration configuration,
        final FutureDiscover futureDiscover) {
        FutureChannelCreator fcc = peer.connectionBean().reservation().create(1, 2);
        Utils.addReleaseListener(fcc, futureDiscover);
        fcc.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
            @Override
            public void operationComplete(final FutureChannelCreator future) throws Exception {
                if (future.isSuccess()) {
                    discover(futureDiscover, peerAddress, future.channelCreator(), configuration);
                } else {
View Full Code Here

        if (routingConfiguration == null) {
            routingConfiguration = new RoutingConfiguration(8, 10, 2);
        }
       
        int conn = routingConfiguration.parallel();
        FutureChannelCreator fcc = peer.connectionBean().reservation().create(conn, 0);
        final FutureDone<Void> futureShutdown = new FutureDone<Void> ();
        Utils.addReleaseListener(fcc, futureShutdown);
       
        fcc.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
            @Override
            public void operationComplete(final FutureChannelCreator futureChannelCreator) throws Exception {
              if (futureChannelCreator.isSuccess()) {
                ChannelCreator cc = futureChannelCreator.channelCreator();
                RoutingBuilder routingBuilder = BootstrapBuilder.createBuilder(routingConfiguration, forceRoutingOnlyToSelf);
View Full Code Here

        final DiscoverResults discoverResults = peer.connectionBean().channelServer().discoverNetworks().currentDiscoverResults();
        final int size = discoverResults.existingBroadcastAddresses().size();
        final FutureLateJoin<FutureResponse> futureLateJoin = new FutureLateJoin<FutureResponse>(size, 1);
        if (size > 0) {

            FutureChannelCreator fcc = peer.connectionBean().reservation().create(size, 0);
            Utils.addReleaseListener(fcc, futurePing);
            fcc.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
                @Override
                public void operationComplete(FutureChannelCreator future) throws Exception {
                    if (future.isSuccess()) {
                        addPingListener(futurePing, futureLateJoin);
                        for (InetAddress broadcastAddress: discoverResults.existingBroadcastAddresses()) {
View Full Code Here

     */
    private FuturePing ping(PeerAddress peerAddress, final boolean isUDP) {
      final FuturePing futurePing = new FuturePing();
        final RequestHandler<FutureResponse> request = peer.pingRPC().ping(peerAddress, connectionConfiguration);
        if (isUDP) {
            FutureChannelCreator fcc = peer.connectionBean().reservation().create(1, 0);
            Utils.addReleaseListener(fcc, futurePing);
            fcc.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
                @Override
                public void operationComplete(final FutureChannelCreator future) throws Exception {
                    if (future.isSuccess()) {
                        FutureResponse futureResponse = request.sendUDP(future.channelCreator());
                        addPingListener(futurePing, futureResponse);
                    } else {
                      futurePing.failed(future);
                    }
                }

       
            });
        } else {
            FutureChannelCreator fcc = peer.connectionBean().reservation().create(0, 1);
            Utils.addReleaseListener(fcc, futurePing);
            fcc.addListener(new BaseFutureAdapter<FutureChannelCreator>() {
                @Override
                public void operationComplete(final FutureChannelCreator future) throws Exception {
                    if (future.isSuccess()) {
                        FutureResponse futureResponse = request.sendTCP(future.channelCreator());
                        addPingListener(futurePing, futureResponse);
View Full Code Here

    private FuturePing pingPeerConnection(final PeerConnection peerConnection) {
      final FuturePing futurePing = new FuturePing();
     
        final RequestHandler<FutureResponse> request = peer.pingRPC().ping(
                peerConnection.remotePeer(), connectionConfiguration);
        FutureChannelCreator futureChannelCreator = peerConnection.acquire(request.futureResponse());
        futureChannelCreator.addListener(new BaseFutureAdapter<FutureChannelCreator>() {

            @Override
            public void operationComplete(FutureChannelCreator future) throws Exception {
                if(future.isSuccess()) {
                    request.futureResponse().request().keepAlive(true);
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.