本文整理汇总了Java中io.vertx.core.spi.cluster.ClusterManager类的典型用法代码示例。如果您正苦于以下问题:Java ClusterManager类的具体用法?Java ClusterManager怎么用?Java ClusterManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClusterManager类属于io.vertx.core.spi.cluster包,在下文中一共展示了ClusterManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startCluster
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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);
});
});
}
示例2: start
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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);
}
}
示例3: fromJson
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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);
}
示例4: initVerticle
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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");
}
});
}
示例5: DisplayManager
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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");
}
示例6: example2
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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!
}
});
}
示例7: startCluster
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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);
});
});
}
示例8: start
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
@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);
}
示例9: example1
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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!
}
});
}
示例10: example2
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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!
}
});
}
示例11: example3
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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!
}
});
}
示例12: createClusterManagerProgramatically
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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!
}
});
}
示例13: useExistingCacheManager
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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!
}
});
}
示例14: ExtendedAsyncMapImpl
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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);
}
}
示例15: logVertxOptions
import io.vertx.core.spi.cluster.ClusterManager; //导入依赖的package包/类
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();
});
}