本文整理汇总了Java中com.hazelcast.core.Hazelcast.newHazelcastInstance方法的典型用法代码示例。如果您正苦于以下问题:Java Hazelcast.newHazelcastInstance方法的具体用法?Java Hazelcast.newHazelcastInstance怎么用?Java Hazelcast.newHazelcastInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.core.Hazelcast
的用法示例。
在下文中一共展示了Hazelcast.newHazelcastInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
public static void main(String[] args) {
Config cfg = new Config();
HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg);
Map<Integer, String> mapCustomers = instance.getMap("customers");
mapCustomers.put(1, "Joe");
mapCustomers.put(2, "Ali");
mapCustomers.put(3, "Avi");
System.out.println("Customer with key 1: "+ mapCustomers.get(1));
System.out.println("Map Size:" + mapCustomers.size());
Queue<String> queueCustomers = instance.getQueue("customers");
queueCustomers.offer("Tom");
queueCustomers.offer("Mary");
queueCustomers.offer("Jane");
System.out.println("First customer: " + queueCustomers.poll());
System.out.println("Second customer: "+ queueCustomers.peek());
System.out.println("Queue size: " + queueCustomers.size());
}
示例2: tenantConfigurationHazelcast
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
@Bean(TENANT_CONFIGURATION_HAZELCAST)
public HazelcastInstance tenantConfigurationHazelcast() throws IOException {
log.info("{}", appProps.getHazelcast());
Properties props = new Properties();
props.putAll(appProps.getHazelcast());
props.put(HAZELCAST_LOCAL_LOCAL_ADDRESS, InetUtils.getFirstNonLoopbackHostInfo().getIpAddress());
String hazelcastConfigUrl = appProps.getHazelcast().get(HAZELCAST_CONFIG_URL_PROPERTY);
InputStream in = context.getResource(hazelcastConfigUrl).getInputStream();
Config config = new XmlConfigBuilder(in).setProperties(props).build();
config.getNetworkConfig().setInterfaces(buildInterfaces(appProps.getHazelcast().get(INTERFACES)));
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
return hazelcastInstance;
}
示例3: hazelcastInstance
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
@Bean
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
log.debug("Configuring Hazelcast");
HazelcastInstance hazelCastInstance = Hazelcast.getHazelcastInstanceByName("balance");
if (hazelCastInstance != null) {
log.debug("Hazelcast already initialized");
return hazelCastInstance;
}
Config config = new Config();
config.setInstanceName("balance");
config.getNetworkConfig().setPort(5701);
config.getNetworkConfig().setPortAutoIncrement(true);
// In development, remove multicast auto-configuration
if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
System.setProperty("hazelcast.local.localAddress", "127.0.0.1");
config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);
}
config.getMapConfigs().put("default", initializeDefaultMapConfig());
config.getMapConfigs().put("com.icthh.xm.ms.balance.domain.*", initializeDomainMapConfig(jHipsterProperties));
return Hazelcast.newHazelcastInstance(config);
}
示例4: runServer
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
void runServer(boolean autoShutDown, String port) throws Exception {
server = new Server("localhost",
Integer.parseInt(port),
"", null, ChatServer.class);
server.start();
HZ = Hazelcast.newHazelcastInstance();
if (autoShutDown) {
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
stop();
System.out.println("Stopped WebSocket server & HZ");
}
}));
System.out.print("Shutdown hook added");
}
started = true;
}
开发者ID:abhirockzz,项目名称:scalable-websocket-chat-with-hazelcast,代码行数:25,代码来源:WebSocketServerManager.java
示例5: executeSchemaChange
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
/**
* Main method for executing the schema conversion to Hazelcast.
* The method just needs to be called statically as it operates on files created during the initial
* schema conversion process.
*/
public static void executeSchemaChange() {
Config cfg = new Config();
HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg);
mapNodes = instance.getMap("nodes");
mapEdges = instance.getMap("edges");
mapLabels = instance.getMap("labels");
mapOut = instance.getMap("out");
mapIn = instance.getMap("in");
nodesMap();
edgesMap();
exampleQueries();
}
示例6: hazelcastInstance
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
@Bean
@Primary
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
log.debug("Configuring Hazelcast");
HazelcastInstance hazelCastInstance = Hazelcast.getHazelcastInstanceByName("dashboard");
if (hazelCastInstance != null) {
log.debug("Hazelcast already initialized");
return hazelCastInstance;
}
Config config = new Config();
config.setInstanceName("dashboard");
config.getNetworkConfig().setPort(5701);
config.getNetworkConfig().setPortAutoIncrement(true);
// In development, remove multicast auto-configuration
if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
System.setProperty("hazelcast.local.localAddress", "127.0.0.1");
config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);
}
config.getMapConfigs().put("default", initializeDefaultMapConfig());
config.getMapConfigs().put("com.icthh.xm.ms.dashboard.domain.*", initializeDomainMapConfig(jHipsterProperties));
return Hazelcast.newHazelcastInstance(config);
}
示例7: hazelcastInstance
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
@Bean
@Primary
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
log.debug("Configuring Hazelcast");
HazelcastInstance hazelCastInstance = Hazelcast.getHazelcastInstanceByName("gate");
if (hazelCastInstance != null) {
log.debug("Hazelcast already initialized");
return hazelCastInstance;
}
Config config = new Config();
config.setInstanceName("gate");
config.getNetworkConfig().setPort(5701);
config.getNetworkConfig().setPortAutoIncrement(true);
// In development, remove multicast auto-configuration
if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
System.setProperty("hazelcast.local.localAddress", "127.0.0.1");
config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);
}
config.getMapConfigs().put("default", initializeDefaultMapConfig());
config.getMapConfigs().put("com.icthh.xm.gate.domain.*", initializeDomainMapConfig(jHipsterProperties));
return Hazelcast.newHazelcastInstance(config);
}
示例8: hazelcastInstance
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
@Bean
@Primary
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
log.debug("Configuring Hazelcast");
HazelcastInstance hazelCastInstance = Hazelcast.getHazelcastInstanceByName("entity");
if (hazelCastInstance != null) {
log.debug("Hazelcast already initialized");
return hazelCastInstance;
}
Config config = new Config();
config.setInstanceName("entity");
config.getNetworkConfig().setPort(5701);
config.getNetworkConfig().setPortAutoIncrement(true);
// In development, remove multicast auto-configuration
if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
System.setProperty("hazelcast.local.localAddress", "127.0.0.1");
config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);
}
config.getMapConfigs().put("default", initializeDefaultMapConfig());
config.getMapConfigs().put("com.icthh.xm.ms.entity.domain.*", initializeDomainMapConfig(jHipsterProperties));
return Hazelcast.newHazelcastInstance(config);
}
示例9: hazelcastInstance
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
@Bean
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
log.debug("Configuring Hazelcast");
Config config = new Config();
config.setInstanceName("operoncloudplatform");
config.getNetworkConfig().setPort(5701);
config.getNetworkConfig().setPortAutoIncrement(true);
// In development, remove multicast auto-configuration
if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
System.setProperty("hazelcast.local.localAddress", "127.0.0.1");
config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);
}
config.getMapConfigs().put("default", initializeDefaultMapConfig());
config.getMapConfigs().put("cloud.operon.platform.domain.*", initializeDomainMapConfig(jHipsterProperties));
return Hazelcast.newHazelcastInstance(config);
}
示例10: testWhenClusterIsDownAtBeginningInDeferedMode
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
@Test
public void testWhenClusterIsDownAtBeginningInDeferedMode() throws Exception {
if (!testName.equals("client - not deferred")) {
return;
}
hz.shutdown();
CookieStore cookieStore = new BasicCookieStore();
assertEquals("true", executeRequest("write", serverPort1, cookieStore));
assertEquals("value", executeRequest("read", serverPort1, cookieStore));
hz = Hazelcast.newHazelcastInstance(
new FileSystemXmlConfig(new File(sourceDir + "/WEB-INF/", "hazelcast.xml")));
assertClusterSizeEventually(1, hz);
assertEquals("value", executeRequest("read", serverPort1, cookieStore));
IMap<String, Object> map = hz.getMap(DEFAULT_MAP_NAME);
assertEquals(0, map.size());
}
示例11: configInstanceWithName
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
@Test
public void configInstanceWithName() {
Config config = new Config("my-test-instance");
HazelcastInstance existingHazelcastInstance = Hazelcast
.newHazelcastInstance(config);
try {
load(HazelcastConfigWithName.class,
"spring.hazelcast.config=this-is-ignored.xml");
HazelcastInstance hazelcastInstance = this.context
.getBean(HazelcastInstance.class);
assertThat(hazelcastInstance.getConfig().getInstanceName())
.isEqualTo("my-test-instance");
// Should reuse any existing instance by default.
assertThat(hazelcastInstance).isEqualTo(existingHazelcastInstance);
}
finally {
existingHazelcastInstance.shutdown();
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:HazelcastAutoConfigurationTests.java
示例12: ensureInstanceIsUp
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
@Override
protected void ensureInstanceIsUp() throws Exception {
if (isInstanceNotActive(hz)) {
hz = Hazelcast.newHazelcastInstance(
new FileSystemXmlConfig(new File(sourceDir + "/WEB-INF/", "hazelcast.xml")));
}
if (serverXml1 != null) {
if (server1 == null) {
serverPort1 = availablePort();
server1 = getServletContainer(serverPort1, sourceDir, serverXml1);
} else if (!server1.isRunning()) {
server1.start();
}
}
if (serverXml2 != null) {
if (server2 == null) {
serverPort2 = availablePort();
server2 = getServletContainer(serverPort2, sourceDir, serverXml2);
} else if (!server2.isRunning()) {
server2.start();
}
}
}
示例13: ensureInstanceIsUp
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
protected void ensureInstanceIsUp() throws Exception {
if (isInstanceNotActive(hz)) {
hz = Hazelcast.newHazelcastInstance(
new FileSystemXmlConfig(new File(sourceDir + "/WEB-INF/", "hazelcast.xml")));
}
if (serverXml1 != null) {
if (server1 == null) {
serverPort1 = availablePort();
server1 = getServletContainer(serverPort1, sourceDir, serverXml1);
} else if (!server1.isRunning()) {
server1.start();
}
}
if (serverXml2 != null) {
if (server2 == null) {
serverPort2 = availablePort();
server2 = getServletContainer(serverPort2, sourceDir, serverXml2);
} else if (!server2.isRunning()) {
server2.start();
}
}
}
示例14: getInstance
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
public synchronized static HazelcastInstance getInstance() {
if (instance == null) {
//Config config = new XmlConfigBuilder().build();
instance = Hazelcast.newHazelcastInstance();
// final AtomicBoolean isStarted = new AtomicBoolean();
// instance.getLifecycleService().addLifecycleListener(new LifecycleListener() {
// @Override
// public void stateChanged(LifecycleEvent event) {
// if(event.getState() == LifecycleEvent.LifecycleState.STARTED){
// isStarted.set(true);
// }
// }
// });
// while(!isStarted.get()) {
// try {
// Thread.sleep(50);
// } catch (InterruptedException ex) {
// throw new RuntimeException(ex);
// }
// }
}
return instance;
}
示例15: create
import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
@Override
public HazelcastInstance create(ClusterConfig config) {
if (customizers != null) {
customizers.forEach(customizer -> customizer.customize(hazelcastConfig));
}
return Hazelcast.newHazelcastInstance(hazelcastConfig);
}