當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。