Package net.kuujo.vertigo.cluster

Examples of net.kuujo.vertigo.cluster.Cluster


          // Create a connection between "sender" and "receiver" via the "file" port.
          network.createConnection("sender", "file", "receiver", "file");

          // Now deploy the network to the cluster.
          Cluster cluster = result.result();
          cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
            @Override
            public void handle(AsyncResult<ActiveNetwork> result) {
              if (result.failed()) {
                startResult.setFailure(result.cause());
              } else {
View Full Code Here


    final Vertigo vertigo = new Vertigo(this);
    vertigo.deployCluster(new Handler<AsyncResult<Cluster>>() {
      @Override
      public void handle(AsyncResult<Cluster> result) {
        assertTrue(result.succeeded());
        final Cluster cluster = result.result();

        // Deploy a network with a single component and connection. The connection
        // doesn't go anywhere, so messages sent to the sender's "out" port will
        // simply be discarded.
        NetworkConfig network = vertigo.createNetwork(name);
        network.addVerticle("sender", TestReconfigureSender.class.getName());
        network.createConnection("sender", "out", "receiver", "in");
        cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
          @Override
          public void handle(AsyncResult<ActiveNetwork> result) {
            if (result.failed()) {
              assertTrue(result.cause().getMessage(), result.succeeded());
            } else {

              // To add a component to listen to the sender's "out" port we simply
              // add a "receiver" component to a new configuration with the same
              // name as the original network's name. This will cause Vertigo to
              // merge the new configuration with the running configuration and
              // add the new component to the running network.
              NetworkConfig network = vertigo.createNetwork(name);
              network.addVerticle("receiver", TestReconfigureReceiver.class.getName());
              cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
                @Override
                public void handle(AsyncResult<ActiveNetwork> result) {
                  if (result.failed()) {
                    assertTrue(result.cause().getMessage(), result.succeeded());
                  } else {
View Full Code Here

    final Vertigo vertigo = new Vertigo(this);
    vertigo.deployCluster(new Handler<AsyncResult<Cluster>>() {
      @Override
      public void handle(AsyncResult<Cluster> result) {
        assertTrue(result.succeeded());
        final Cluster cluster = result.result();
        NetworkConfig network = vertigo.createNetwork(name);
        network.addVerticle("sender", TestSimpleSender.class.getName());
        network.addVerticle("receiver", TestSimpleReceiver.class.getName());
        network.createConnection("sender", "out", "receiver", "in");
        cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
          @Override
          public void handle(AsyncResult<ActiveNetwork> result) {
            if (result.failed()) {
              assertTrue(result.cause().getMessage(), result.succeeded());
            } else {
              NetworkConfig network = vertigo.createNetwork(name);
              network.addComponent("receiver", TestSimpleReceiver.class.getName());
              cluster.undeployNetwork(network, new Handler<AsyncResult<Void>>() {
                @Override
                public void handle(AsyncResult<Void> result) {
                  if (result.failed()) {
                    assertTrue(result.cause().getMessage(), result.succeeded());
                  } else {
View Full Code Here

    final Vertigo vertigo = new Vertigo(this);
    vertigo.deployCluster(new Handler<AsyncResult<Cluster>>() {
      @Override
      public void handle(AsyncResult<Cluster> result) {
        assertTrue(result.succeeded());
        final Cluster cluster = result.result();

        // Deploy a network with two components but no connections. The components
        // won't be able to communicate with each other, though the component code
        // doesn't need to know that
        NetworkConfig network = vertigo.createNetwork(name);
        network.addVerticle("sender", TestReconfigureSender.class.getName());
        network.addVerticle("receiver", TestReconfigureReceiver.class.getName());
        cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
          @Override
          public void handle(AsyncResult<ActiveNetwork> result) {
            if (result.failed()) {
              assertTrue(result.cause().getMessage(), result.succeeded());
            } else {
              // Now that the two components are running, to add a connection between
              // the two components we have to create a new network configuration with
              // the same name as the original network and add the connection to it.
              // When the new configuration is deployed, Vertigo will recognize that
              // it has the same name as the running connection and merge the two
              // networks.
              NetworkConfig network = vertigo.createNetwork(name);
              network.createConnection("sender", "out", "receiver", "in");
              cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
                @Override
                public void handle(AsyncResult<ActiveNetwork> result) {
                  if (result.failed()) {
                    assertTrue(result.cause().getMessage(), result.succeeded());
                  } else {
View Full Code Here

    final Vertigo vertigo = new Vertigo(this);
    vertigo.deployCluster(new Handler<AsyncResult<Cluster>>() {
      @Override
      public void handle(AsyncResult<Cluster> result) {
        assertTrue(result.succeeded());
        final Cluster cluster = result.result();
        NetworkConfig network = vertigo.createNetwork(name);
        network.addVerticle("sender", TestSimpleSender.class.getName());
        network.addVerticle("receiver", TestSimpleReceiver.class.getName());
        network.createConnection("sender", "out", "receiver", "in");
        cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
          @Override
          public void handle(AsyncResult<ActiveNetwork> result) {
            if (result.failed()) {
              assertTrue(result.cause().getMessage(), result.succeeded());
            } else {
              NetworkConfig network = vertigo.createNetwork(name);
              network.createConnection("sender", "out", "receiver", "in");
              cluster.undeployNetwork(network, new Handler<AsyncResult<Void>>() {
                @Override
                public void handle(AsyncResult<Void> result) {
                  if (result.failed()) {
                    assertTrue(result.cause().getMessage(), result.succeeded());
                  } else {
View Full Code Here

      @Override
      public void handle(AsyncResult<Cluster> result) {
        if (result.failed()) {
          startResult.setFailure(result.cause());
        } else {
          Cluster cluster = result.result();

          NetworkConfig network = vertigo.createNetwork("word-count");
          network.addVerticle("word-feeder", WordFeeder.class.getName());
          network.addVerticle("word-counter", WordCounter.class.getName(), 4);
          network.createConnection("word-feeder", "word", "word-counter", "word").hashSelect();

          cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
            @Override
            public void handle(AsyncResult<ActiveNetwork> result) {
              if (result.failed()) {
                startResult.setFailure(result.cause());
              } else {
View Full Code Here

        if (result.failed()) {
          startResult.setFailure(result.cause());
        } else {
          // The cluster is used to deploy, undeploy, and
          // reconfigure networks in a cluster.
          Cluster cluster = result.result();

          // Create a new network configuration. This network uses
          // circular connections to send "ack" messages back to the
          // FaultTolerantFeeder from the MessageReceiver.
          NetworkConfig network = vertigo.createNetwork("fault-tolerant");
          network.addVerticle("sender", FaultTolerantFeeder.class.getName());
          network.addVerticle("receiver", MessageReceiver.class.getName());
          network.createConnection("sender", "out", "receiver", "in");
          network.createConnection("receiver", "ack", "sender", "ack");

          // Deploy the network to the cluster. Once all the components
          // in the network have been started and all the connections
          // are successfully communicating with one another the async
          // handler will be called.
          cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
            @Override
            public void handle(AsyncResult<ActiveNetwork> result) {
              if (result.failed()) {
                startResult.setFailure(result.cause());
              } else {
View Full Code Here

   * @param address The cluster address.
   * @param resultHandler An asynchronous handler to be called once complete.
   * @return The Vertigo instance.
   */
  public Vertigo getCluster(String address, Handler<AsyncResult<Cluster>> resultHandler) {
    Cluster cluster = new DefaultCluster(address, vertx, container);
    cluster.ping(resultHandler);
    return this;
  }
View Full Code Here

        assertTrue(result.succeeded());
        NetworkConfig network = vertigo.createNetwork("test");
        network.addVerticle("sender", TestFeederSender.class.getName());
        network.addVerticle("receiver", TestFeederReceiver.class.getName(), 4);
        network.createConnection("sender", "out", "receiver", "in").setSelector(new RoundRobinSelector());
        Cluster cluster = result.result();
        cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
          @Override
          public void handle(AsyncResult<ActiveNetwork> result) {
            if (result.failed()) {
              assertTrue(result.cause().getMessage(), result.succeeded());
            } else {
View Full Code Here

        assertTrue(result.succeeded());
        NetworkConfig network = vertigo.createNetwork("test");
        network.addVerticle("sender", TestFileSender.class.getName());
        network.addVerticle("receiver", TestFileReceiver.class.getName(), 4);
        network.createConnection("sender", "out", "receiver", "in").setSelector(new RoundRobinSelector());
        Cluster cluster = result.result();
        cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
          @Override
          public void handle(AsyncResult<ActiveNetwork> result) {
            if (result.failed()) {
              assertTrue(result.cause().getMessage(), result.succeeded());
            } else {
View Full Code Here

TOP

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

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.