当前位置: 首页>>代码示例>>Java>>正文


Java VertxOptions.setClusterManager方法代码示例

本文整理汇总了Java中io.vertx.core.VertxOptions.setClusterManager方法的典型用法代码示例。如果您正苦于以下问题:Java VertxOptions.setClusterManager方法的具体用法?Java VertxOptions.setClusterManager怎么用?Java VertxOptions.setClusterManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vertx.core.VertxOptions的用法示例。


在下文中一共展示了VertxOptions.setClusterManager方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: vertx

import io.vertx.core.VertxOptions; //导入方法依赖的package包/类
/**
 * Vertx.
 *
 * @return the future vertx
 */
protected Future<Vertx> vertx() {

  VertxOptions options = new VertxOptions();
  options.setClustered(true);
  options.setClusterManager(clusterManager());

  return VertxBuilder.create().options(options).build().compose(vertx -> {
    vertx.deployVerticle(this);
  }, Future.succeededFuture());
}
 
开发者ID:jspare-projects,项目名称:vertx-jspare,代码行数:16,代码来源:VertxClusteredRunner.java

示例2: createClusteredVertx

import io.vertx.core.VertxOptions; //导入方法依赖的package包/类
/**
 * Create a clustered vert.x instance and block until the instance has been created.
 * 
 * @param options
 *            Mesh options
 * @param vertxOptions
 *            Vert.x options
 * @param hazelcast
 *            Hazelcast instance which should be used by vert.x
 */
private Vertx createClusteredVertx(MeshOptions options, VertxOptions vertxOptions, HazelcastInstance hazelcast) {
	Objects.requireNonNull(hazelcast, "The hazelcast instance was not yet initialized.");
	manager = new HazelcastClusterManager(hazelcast);
	vertxOptions.setClusterManager(manager);
	String localIp = options.getClusterOptions().getNetworkHost();
	vertxOptions.getEventBusOptions().setHost(localIp);
	vertxOptions.getEventBusOptions().setClusterPublicHost(localIp);
	vertxOptions.setClusterHost(localIp);
	vertxOptions.setClusterPublicHost(localIp);

	Integer clusterPort = options.getClusterOptions().getVertxPort();
	int vertxClusterPort = clusterPort == null ? 0 : clusterPort;
	vertxOptions.setClusterPort(vertxClusterPort);
	vertxOptions.setClusterPublicPort(vertxClusterPort);

	if (log.isDebugEnabled()) {
		log.debug("Using vert.x cluster port {" + vertxClusterPort + "}");
		log.debug("Using vert.x cluster public port {" + vertxClusterPort + "}");
		log.debug("Binding vert.x on host {" + localIp + "}");
	}
	CompletableFuture<Vertx> fut = new CompletableFuture<>();
	Vertx.clusteredVertx(vertxOptions, rh -> {
		log.info("Created clustered vert.x instance");
		if (rh.failed()) {
			Throwable cause = rh.cause();
			log.error("Failed to create clustered vert.x instance", cause);
			fut.completeExceptionally(new RuntimeException("Error while creating clusterd vert.x instance", cause));
			return;
		}
		Vertx vertx = rh.result();
		fut.complete(vertx);
	});
	try {
		return fut.get(10, SECONDS);
	} catch (Exception e) {
		throw new RuntimeException("Error while creating clusterd vert.x instance");
	}

}
 
开发者ID:gentics,项目名称:mesh,代码行数:50,代码来源:BootstrapInitializerImpl.java

示例3: createAndRegisterVertx

import io.vertx.core.VertxOptions; //导入方法依赖的package包/类
private void createAndRegisterVertx() {
    VertxOptions options = new VertxOptions().setMetricsOptions(new DropwizardMetricsOptions()
            .setJmxEnabled(true)
            .setJmxDomain("vertx-metrics")
            .setRegistryName("vertx-karaf-registry")
            .setFactory(metrxFactory)
        );
            
    if (cfg.getWorkerPoolSize() > 0) {
        options.setWorkerPoolSize(cfg.getWorkerPoolSize());
    }
    
    if (cfg.getEventLoopPoolSize() > 0) {
        options.setEventLoopPoolSize(cfg.getEventLoopPoolSize());
    }
    
    if (cfg.getHAEnabled()) {
        options.setHAEnabled(cfg.getHAEnabled());
        if (cfg.getHAGroup() != null && !cfg.getHAGroup().isEmpty()) {
            options.setHAGroup(cfg.getHAGroup());
        }
    }
    
    if (clusterManager != null) {
        LOGGER.info("Starting vertx with cluster manager");
        options.setClusterManager(clusterManager);
    }

    try {
        vertx = executeWithTCCLSwitch(() -> Vertx.vertx(options));
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Error while creating vertx system", e);
        return;
    }
    
    vertxRegistration = bundleContext.registerService(Vertx.class, vertx, null);
    LOGGER.info("Vert.x service registered");
    ebRegistration = bundleContext.registerService(EventBus.class, vertx.eventBus(), null);
    LOGGER.info("Vert.x Event Bus service registered");
    registry = SharedMetricRegistries.getOrCreate("vertx-karaf-registry");
    metricsRegistration = bundleContext.registerService(MetricRegistry.class, registry, null);
    LOGGER.info("Vert.x MetricsService service registered");
    MetricsService metricsService = MetricsService.create(vertx);
    metricsServiceRegistration = bundleContext.registerService(MetricsService.class, metricsService, null);
}
 
开发者ID:ANierbeck,项目名称:Karaf-Vertx,代码行数:46,代码来源:VertxService.java


注:本文中的io.vertx.core.VertxOptions.setClusterManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。