Package net.kuujo.vertigo

Examples of net.kuujo.vertigo.Vertigo


    }
  }

  @Override
  public void start(final Future<Void> startResult) {
    final Vertigo vertigo = new Vertigo(this);

    // Deploy a single-node Vertigo cluster at the "default" event bus address.
    // Note: In production clusters you should deploy instances of the
    // net.kuujo~vertigo-cluster~0.7.x module.
    vertigo.deployCluster("default", new Handler<AsyncResult<Cluster>>() {
      @Override
      public void handle(AsyncResult<Cluster> result) {
        if (result.failed()) {
          startResult.setFailure(result.cause());
        } else {
          // If the cluster was successfully deployed, create the file sender network.
          NetworkConfig network = vertigo.createNetwork("file-send");

          // Add the "sender" component.
          network.addVerticle("sender", FileSender.class.getName());

          // We can create four instances of the "receiver" and Vertigo will still
View Full Code Here


  }

  @Test
  public void testReconfigureAddComponent() {
    final String name = Addresses.createUniqueAddress();
    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()) {
View Full Code Here

  }

  @Test
  public void testReconfigureRemoveComponent() {
    final String name = Addresses.createUniqueAddress();
    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()) {
View Full Code Here

  }

  @Test
  public void testReconfigureCreateConnection() {
    final String name = Addresses.createUniqueAddress();
    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()) {
View Full Code Here

  }

  @Test
  public void testReconfigureDestroyConnection() {
    final String name = Addresses.createUniqueAddress();
    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()) {
View Full Code Here

  @Test
  public void testNetworkFromJson() {
    JsonObject json = new JsonObject()
        .putString(NetworkConfig.NETWORK_NAME, "test")
        .putObject(NetworkConfig.NETWORK_COMPONENTS, new JsonObject());
    NetworkConfig network = new Vertigo(null, null).createNetwork(json);
    assertEquals("test", network.getName());
  }
View Full Code Here

        .putString(ModuleConfig.COMPONENT_TYPE, ModuleConfig.COMPONENT_TYPE_MODULE)
        .putString(ModuleConfig.MODULE_NAME, "com.test~test-module~1.0")
        .putObject(ModuleConfig.COMPONENT_CONFIG, new JsonObject().putString("foo", "bar"))
        .putNumber(ModuleConfig.COMPONENT_NUM_INSTANCES, 2);
    json.putObject(NetworkConfig.NETWORK_COMPONENTS, new JsonObject().putObject("feeder", jsonFeeder));
    NetworkConfig network = new Vertigo(null, null).createNetwork(json);
    assertEquals("test", network.getName());
    ModuleConfig module = network.getComponent("feeder");
    assertEquals("feeder", module.getName());
    assertEquals("com.test~test-module~1.0", module.getModule());
    assertEquals("bar", module.getConfig().getString("foo"));
View Full Code Here

        .putObject(VerticleConfig.COMPONENT_CONFIG, new JsonObject().putString("foo", "bar"))
        .putNumber(VerticleConfig.COMPONENT_NUM_INSTANCES, 2)
        .putBoolean(VerticleConfig.VERTICLE_IS_WORKER, true)
        .putBoolean(VerticleConfig.VERTICLE_IS_MULTI_THREADED, true);
    json.putObject(NetworkConfig.NETWORK_COMPONENTS, new JsonObject().putObject("feeder", jsonFeeder));
    NetworkConfig network = new Vertigo(null, null).createNetwork(json);
    assertEquals("test", network.getName());
    VerticleConfig verticle = network.getComponent("feeder");
    assertEquals("feeder", verticle.getName());
    assertEquals("test.py", verticle.getMain());
    assertEquals("bar", verticle.getConfig().getString("foo"));
View Full Code Here

        .putString(ModuleConfig.COMPONENT_TYPE, ModuleConfig.COMPONENT_TYPE_MODULE)
        .putString(ModuleConfig.MODULE_NAME, "com.test~test-module~1.0")
        .putObject(ModuleConfig.COMPONENT_CONFIG, new JsonObject().putString("foo", "bar"))
        .putNumber(ModuleConfig.COMPONENT_NUM_INSTANCES, 2);
    json.putObject(NetworkConfig.NETWORK_COMPONENTS, new JsonObject().putObject("worker", jsonWorker));
    NetworkConfig network = new Vertigo(null, null).createNetwork(json);
    assertEquals("test", network.getName());
    ModuleConfig module = network.getComponent("worker");
    assertEquals("worker", module.getName());
    assertEquals("com.test~test-module~1.0", module.getModule());
    assertEquals("bar", module.getConfig().getString("foo"));
View Full Code Here

        .putObject(VerticleConfig.COMPONENT_CONFIG, new JsonObject().putString("foo", "bar"))
        .putNumber(VerticleConfig.COMPONENT_NUM_INSTANCES, 2)
        .putBoolean(VerticleConfig.VERTICLE_IS_WORKER, true)
        .putBoolean(VerticleConfig.VERTICLE_IS_MULTI_THREADED, true);
    json.putObject(NetworkConfig.NETWORK_COMPONENTS, new JsonObject().putObject("worker", jsonWorker));
    NetworkConfig network = new Vertigo(null, null).createNetwork(json);
    assertEquals("test", network.getName());
    VerticleConfig verticle = network.getComponent("worker");
    assertEquals("worker", verticle.getName());
    assertEquals("test.py", verticle.getMain());
    assertEquals("bar", verticle.getConfig().getString("foo"));
View Full Code Here

TOP

Related Classes of net.kuujo.vertigo.Vertigo

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.