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


Java HazelcastClusterManager类代码示例

本文整理汇总了Java中io.vertx.spi.cluster.hazelcast.HazelcastClusterManager的典型用法代码示例。如果您正苦于以下问题:Java HazelcastClusterManager类的具体用法?Java HazelcastClusterManager怎么用?Java HazelcastClusterManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HazelcastClusterManager类属于io.vertx.spi.cluster.hazelcast包,在下文中一共展示了HazelcastClusterManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldFireSessionExpiredEventForHazelcastSessionStore

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的package包/类
@Test(timeout = 15000L)
public void shouldFireSessionExpiredEventForHazelcastSessionStore(TestContext context) {
    Async async = context.async();
    Vertx.clusteredVertx(new VertxOptions().setClusterManager(new HazelcastClusterManager()), res -> {

        vertx = res.result();
        SessionStore adapted = SessionStoreAdapter.adapt(vertx, ClusteredSessionStore.create(vertx));
        Session session = adapted.createSession(2000);

        sessionExpiredConsumer = SessionStoreAdapter.sessionExpiredHandler(vertx, event -> {
            context.assertEquals(session.id(), event.body());
            async.countDown();
        });
        adapted.put(session, Future.<Boolean>future().completer());
        session.put("a", "b");

    });

}
 
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:20,代码来源:SessionStoreAdapterUT.java

示例2: initVerticle

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的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");
	  }
	});
}
 
开发者ID:quebic-source,项目名称:puppy-io,代码行数:25,代码来源:PuppyAppLauncher.java

示例3: DisplayManager

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的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");
}
 
开发者ID:apache,项目名称:incubator-tamaya,代码行数:24,代码来源:DisplayManager.java

示例4: example2

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的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!
      }
    });
  }
 
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:19,代码来源:Examples.java

示例5: start

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的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);
}
 
开发者ID:ANierbeck,项目名称:Karaf-Vertx,代码行数:8,代码来源:VertxHazelcastClusterMngrFactory.java

示例6: createClusteredVertx

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的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

示例7: configureClusterManager

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的package包/类
/**
 * The Hazelcast instance name will always start with "vertx". If an instance-name is specified, it will be appended to "vertx/", e.g., vertx/instance-name
 */
private void configureClusterManager() {
    ConfigUtils.getConfig(config, "VertxOptions", "clusterManager", "hazelcast").map(c -> {
        final String hazelcastInstanceName = ConfigUtils.getString(c, "instance-name")
                .map(name -> String.format("%s/%s", VERTX_HAZELCAST_INSTANCE_ID, name))
                .orElse(VERTX_HAZELCAST_INSTANCE_ID);

        final com.hazelcast.config.Config hazelcastConfig = hazelcastConfigFactory(hazelcastInstanceName).apply(c.withFallback(config));
        return new HazelcastClusterManager(hazelcastConfig);
    }).ifPresent(vertxOptions::setClusterManager);
}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:14,代码来源:VertxServiceImpl.java

示例8: getHazelcastInstance

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的package包/类
@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();
}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:14,代码来源:VertxServiceImpl.java

示例9: main

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的package包/类
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");
        }
    });
}
 
开发者ID:zhongzhaoyl,项目名称:wxvertx,代码行数:15,代码来源:Launcher.java

示例10: Display

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-tamaya,代码行数:29,代码来源:Display.java

示例11: example1

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的package包/类
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!
      }
    });
  }
 
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:15,代码来源:Examples.java

示例12: example3

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的package包/类
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!
    }
  });
}
 
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:12,代码来源:Examples.java

示例13: testProgrammatic

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的package包/类
private void testProgrammatic(HazelcastClusterManager mgr, Config config) throws Exception {
  mgr.setConfig(config);
  assertEquals(config, mgr.getConfig());
  VertxOptions options = new VertxOptions().setClusterManager(mgr).setClustered(true);
  Vertx.clusteredVertx(options, res -> {
    assertTrue(res.succeeded());
    assertNotNull(mgr.getHazelcastInstance());
    res.result().close(res2 -> {
      assertTrue(res2.succeeded());
      testComplete();
    });
  });
  await();
}
 
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:15,代码来源:ProgrammaticHazelcastClusterManagerTest.java

示例14: testProgrammaticSetConfig

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的package包/类
@Test
public void testProgrammaticSetConfig() throws Exception {
  Config config = new Config();
  HazelcastClusterManager mgr = new HazelcastClusterManager();
  mgr.setConfig(config);
  testProgrammatic(mgr, config);
}
 
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:8,代码来源:ProgrammaticHazelcastClusterManagerTest.java

示例15: hazelcastClusterManager

import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; //导入依赖的package包/类
@Bean
public HazelcastClusterManager hazelcastClusterManager(HazelcastInstance hazelcastInstance) {
    return new HazelcastClusterManager(hazelcastInstance);
}
 
开发者ID:unbroken-dome,项目名称:vertx-spring,代码行数:5,代码来源:HazelcastClusterManagerConfiguration.java


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