Java 类io.vertx.core.spi.cluster.ClusterManager 实例源码

项目:vertx-zero    文件:ZeroLauncher.java   
private void startCluster(final ClusterManager manager,
                          final Consumer<Vertx> consumer) {
    Motor.each((name, option) -> {
        Vertx.clusteredVertx(option, clustered -> {
            // 1. Async clustered vertx initialized
            final Vertx vertx = clustered.result();
            // 2. Codecs
            Motor.codec(vertx.eventBus());
            // 3. Cluster connect
            manager.setVertx(vertx);
            // Finalized
            VERTX.putIfAbsent(name, vertx);

            consumer.accept(vertx);
        });
    });
}
项目:vertx-zero    文件:Motor.java   
public static <T> void start(
        final Class<?> clazz,
        final Consumer<T> consumer,
        final Consumer<Consumer<T>> fnSingle,
        final BiConsumer<ClusterManager, Consumer<T>> fnCluster,
        final Annal logger) {
    if (null == consumer) {
        throw new VertxCallbackException(clazz);
    }
    // 1. Check if clustered mode
    final ClusterOptions cluster = ZeroGrid.getClusterOption();
    if (cluster.isEnabled()) {
        // 2.1. Clustered
        final ClusterManager manager = cluster.getManager();
        logger.info(Info.APP_CLUSTERD, manager.getClass().getName(),
                manager.getNodeID(), manager.isActive());
        fnCluster.accept(manager, consumer);
    } else {
        // 2.2. Standalone
        fnSingle.accept(consumer);
    }
}
项目:vertx-zero    文件:ClusterOptionsConverter.java   
static void fromJson(final JsonObject json, final ClusterOptions obj) {
    if (json.getValue("enabled") instanceof Boolean) {
        obj.setEnabled(json.getBoolean("enabled"));
    }
    if (json.getValue("options") instanceof JsonObject) {
        obj.setOptions(json.getJsonObject("options"));
    }
    final Object managerObj = json.getValue("manager");
    Fn.safeNull(() -> {
        final Class<?> clazz = Instance.clazz(managerObj.toString());
        Fn.safeNull(() -> {
            // If null, keep default
            final ClusterManager manager = Instance.instance(clazz);
            obj.setManager(manager);
        }, clazz);
    }, managerObj);
}
项目:puppy-io    文件:PuppyAppLauncher.java   
private void initVerticle(Handler<Object> handler){
    //start vert.x
    ClusterManager mgr = new HazelcastClusterManager();

    VertxOptions options = new VertxOptions().setClusterManager(mgr);
    options.setWorkerPoolSize(1000);

    Vertx.clusteredVertx(options, res -> {
      if (res.succeeded()) {

          vertx = res.result();
          vertx.eventBus().registerDefaultCodec(MessageBody.class, new MessageBodyCodec());

          AppConfig appConfig = context.getBean(AppConfig.class);
          appConfig.setVertx(vertx);
          appConfig.setAppClass(appClass);
          appConfig.setAppName(appName);

          handler.handle(1);
      } else {
          logger.error("fail clusteredVertx");
      }
    });
}
项目:incubator-tamaya    文件:DisplayManager.java   
public DisplayManager(){
    LOG.info("\n-----------------------------------\n" +
            "Starting DisplayDisplayManager...\n" +
            "-----------------------------------");
    LOG.info("--- Starting Vertx cluster...");
    // Reusing the hazelcast instance already in place for vertx...
    ClusterManager mgr = new HazelcastClusterManager(
            hazelCastPropertySource.getHazelcastInstance());
    VertxOptions vertxOptions = new VertxOptions().setClusterManager(mgr);
    Vertx.clusteredVertx(vertxOptions, h -> {
        vertx = h.result();
    });
    LOG.info("--- Waiting for Vertx cluster...");
    while(vertx==null){
        try {
            Thread.sleep(100L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    monitorField.getStyleClass().add("monitor");
    configField.getStyleClass().add("config");
}
项目:vertx-hazelcast    文件:Examples.java   
public void example2() {

    Config hazelcastConfig = new Config();

    // Now set some stuff on the config (omitted)

    ClusterManager mgr = new HazelcastClusterManager(hazelcastConfig);

    VertxOptions options = new VertxOptions().setClusterManager(mgr);

    Vertx.clusteredVertx(options, res -> {
      if (res.succeeded()) {
        Vertx vertx = res.result();
      } else {
        // failed!
      }
    });
  }
项目:vertx-zero    文件:ZeroLauncher.java   
private void startCluster(final ClusterManager manager,
                          final Consumer<Vertx> consumer) {
    Motor.each((name, option) -> {
        // Set cluster manager
        option.setClusterManager(manager);

        final Single<Vertx> observable = Vertx.rxClusteredVertx(option);
        observable.subscribe(vertx -> {
            Motor.codec(vertx.eventBus().getDelegate());
            // Finalized
            VERTX.putIfAbsent(name, vertx);
            consumer.accept(vertx);
        });
    });
}
项目:Karaf-Vertx    文件:VertxHazelcastClusterMngrFactory.java   
@Activate
public void start(BundleContext bundleContext) {
    this.bc = bundleContext;
    LOGGER.info("Starting VertxHazelcastClusterMngrFactory ... registering ClusterManager as service.");
    ClusterManager mgr = new HazelcastClusterManager(hazelcastInstance);
    clusterManagerService = bc.registerService(ClusterManager.class, mgr, null);
}
项目:vertx-ignite    文件:Examples.java   
public void example1() {
  ClusterManager clusterManager = new IgniteClusterManager();

  VertxOptions options = new VertxOptions().setClusterManager(clusterManager);
  Vertx.clusteredVertx(options, res -> {
    if (res.succeeded()) {
      Vertx vertx = res.result();
    } else {
      // failed!
    }
  });
}
项目:vertx-ignite    文件:Examples.java   
public void example2() {
  IgniteConfiguration cfg = new IgniteConfiguration();
  // Configuration code (omitted)

  ClusterManager clusterManager = new IgniteClusterManager(cfg);

  VertxOptions options = new VertxOptions().setClusterManager(clusterManager);
  Vertx.clusteredVertx(options, res -> {
    if (res.succeeded()) {
      Vertx vertx = res.result();
    } else {
      // failed!
    }
  });
}
项目:vertx-ignite    文件:Examples.java   
public void example3(Ignite ignite) {
  // Configuration code (omitted)

  ClusterManager clusterManager = new IgniteClusterManager(ignite);

  VertxOptions options = new VertxOptions().setClusterManager(clusterManager);
  Vertx.clusteredVertx(options, res -> {
    if (res.succeeded()) {
      Vertx vertx = res.result();
    } else {
      // failed!
    }
  });
}
项目:vertx-infinispan    文件:Examples.java   
public void createClusterManagerProgramatically() {
  ClusterManager mgr = new InfinispanClusterManager();

  VertxOptions options = new VertxOptions().setClusterManager(mgr);

  Vertx.clusteredVertx(options, res -> {
    if (res.succeeded()) {
      Vertx vertx = res.result();
    } else {
      // failed!
    }
  });
}
项目:vertx-infinispan    文件:Examples.java   
public void useExistingCacheManager(DefaultCacheManager cacheManager) {
  ClusterManager mgr = new InfinispanClusterManager(cacheManager);

  VertxOptions options = new VertxOptions().setClusterManager(mgr);

  Vertx.clusteredVertx(options, res -> {
    if (res.succeeded()) {
      Vertx vertx = res.result();
    } else {
      // failed!
    }
  });
}
项目:vertx-discovery-service    文件:ExtendedAsyncMapImpl.java   
public ExtendedAsyncMapImpl(Vertx vertx, String name) {
  this.vertx = vertx;
  ClusterManager clusterManager = ((VertxInternal) vertx).getClusterManager();
  if (clusterManager == null) {
    syncMap = new ConcurrentHashMap<>();
  } else {
    syncMap = clusterManager.getSyncMap(name);
  }
}
项目:runrightfast-vertx    文件:VertxServiceImpl.java   
private void logVertxOptions() {
    LOG.logp(CONFIG, getClass().getName(), "logVertxOptions", () -> {
        final JsonObject json = new JsonObject()
                .put("BlockedThreadCheckInterval", vertxOptions.getBlockedThreadCheckInterval())
                .put("ClusterHost", vertxOptions.getClusterHost())
                .put("ClusterPingInterval", vertxOptions.getClusterPingInterval())
                .put("ClusterPingReplyInterval", vertxOptions.getClusterPingReplyInterval())
                .put("ClusterPort", vertxOptions.getClusterPort())
                .put("EventLoopPoolSize", vertxOptions.getEventLoopPoolSize())
                .put("HAGroup", vertxOptions.getHAGroup())
                .put("InternalBlockingPoolSize", vertxOptions.getInternalBlockingPoolSize())
                .put("MaxEventLoopExecuteTime", vertxOptions.getMaxEventLoopExecuteTime())
                .put("MaxWorkerExecuteTime", vertxOptions.getMaxWorkerExecuteTime())
                .put("QuorumSize", vertxOptions.getQuorumSize())
                .put("WarningExceptionTime", vertxOptions.getWarningExceptionTime())
                .put("WorkerPoolSize", vertxOptions.getWorkerPoolSize());

        final ClusterManager clusterManager = vertxOptions.getClusterManager();
        if (clusterManager != null) {
            json.put("clusterManagerClass", clusterManager.getClass().getName());
        }

        final MetricsOptions metricsOptions = vertxOptions.getMetricsOptions();
        if (metricsOptions != null) {
            json.put("MetricsOptions", toJsonObject(metricsOptions));
        }
        return json.encodePrettily();
    });
}
项目:runrightfast-vertx    文件:VertxServiceImpl.java   
@Override
public Optional<HazelcastInstance> getHazelcastInstance() {
    if (!this.vertx.isClustered()) {
        return Optional.empty();
    }

    final ClusterManager clusterManager = this.vertxOptions.getClusterManager();
    if (clusterManager != null && clusterManager instanceof HazelcastClusterManager) {
        return Optional.of(((HazelcastClusterManager) clusterManager).getHazelcastInstance());
    }

    return Optional.empty();
}
项目:vertx-jgroups    文件:Examples.java   
public void example1() {
  ClusterManager mgr = new JGroupsClusterManager();
  VertxOptions options = new VertxOptions().setClusterManager(mgr);
  Vertx.clusteredVertx(options, res -> {
    if (res.succeeded()) {
      Vertx vertx = res.result();
    } else {
      // failed!
    }
  });
}
项目:vertx-jgroups    文件:Examples.java   
public void example2(JChannel channel) {
  ClusterManager mgr = new JGroupsClusterManager(channel);
  VertxOptions options = new VertxOptions().setClusterManager(mgr);
  Vertx.clusteredVertx(options, res -> {
    if (res.succeeded()) {
      Vertx vertx = res.result();
    } else {
      // failed!
    }
  });

  // Don't forget to close the channel when done.
}
项目:wxvertx    文件:Launcher.java   
public static void main(String[] args) {
    ClusterManager clusterManager = new HazelcastClusterManager();
    VertxOptions vertxOptions = new VertxOptions().setClusterManager(clusterManager);
    Vertx.clusteredVertx(vertxOptions, res -> {
        if(res.succeeded()) {
            vertx = res.result();

            initRouter();
            addVerticle();
        }else {
            throw new RuntimeException("Vert.x Init Error");
        }
    });
}
项目:incubator-tamaya    文件:Display.java   
public Display(){
    LOG.info("\n-----------------------------------\n" +
            "Starting Display...\n" +
            "-----------------------------------");
    LOG.info("--- Starting Vertx cluster...");
    // Reusing the hazelcast instance already in place for vertx...
    ClusterManager mgr = new HazelcastClusterManager(
            hazelCastPropertySource.getHazelcastInstance());
    VertxOptions vertxOptions = new VertxOptions().setClusterManager(mgr);
    Vertx.clusteredVertx(vertxOptions, h -> {
        vertx = h.result();
    });
    LOG.info("--- Waiting for Vertx cluster...");
    while(vertx==null){
        try {
            Thread.sleep(100L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    titleField.getStyleClass().add("title");
    contentField.getStyleClass().add("content");
    monitorField.getStyleClass().add("monitor");
    titleField.setId("title");
    titleField.setEditable(false);
    contentField.setId("scene");
    contentField.setEditable(false);
}
项目:vertx-hazelcast    文件:Examples.java   
public void example1() {

    ClusterManager mgr = new HazelcastClusterManager();

    VertxOptions options = new VertxOptions().setClusterManager(mgr);

    Vertx.clusteredVertx(options, res -> {
      if (res.succeeded()) {
        Vertx vertx = res.result();
      } else {
        // failed!
      }
    });
  }
项目:vertx-hazelcast    文件:Examples.java   
public void example3(HazelcastInstance hazelcastInstance) {
  ClusterManager mgr = new HazelcastClusterManager(hazelcastInstance);
  VertxOptions options = new VertxOptions().setClusterManager(mgr);
  Vertx.clusteredVertx(options, res -> {
    if (res.succeeded()) {
      Vertx vertx = res.result();
    } else {
      // failed!
    }
  });
}
项目:vertx-spring    文件:VertxConfiguration.java   
@Bean
public SpringVertx vertx(
        ObjectProvider<VertxOptions> optionsProvider,
        ObjectProvider<ClusterManager> clusterManagerProvider,
        ObjectProvider<List<VertxListener>> listenersProvider,
        ObjectProvider<List<VertxConfigurer>> configurersProvider) {

    SpringVertx.Builder builder = SpringVertx.builder();

    List<VertxConfigurer> configurers = new ArrayList<>();

    ClusterManager clusterManager = clusterManagerProvider.getIfAvailable();
    if (clusterManager != null) {
        configurers.add(new ClusterManagerConfigurer(clusterManager));
    }

    List<VertxListener> listeners = listenersProvider.getIfAvailable();
    if (listeners != null) {
        for (VertxListener listener : listeners) {
            builder.listener(listener);
        }
    }

    List<VertxConfigurer> injectedConfigurers = configurersProvider.getIfAvailable();
    if (injectedConfigurers != null) {
        configurers.addAll(injectedConfigurers);
    }

    if (!configurers.isEmpty()) {
        List<VertxConfigurer> sortedConfigurers = new ArrayList<>(configurers);
        AnnotationAwareOrderComparator.sort(sortedConfigurers);
        for (VertxConfigurer configurer : sortedConfigurers) {
            logger.debug("Applying configurer: {}", configurer);
            configurer.configure(builder);
        }
    }

    // If we have a VertxOptions bean, it will replace all the options possibly gathered by configurers,
    // so make sure to call it last
    VertxOptions options = optionsProvider.getIfAvailable();
    if (options != null) {
        builder.options(options);
    }

    return builder.build();
}
项目:vertx-spring    文件:VertxConfiguration.java   
public ClusterManagerConfigurer(ClusterManager clusterManager) {
    this.clusterManager = clusterManager;
}
项目:vertx-zero    文件:VertxTestBase.java   
protected ClusterManager getClusterManager() {
    return null;
}
项目:vertx-zero    文件:ClusterOptions.java   
public ClusterManager getManager() {
    return this.manager;
}
项目:vertx-zero    文件:ClusterOptions.java   
public ClusterOptions setManager(final ClusterManager manager) {
    this.manager = manager;
    return this;
}
项目:Karaf-Vertx    文件:VertxService.java   
public void bindClusterManager(ClusterManager clusterManager) {
    this.clusterManager = clusterManager;
    deregisterVertx();
    createAndRegisterVertx();
}
项目:Karaf-Vertx    文件:VertxService.java   
public void unbindClusterManager(ClusterManager clusterManager) {
    this.clusterManager = null;
    deregisterVertx();
    createAndRegisterVertx();
}
项目:okapi    文件:DiscoveryManager.java   
public void setClusterManager(ClusterManager mgr) {
  this.clusterManager = mgr;
  mgr.nodeListener(this);
}
项目:okapi    文件:MainVerticle.java   
public void setClusterManager(ClusterManager mgr) {
  clusterManager = mgr;
}
项目:vertx-ignite    文件:IgniteClusteredSharedCounterTest.java   
@Override
protected ClusterManager getClusterManager() {
  return new IgniteClusterManager();
}
项目:vertx-ignite    文件:IgniteComplexHATest.java   
@Override
protected ClusterManager getClusterManager() {
  return new IgniteClusterManager();
}
项目:vertx-ignite    文件:IgniteClusteredEventbusTest.java   
@Override
protected ClusterManager getClusterManager() {
  return new IgniteClusterManager();
}
项目:vertx-ignite    文件:IgniteClusteredAsyncMapTest.java   
@Override
protected ClusterManager getClusterManager() {
  return new IgniteClusterManager();
}
项目:vertx-ignite    文件:IgniteAsyncMultiMapTest.java   
@Override
protected ClusterManager getClusterManager() {
  return new IgniteClusterManager();
}
项目:vertx-ignite    文件:IgniteClusterFaultToleranceTest.java   
@Override
protected ClusterManager getClusterManager() {
  return new IgniteClusterManager();
}
项目:vertx-ignite    文件:IgniteHATest.java   
@Override
protected ClusterManager getClusterManager() {
  return new IgniteClusterManager();
}
项目:vertx-ignite    文件:IgnitesClusteredAsynchronousLockTest.java   
@Override
protected ClusterManager getClusterManager() {
  return new IgniteClusterManager();
}
项目:vertx-ignite    文件:IgniteClusteredSessionHandlerTest.java   
@Override
protected ClusterManager getClusterManager() {
  return new IgniteClusterManager();
}