Esempio n. 1
0
 private FutureWrappedBootstrap<FutureBootstrap> broadcast() {
   final FutureWrappedBootstrap<FutureBootstrap> result =
       new FutureWrappedBootstrap<FutureBootstrap>();
   // limit after
   @SuppressWarnings("unchecked")
   final FutureLateJoin<FutureResponse> tmp =
       (FutureLateJoin<FutureResponse>) peer.ping().setBroadcast().setPort(portUDP).start();
   tmp.addListener(
       new BaseFutureAdapter<FutureLateJoin<FutureResponse>>() {
         @Override
         public void operationComplete(final FutureLateJoin<FutureResponse> future)
             throws Exception {
           if (future.isSuccess()) {
             FutureResponse futureResponse = future.getLastSuceessFuture();
             if (futureResponse == null) {
               result.setFailed("no futures found", future);
               return;
             }
             if (bootstrapTo != null && bootstrapTo.size() > 0) {
               logger.info(
                   "you added peers to bootstrapTo. However with broadcast we found our own peers.");
             }
             peerAddress = futureResponse.getResponse().getSender();
             bootstrapTo = new ArrayList<PeerAddress>(1);
             bootstrapTo.add(peerAddress);
             result.setBootstrapTo(bootstrapTo);
             result.waitFor(bootstrap());
           } else {
             result.setFailed("could not reach anyone with the broadcast", future);
           }
         }
       });
   return result;
 }
Esempio n. 2
0
 private FutureWrappedBootstrap<FutureBootstrap> bootstrapPing(PeerAddress address) {
   final FutureWrappedBootstrap<FutureBootstrap> result =
       new FutureWrappedBootstrap<FutureBootstrap>();
   final FutureResponse tmp =
       (FutureResponse) peer.ping().setPeerAddress(address).setTcpPing().start();
   tmp.addListener(
       new BaseFutureAdapter<FutureResponse>() {
         @Override
         public void operationComplete(final FutureResponse future) throws Exception {
           if (future.isSuccess()) {
             peerAddress = future.getResponse().getSender();
             bootstrapTo = new ArrayList<PeerAddress>(1);
             bootstrapTo.add(peerAddress);
             result.setBootstrapTo(bootstrapTo);
             result.waitFor(bootstrap());
           } else {
             result.setFailed("could not reach anyone with bootstrap");
           }
         }
       });
   return result;
 }