Package net.kuujo.vertigo.cluster

Examples of net.kuujo.vertigo.cluster.Node


      public void handle(AsyncResult<Node> result) {
        if (result.failed()) {
          new DefaultFutureResult<ActiveNetwork>(result.cause()).setHandler(doneHandler);
        } else {
          // Once we've selected a node we need to install all the modules to the node.
          final Node node = result.result();
          List<ModuleConfig> modules = new ArrayList<>();
          for (ComponentConfig<?> component : network.getComponents()) {
            if (component.getType().equals(ComponentConfig.Type.MODULE)) {
              modules.add((ModuleConfig) component);
            }
          }

          final CountingCompletionHandler<Void> counter = new CountingCompletionHandler<Void>(modules.size());
          counter.setHandler(new Handler<AsyncResult<Void>>() {
            @Override
            public void handle(AsyncResult<Void> result) {
              if (result.failed()) {
                new DefaultFutureResult<ActiveNetwork>(result.cause()).setHandler(doneHandler);
              } else {
                // Once all the modules have been installed we can deploy the network.
                JsonObject message = new JsonObject()
                    .putString("action", "deploy")
                    .putString("type", "network")
                    .putObject("network", SerializerFactory.getSerializer(Config.class).serializeToObject(network));
                vertx.eventBus().sendWithTimeout(address, message, DEFAULT_REPLY_TIMEOUT, new Handler<AsyncResult<Message<JsonObject>>>() {
                  @Override
                  public void handle(AsyncResult<Message<JsonObject>> result) {
                    if (result.failed()) {
                      new DefaultFutureResult<ActiveNetwork>(new ClusterException(result.cause())).setHandler(doneHandler);
                    } else if (result.result().body().getString("status").equals("error")) {
                      new DefaultFutureResult<ActiveNetwork>(new ClusterException(result.result().body().getString("message"))).setHandler(doneHandler);
                    } else {
                      createActiveNetwork(Contexts.<NetworkContext>deserialize(result.result().body().getObject("context")), doneHandler);
                    }
                  }
                });
              }
            }
          });

          for (ModuleConfig module : modules) {
            node.installModule(module.getModule(), counter);
          }
        }
      }
    });
    return this;
View Full Code Here

TOP

Related Classes of net.kuujo.vertigo.cluster.Node

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.