Package net.kuujo.vertigo

Examples of net.kuujo.vertigo.Vertigo


    JsonObject jsonConnection = new JsonObject()
        .putObject("source", new JsonObject().putString("component", "foo").putString("port", "notout"))
        .putObject("target", new JsonObject().putString("component", "bar").putString("port", "notin"))
        .putObject("grouping", new JsonObject().putString("type", "random"));
    json.putArray("connections", new JsonArray().add(jsonConnection));
    NetworkConfig network = new Vertigo(null, null).createNetwork(json);
    assertEquals("test", network.getName());
    ConnectionConfig connection = network.getConnections().iterator().next();
    assertEquals("foo", connection.getSource().getComponent());
    assertEquals("notout", connection.getSource().getPort());
    assertEquals("bar", connection.getTarget().getComponent());
View Full Code Here


  }

  @Override
  public void start(final Future<Void> startResult) {
    final Vertigo vertigo = new Vertigo(this);
    vertigo.deployCluster("default", new Handler<AsyncResult<Cluster>>() {
      @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>>() {
View Full Code Here

    }
  }

  @Test
  public void testRandomWordFeeder() {
    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
View Full Code Here

    }
  }

  @Test
  public void testWordCounter() {
    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("counter", WordCountNetwork.WordCounter.class.getName());
        network.addVerticle("tester", CountTester.class.getName());
        network.createConnection("counter", "count", "tester", "in");
        network.createConnection("tester", "out", "counter", "word");
        result.result().deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
View Full Code Here

  public void start(final Future<Void> startResult) {
    // Deploy a "default" cluster. This will deploy a single node cluster.
    // If the current Vert.x instance is a Hazelcast clustered instance,
    // the cluster will coordinate through Hazelcast data structures,
    // otherwise the cluster will coordinate through Vert.x shared data.
    final Vertigo vertigo = new Vertigo(this);
    vertigo.deployCluster("default", new Handler<AsyncResult<Cluster>>() {
      public void handle(AsyncResult<Cluster> result) {
        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");
View Full Code Here

    context = component.context();
    cluster = component.cluster();
    logger = component.logger();
    input = component.input();
    output = component.output();
    vertigo = new Vertigo(this);
    log = LoggerFactory.getLogger(String.format("%s-%s", getClass().getCanonicalName(), context.address()));

    log.info(String.format("%s - Starting", component));
    component.start(new Handler<AsyncResult<Void>>() {
      @Override
View Full Code Here

    }
  }

  @Test
  public void testPortFeeder() {
    final Vertigo vertigo = new Vertigo(this);
    vertigo.deployCluster(new Handler<AsyncResult<Cluster>>() {
      @Override
      public void handle(AsyncResult<Cluster> result) {
        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>>() {
View Full Code Here

    }
  }

  @Test
  public void testSendFile() {
    final Vertigo vertigo = new Vertigo(this);
    vertigo.deployCluster(new Handler<AsyncResult<Cluster>>() {
      @Override
      public void handle(AsyncResult<Cluster> result) {
        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>>() {
View Full Code Here

*/
public class AsyncCounterTest extends TestVerticle {

  @Test
  public void testCounterIncrement() {
    Vertigo vertigo = new Vertigo(this);
    vertigo.deployCluster("test", new Handler<AsyncResult<Cluster>>() {
      @Override
      public void handle(AsyncResult<Cluster> result) {
        assertTrue(result.succeeded());
        final Cluster cluster = new DefaultCluster("test", vertx, container);
        final AsyncCounter data = cluster.getCounter("test-counter-increment");
View Full Code Here

    });
  }

  @Test
  public void testCounterDecrement() {
    Vertigo vertigo = new Vertigo(this);
    vertigo.deployCluster("test", new Handler<AsyncResult<Cluster>>() {
      @Override
      public void handle(AsyncResult<Cluster> result) {
        assertTrue(result.succeeded());
        final Cluster cluster = new DefaultCluster("test", vertx, container);
        final AsyncCounter data = cluster.getCounter("test-counter-decrement");
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.