Package net.kuujo.vertigo

Examples of net.kuujo.vertigo.Vertigo


    }
  }

  @Test
  public void testIOReceiveHook() {
    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();
        network.addComponent("sender", TestSimpleSender.class.getName());
        network.addComponent("receiver", TestSimpleReceiver.class.getName());

        // The IO hook is added directly to a connection between two components.
        network.createConnection("sender", "out", "receiver", "in").addHook(new TestIOReceiveHook());
View Full Code Here


    }
  }

  @Test
  public void testComponentStartHook() {
    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();

        // The start hook is added directly to a component configuration.
        network.addComponent("sender", TestSimpleSender.class.getName()).addHook(new TestComponentStartHook());
        network.addComponent("receiver", TestSimpleReceiver.class.getName());
        network.createConnection("sender", "out", "receiver", "in");
View Full Code Here

    }
  }

  @Test
  public void testComponentSendHook() {
    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();

        // The component hook is added directly to a component configuration. The
        // send handler will be called each time a message is sent on *any* port.
        network.addComponent("sender", TestSimpleSender.class.getName()).addHook(new TestComponentSendHook());
        network.addComponent("receiver", TestSimpleReceiver.class.getName());
View Full Code Here

    }
  }

  @Test
  public void testComponentReceiveHook() {
    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();
        network.addComponent("sender", TestSimpleSender.class.getName());

        // The component hook is added directly to a component configuration. The
        // receive handler will be called each time a message is received on *any* port.
        network.addComponent("receiver", TestSimpleReceiver.class.getName()).addHook(new TestComponentReceiveHook());
View Full Code Here

    });
  }

  @Test
  public void testEventBusHookStart() {
    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();

        // Use the special EventBusHookListener to listen for messages
        // from the event bus hook. This will handle parsing event bus messages.
        final EventBusHookListener listener = new EventBusHookListener("test-hook", vertx.eventBus());
        listener.startHandler(new Handler<InstanceContext>() {
          @Override
          public void handle(InstanceContext context) {
            assertEquals("sender", context.component().name());
            testComplete();
          }
        });

        // The start() method simply registers an event bus handler for the hook.
        listener.start(new Handler<AsyncResult<Void>>() {
          @Override
          public void handle(AsyncResult<Void> result) {
            assertTrue(result.succeeded());

            NetworkConfig network = vertigo.createNetwork();
            network.addComponent("sender", TestSimpleSender.class.getName()).addHook(new EventBusHook("test-hook"));
            network.addComponent("receiver", TestSimpleReceiver.class.getName());
            network.createConnection("sender", "out", "receiver", "in");

            cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
View Full Code Here

    });
  }

  @Test
  public void testEventBusHookSend() {
    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();

        // Use the special EventBusHookListener to listen for messages
        // from the event bus hook. This will handle parsing event bus messages.
        final EventBusHookListener listener = new EventBusHookListener("test-hook", vertx.eventBus());
        listener.sendHandler(new Handler<String>() {
          @Override
          public void handle(String message) {
            assertEquals("Hello world!", message);
            testComplete();
          }
        });

        // The start() method simply registers an event bus handler for the hook.
        listener.start(new Handler<AsyncResult<Void>>() {
          @Override
          public void handle(AsyncResult<Void> result) {
            assertTrue(result.succeeded());

            NetworkConfig network = vertigo.createNetwork();
            network.addComponent("sender", TestSimpleSender.class.getName()).addHook(new EventBusHook("test-hook"));
            network.addComponent("receiver", TestSimpleReceiver.class.getName());
            network.createConnection("sender", "out", "receiver", "in");

            cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
View Full Code Here

    });
  }

  @Test
  public void testEventBusHookReceive() {
    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();

        // Use the special EventBusHookListener to listen for messages
        // from the event bus hook. This will handle parsing event bus messages.
        final EventBusHookListener listener = new EventBusHookListener("test-hook", vertx.eventBus());
        listener.receiveHandler(new Handler<String>() {
          @Override
          public void handle(String message) {
            assertEquals("Hello world!", message);
            testComplete();
          }
        });

        // The start() method simply registers an event bus handler for the hook.
        listener.start(new Handler<AsyncResult<Void>>() {
          @Override
          public void handle(AsyncResult<Void> result) {
            assertTrue(result.succeeded());

            NetworkConfig network = vertigo.createNetwork();
            network.addComponent("sender", TestSimpleSender.class.getName());
            network.addComponent("receiver", TestSimpleReceiver.class.getName()).addHook(new EventBusHook("test-hook"));
            network.createConnection("sender", "out", "receiver", "in");

            cluster.deployNetwork(network, new Handler<AsyncResult<ActiveNetwork>>() {
View Full Code Here

    }
  }

  @Test
  public void testDeploy() {
    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-deploy");
        network.addVerticle("feeder", TestFeeder.class.getName());
        network.addVerticle("worker1", TestWorker.class.getName(), 2);
        network.createConnection("feeder", "stream1", "worker", "stream1");
        network.createConnection("feeder", "stream2", "worker", "stream2");
View Full Code Here

    });
  }

  @Test
  public void testDeployFromJson() {
    final Vertigo vertigo = new Vertigo(this);
    vertigo.deployCluster(new Handler<AsyncResult<Cluster>>() {
      @Override
      public void handle(AsyncResult<Cluster> result) {
        assertTrue(result.succeeded());
        JsonObject network = new JsonObject()
            .putString("name", "test-deploy-from-json")
View Full Code Here

    });
  }

  @Test
  public void testUndeployByName() {
    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-undeploy-by-name");
        network.addVerticle("feeder", TestFeeder.class.getName());
        network.addVerticle("worker1", TestWorker.class.getName(), 2);
        network.createConnection("feeder", "stream1", "worker", "stream1");
        network.addVerticle("worker2", TestWorker.class.getName(), 2);
        network.createConnection("feeder", "stream2", "worker", "stream2");
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.