Package net.kuujo.vertigo.network

Examples of net.kuujo.vertigo.network.NetworkConfig


        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());
View Full Code Here


    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());
View Full Code Here

        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());
View Full Code Here

    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());
View Full Code Here

  @Override
  public Verticle createVerticle(String main) throws Exception {
    JsonObject json = loadJson(main);
    String cluster = json.getString("cluster");
    Vertigo vertigo = new Vertigo(vertx, container);
    NetworkConfig network = vertigo.createNetwork(json);
    Verticle verticle = new NetworkVerticle(vertigo, cluster, network);
    verticle.setVertx(vertx);
    verticle.setContainer(container);
    return verticle;
  }
View Full Code Here

*/
public class NetworkTest {

  @Test
  public void testDefaultNetworkConfig() {
    NetworkConfig network = new DefaultNetworkConfig("test");
    assertEquals("test", network.getName());
  }
View Full Code Here

    assertFalse(verticle.isMultiThreaded());
  }

  @Test
  public void testAddInvalidModule() {
    NetworkConfig network = new DefaultNetworkConfig("test");
    try {
      network.addModule("feeder", "feeder.py");
      fail();
    }
    catch (IllegalArgumentException e) {
    }
  }
View Full Code Here

    assertEquals("test", module.getGroup());
  }

  @Test
  public void testAddFeeder() {
    NetworkConfig network = new DefaultNetworkConfig("test");
    assertEquals("test", network.getName());
    ComponentConfig<?> verticle1 = network.addVerticle("verticle1", "verticle1.py");
    assertEquals("verticle1", verticle1.getName());
    assertTrue(verticle1.getType().equals(ComponentConfig.Type.VERTICLE));
    assertEquals("verticle1.py", ((VerticleConfig) verticle1).getMain());
    assertEquals(new JsonObject(), verticle1.getConfig());
    assertEquals(1, verticle1.getInstances());
    ComponentConfig<?> verticle2 = network.addVerticle("verticle2", "verticle2.py", new JsonObject().putString("foo", "bar"));
    assertEquals("verticle2", verticle2.getName());
    assertTrue(verticle2.getType().equals(ComponentConfig.Type.VERTICLE));
    assertEquals("verticle2.py", ((VerticleConfig) verticle2).getMain());
    assertEquals("bar", verticle2.getConfig().getString("foo"));
    assertEquals(1, verticle2.getInstances());
    ComponentConfig<?> verticle3 = network.addVerticle("verticle3", "verticle3.py", 2);
    assertEquals("verticle3", verticle3.getName());
    assertTrue(verticle3.getType().equals(ComponentConfig.Type.VERTICLE));
    assertEquals("verticle3.py", ((VerticleConfig) verticle3).getMain());
    assertEquals(new JsonObject(), verticle3.getConfig());
    assertEquals(2, verticle3.getInstances());
    ComponentConfig<?> verticle4 = network.addVerticle("verticle4", "verticle4.py", new JsonObject().putString("foo", "bar"), 2);
    assertEquals("verticle4", verticle4.getName());
    assertTrue(verticle4.getType().equals(ComponentConfig.Type.VERTICLE));
    assertEquals("verticle4.py", ((VerticleConfig) verticle4).getMain());
    assertEquals("bar", verticle4.getConfig().getString("foo"));
    assertEquals(2, verticle4.getInstances());
    ComponentConfig<?> module1 = network.addModule("module1", "com.test~test-module~1.0");
    assertEquals("module1", module1.getName());
    assertTrue(module1.getType().equals(ComponentConfig.Type.MODULE));
    assertEquals("com.test~test-module~1.0", ((ModuleConfig) module1).getModule());
    assertEquals(new JsonObject(), module1.getConfig());
    assertEquals(1, module1.getInstances());
    ComponentConfig<?> module2 = network.addModule("module2", "com.test~test-module~2.0", new JsonObject().putString("foo", "bar"));
    assertEquals("module2", module2.getName());
    assertTrue(module2.getType().equals(ComponentConfig.Type.MODULE));
    assertEquals("com.test~test-module~2.0", ((ModuleConfig) module2).getModule());
    assertEquals("bar", module2.getConfig().getString("foo"));
    assertEquals(1, module2.getInstances());
    ComponentConfig<?> module3 = network.addModule("module3", "com.test~test-module~3.0", 2);
    assertEquals("module3", module3.getName());
    assertTrue(module3.getType().equals(ComponentConfig.Type.MODULE));
    assertEquals("com.test~test-module~3.0", ((ModuleConfig) module3).getModule());
    assertEquals(new JsonObject(), module3.getConfig());
    assertEquals(2, module3.getInstances());
    ComponentConfig<?> module4 = network.addModule("module4", "com.test~test-module~4.0", new JsonObject().putString("foo", "bar"), 2);
    assertEquals("module4", module4.getName());
    assertTrue(module4.getType().equals(ComponentConfig.Type.MODULE));
    assertEquals("com.test~test-module~4.0", ((ModuleConfig) module4).getModule());
    assertEquals("bar", module4.getConfig().getString("foo"));
    assertEquals(2, module4.getInstances());
View Full Code Here

        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()) {
View Full Code Here

    final Vertigo vertigo = new Vertigo(this);
    vertigo.deployCluster(UUID.randomUUID().toString(), new Handler<AsyncResult<Cluster>>() {
      @Override
      public void handle(AsyncResult<Cluster> result) {
        assertTrue(result.succeeded());
        NetworkConfig network = vertigo.createNetwork("test");
        network.addVerticle("feeder", WordCountNetwork.WordFeeder.class.getName());
        network.addVerticle("tester", WordTester.class.getName());
        network.createConnection("feeder", "word", "tester", "in");
        result.result().deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
          @Override
          public void handle(AsyncResult<ActiveNetwork> result) {
            assertTrue(result.succeeded());
          }
View Full Code Here

TOP

Related Classes of net.kuujo.vertigo.network.NetworkConfig

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.