private void handleUpdate(final NetworkContext context) {
    log.debug(String.format("%s - Network configuration updated in cluster: %s", NetworkManager.this, cluster.address()));
    log.debug(String.format("%s - Scheduling network update task", NetworkManager.this));
    tasks.runTask(new Handler<Task>() {
      @Override
      public void handle(final Task task) {
        // Any time the network is being reconfigured, unready the network.
        // This will cause components to pause during the reconfiguration.
        unready(new Handler<AsyncResult<Void>>() {
          @Override
          public void handle(AsyncResult<Void> result) {
            if (result.failed()) {
              log.error(result.cause());
              task.complete();
            } else {
              if (currentContext != null) {
                final NetworkContext runningContext = currentContext;
                currentContext = context;
                

                // We have to update all instance contexts before deploying
                // any new components in order to ensure connections are
                // available for startup.
                log.info(String.format("%s - Updating network in cluster: %s", NetworkManager.this, address));
                log.debug(String.format("%s - Network:%n%s", NetworkManager.this, currentContext.toString(true)));
                updateNetwork(currentContext, new Handler<AsyncResult<Void>>() {
                  @Override
                  public void handle(AsyncResult<Void> result) {
                    if (result.failed()) {
                      log.warn(result.cause());
                      task.complete();
                    } else {
                      undeployRemovedComponents(currentContext, runningContext, new Handler<AsyncResult<Void>>() {
                        @Override
                        public void handle(AsyncResult<Void> result) {
                          if (result.failed()) {
                            log.warn(result.cause());
                            task.complete();
                          } else {
                            deployAddedComponents(currentContext, runningContext, new Handler<AsyncResult<Void>>() {
                              @Override
                              public void handle(AsyncResult<Void> result) {
                                task.complete();
                                if (result.failed()) {
                                  log.warn(result.cause());
                                }
                              }
                            });
                          }
                        }
                      });
                    }
                  }
                });
              }
              else {
                // Just deploy the entire network if it wasn't already deployed.
                currentContext = context;
                log.info(String.format("%s - Deploying network in cluster: %s", NetworkManager.this, address));
                log.debug(String.format("%s - Network:%n%s", NetworkManager.this, currentContext.toString(true)));
                deployNetwork(context, new Handler<AsyncResult<NetworkContext>>() {
                  @Override
                  public void handle(AsyncResult<NetworkContext> result) {
                    task.complete();
                    if (result.failed()) {
                      log.warn(result.cause());
                    } else {
                      log.info(String.format("%s - Successfully deployed network", NetworkManager.this));
                    }
                  }
                });
              }
            }
          }
        });
      }
    });
  }
private void handleUpdate ( final NetworkContext context ) { log . debug ( String . format ( "%s - Network configuration updated in cluster: %s" , NetworkManager . this , cluster . address ( ) ) ) ; log . debug ( String . format ( "%s - Scheduling network update task" , NetworkManager . this ) ) ; tasks . runTask ( new Handler < Task > ( ) { @ Override public void handle ( final Task task ) { unready ( new Handler < AsyncResult < Void > > ( ) { @ Override public void handle ( AsyncResult < Void > result ) { if ( result . failed ( ) ) { log . error ( result . cause ( ) ) ; task . complete ( ) ; } else { if ( currentContext != null ) { final NetworkContext runningContext = currentContext ; currentContext = context ; log . info ( String . format ( "%s - Updating network in cluster: %s" , NetworkManager . this , address ) ) ; log . debug ( String . format ( "%s - Network:%n%s" , NetworkManager . this , currentContext . toString ( true ) ) ) ; updateNetwork ( currentContext , new Handler < AsyncResult < Void > > ( ) { @ Override public void handle ( AsyncResult < Void > result ) { if ( result . failed ( ) ) { log . warn ( result . cause ( ) ) ; task . complete ( ) ; } else { undeployRemovedComponents ( currentContext , runningContext , new Handler < AsyncResult < Void > > ( ) { @ Override public void handle ( AsyncResult < Void > result ) { if ( result . failed ( ) ) { log . warn ( result . cause ( ) ) ; task . complete ( ) ; } else { deployAddedComponents ( currentContext , runningContext , new Handler < AsyncResult < Void > > ( ) { @ Override public void handle ( AsyncResult < Void > result ) { task . complete ( ) ; if ( result . failed ( ) ) { log . warn ( result . cause ( ) ) ; } } } ) ; } } } ) ; } } } ) ; } else { currentContext = context ; log . info ( String . format ( "%s - Deploying network in cluster: %s" , NetworkManager . this , address ) ) ; log . debug ( String . format ( "%s - Network:%n%s" , NetworkManager . this , currentContext . toString ( true ) ) ) ; deployNetwork ( context , new Handler < AsyncResult < NetworkContext > > ( ) { @ Override public void handle ( AsyncResult < NetworkContext > result ) { task . complete ( ) ; if ( result . failed ( ) ) { log . warn ( result . cause ( ) ) ; } else { log . info ( String . format ( "%s - Successfully deployed network" , NetworkManager . this ) ) ; } } } ) ; } } } } ) ; } } ) ; }
Handles the update of the network.