Package net.kuujo.vertigo.network

Examples of net.kuujo.vertigo.network.NetworkContext


    final Vertigo vertigo = new Vertigo(this);
    vertigo.deployCluster("vertigo", new Handler<AsyncResult<Cluster>>() {
      @Override
      public void handle(AsyncResult<Cluster> result) {
        assertTrue(result.succeeded());
        final NetworkContext context = DefaultNetworkContext.Builder.newBuilder()
            .setName("test-coordinator-resume")
            .setAddress("test")
            .setStatusAddress("test.__status")
            .setCluster("test")
            .addComponent(DefaultVerticleContext.Builder.newBuilder()
                .setName("test")
                .setAddress("test.test")
                .setStatusAddress("test.test.__status")
                .addInstance(DefaultInstanceContext.Builder.newBuilder()
                    .setAddress("test.test-1")
                    .setStatusAddress("test.test-1.__status")
                    .setInput(DefaultInputContext.Builder.newBuilder().build())
                    .setOutput(DefaultOutputContext.Builder.newBuilder().build()).build()).build()).build();
        final InstanceContext instance = context.component("test").instances().iterator().next();

        final Cluster cluster = new DefaultCluster("vertigo", vertx, container);
        final WatchableAsyncMap<String, String> data = new WrappedWatchableAsyncMap<String, String>(cluster.<String, String>getMap("test"), vertx);

        data.put(instance.address(), Contexts.serialize(instance).encode(), new Handler<AsyncResult<String>>() {
          @Override
          public void handle(AsyncResult<String> result) {
            if (result.failed()) {
              fail(result.cause().getMessage());
            } else {
              final ComponentCoordinator coordinator = new DefaultComponentCoordinator(instance, vertx, new DefaultCluster("vertigo", vertx, container));
              coordinator.start(new Handler<AsyncResult<Void>>() {
                @Override
                public void handle(AsyncResult<Void> result) {
                  if (result.failed()) {
                    fail(result.cause().getMessage());
                  } else {
                    coordinator.resumeHandler(new Handler<Void>() {
                      @Override
                      public void handle(Void _) {
                        testComplete();
                      }
                    });
                    data.remove(context.status(), new Handler<AsyncResult<String>>() {
                      @Override
                      public void handle(AsyncResult<String> result) {
                        if (result.failed()) {
                          fail(result.cause().getMessage());
                        } else {
                          data.put(context.status(), "ready");
                        }
                      }
                    });
                  }
                }
              });
              data.put(context.status(), "ready");
            }
          }
        });
      }
    });
View Full Code Here

TOP

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

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.