Package net.kuujo.vertigo.component

Examples of net.kuujo.vertigo.component.ModuleConfig


  @Test
  public void testAddWorkerModule() {
    NetworkConfig network = new DefaultNetworkConfig("test");
    assertEquals("test", network.getName());
    ModuleConfig 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", module1.getModule());
    assertEquals(new JsonObject(), module1.getConfig());
    assertEquals(1, module1.getInstances());
    ModuleConfig 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", module2.getModule());
    assertEquals("bar", module2.getConfig().getString("foo"));
    assertEquals(1, module2.getInstances());
    ModuleConfig 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", module3.getModule());
    assertEquals(new JsonObject(), module3.getConfig());
    assertEquals(2, module3.getInstances());
    ModuleConfig 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", module4.getModule());
    assertEquals("bar", module4.getConfig().getString("foo"));
    assertEquals(2, module4.getInstances());
  }
View Full Code Here


        .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"));
    assertEquals(2, module.getInstances());
    assertTrue(module.getType().equals(ComponentConfig.Type.MODULE));
  }
View Full Code Here

        .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"));
    assertEquals(2, module.getInstances());
    assertTrue(module.getType().equals(ComponentConfig.Type.MODULE));
  }
View Full Code Here

    }
  }

  @Test
  public void testModuleDefaults() {
    ModuleConfig module = new DefaultModuleConfig("test", "com.test~test-module~1.0", new DefaultNetworkConfig("test"));
    assertEquals("test", module.getName());
    assertTrue(module.getType().equals(ComponentConfig.Type.MODULE));
    assertEquals("com.test~test-module~1.0", module.getModule());
    assertEquals(new JsonObject(), module.getConfig());
    assertEquals(1, module.getInstances());
  }
View Full Code Here

    assertEquals(1, module.getInstances());
  }

  @Test
  public void testDefaultModuleConfig() {
    ModuleConfig module = new DefaultModuleConfig("test", "com.test~test-module~1.0", new DefaultNetworkConfig("test"));
    assertEquals("test", module.getName());
    assertTrue(module.getType().equals(ComponentConfig.Type.MODULE));
    assertEquals("com.test~test-module~1.0", module.getModule());
    module.setModule("com.foo~foo~1.0");
    assertEquals("com.foo~foo~1.0", module.getModule());
    assertEquals(new JsonObject(), module.getConfig());
    module.setConfig(new JsonObject().putString("foo", "bar"));
    assertEquals("bar", module.getConfig().getString("foo"));
    assertEquals(1, module.getInstances());
    module.setInstances(4);
    assertEquals(4, module.getInstances());
    module.setGroup("test");
    assertEquals("test", module.getGroup());
  }
View Full Code Here

  @Test
  public void testAddFeederModule() {
    NetworkConfig network = new DefaultNetworkConfig("test");
    assertEquals("test", network.getName());
    ModuleConfig 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", module1.getModule());
    assertEquals(new JsonObject(), module1.getConfig());
    assertEquals(1, module1.getInstances());
    ModuleConfig 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", module2.getModule());
    assertEquals("bar", module2.getConfig().getString("foo"));
    assertEquals(1, module2.getInstances());
    ModuleConfig 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", module3.getModule());
    assertEquals(new JsonObject(), module3.getConfig());
    assertEquals(2, module3.getInstances());
    ModuleConfig 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", module4.getModule());
    assertEquals("bar", module4.getConfig().getString("foo"));
    assertEquals(2, module4.getInstances());
  }
View Full Code Here

  }

  @Test
  public void testConfiguredFeederModuleContext() {
    DefaultNetworkConfig network = new DefaultNetworkConfig("test");
    ModuleConfig verticle = network.addModule("feeder", "com.test~test-module~1.0");
    verticle.setModule("com.test~test-module~1.0");
    verticle.setConfig(new JsonObject().putString("foo", "bar"));
    verticle.setInstances(2);
    verticle.setGroup("test");
    NetworkContext context = ContextBuilder.buildContext(network, "vertigo");
    assertEquals("vertigo.test", context.address());
    ModuleContext moduleContext = context.component("feeder");
    assertEquals("feeder", moduleContext.name());
    assertEquals("vertigo.test.feeder", moduleContext.address());
View Full Code Here

  }

  @Test
  public void testConfiguredWorkerModuleContext() {
    DefaultNetworkConfig network = new DefaultNetworkConfig("test");
    ModuleConfig module = network.addModule("worker", "com.test~test-module~1.0");
    module.setModule("com.test~test-module~1.0");
    module.setConfig(new JsonObject().putString("foo", "bar"));
    module.setInstances(2);
    module.setGroup("test");
    NetworkContext context = ContextBuilder.buildContext(network, "vertigo");
    assertEquals("vertigo.test", context.address());
    ModuleContext moduleContext = context.component("worker");
    assertEquals("worker", moduleContext.name());
    assertEquals("vertigo.test.worker", moduleContext.address());
View Full Code Here

    return addModule(name, moduleName, null, instances, doneHandler);
  }

  @Override
  public ModuleConfig addModule(String name, String moduleName, JsonObject config, int instances, Handler<AsyncResult<ActiveNetwork>> doneHandler) {
    ModuleConfig module = network.addModule(name, moduleName, config, instances);
    cluster.deployNetwork(network, doneHandler);
    return module;
  }
View Full Code Here

  @Override
  public ModuleConfig removeModule(String name, final Handler<AsyncResult<ActiveNetwork>> doneHandler) {
    // Undeploy a single module by creating a copy of the network with the
    // module as its only element. When then network is undeployed, the module
    // will be removed from the network.
    ModuleConfig module = network.removeModule(name);
    NetworkConfig undeploy = new DefaultNetworkConfig(network.getName());
    undeploy.addModule(module);
    cluster.undeployNetwork(undeploy, new Handler<AsyncResult<Void>>() {
      @Override
      public void handle(AsyncResult<Void> result) {
View Full Code Here

TOP

Related Classes of net.kuujo.vertigo.component.ModuleConfig

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.