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


Java Hazelcast.getOrCreateHazelcastInstance方法代码示例

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


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

示例1: createHazelcastInstance

import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
/**
 * 
 */
private void createHazelcastInstance()
{
  hazelcast = Hazelcast.getOrCreateHazelcastInstance(hzConfig);
   Set<Member> members = hazelcast.getCluster().getMembers();
   
   int memberIdCnt = 0;
   for(Member m : members)
   {
     
     if(m.getStringAttribute(Configurator.NODE_INSTANCE_ID).equals(getInstanceId()))
     {
       memberIdCnt++;
     }
     if(memberIdCnt >= 2){
       stop();
       throw new IllegalStateException("Instance not allowed to join cluster as ["+getInstanceId()+"]. Duplicate name!");
     }
     
   }
   log.info("** Instance ["+getInstanceId()+"] joined cluster ["+hzConfig.getGroupConfig().getName()+"] successfully **");
}
 
开发者ID:javanotes,项目名称:reactive-data,代码行数:25,代码来源:HazelcastInstanceProxy.java

示例2: createHazelcastFullInstance

import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
/**
 * Create hazelcast full instance.
 *
 * @param configLocation the config location
 * @return the hazelcast instance
 */
public static HazelcastInstance createHazelcastFullInstance(String configLocation) {
    Config config;
    try {
        if (configLocation == null) {
            config = new XmlConfigBuilder().build();
        } else {
            config = ConfigLoader.load(configLocation);
        }
    } catch (IOException e) {
        throw new RuntimeException("failed to load config", e);
    }

    checkNotNull(config, "failed to find configLocation: " + configLocation);

    config.setInstanceName(DEFAULT_INSTANCE_NAME);
    return Hazelcast.getOrCreateHazelcastInstance(config);
}
 
开发者ID:hazelcast,项目名称:hazelcast-jetty-sessionmanager,代码行数:24,代码来源:JettySessionUtils.java

示例3: getInstance

import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
public static HazelcastInstance getInstance() {
    if (hazelcastInstance == null) {
        Config config = new XmlConfigBuilder().build();
        config.setInstanceName(Thread.currentThread().getName());

        hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(config);
    }

    return hazelcastInstance;
}
 
开发者ID:vgoldin,项目名称:cqrs-eventsourcing-kafka,代码行数:11,代码来源:HazelcastManaged.java

示例4: getHazelcastInstance

import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
/**
 * Get the {@link HazelcastInstance}.
 * @return the {@link HazelcastInstance}
 */
public HazelcastInstance getHazelcastInstance() {
	if (StringUtils.hasText(this.config.getInstanceName())) {
		return Hazelcast.getOrCreateHazelcastInstance(this.config);
	}
	return Hazelcast.newHazelcastInstance(this.config);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:HazelcastInstanceFactory.java

示例5: lifecycleEvent

import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
@Override
public void lifecycleEvent(LifecycleEvent event) {
    String shutdown = System.getProperty("hazelcast.tomcat.shutdown_hazelcast_instance");
    if (getConfigLocation() == null) {
        setConfigLocation("hazelcast-default.xml");
    }

    if ("start".equals(event.getType())) {
        try {
            config = ConfigLoader.load(getConfigLocation());
        } catch (IOException e) {
            throw new RuntimeException("failed to load Config:", e);
        }

        if (config == null) {
            throw new RuntimeException("failed to find configLocation:" + getConfigLocation());
        }
        if (config.getInstanceName() == null) {
            config.setInstanceName(SessionManager.DEFAULT_INSTANCE_NAME);
        }
        Hazelcast.getOrCreateHazelcastInstance(config);
    } else if ("stop".equals(event.getType()) && !"false".equals(shutdown)) {
        HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(SessionManager.DEFAULT_INSTANCE_NAME);
        if (instance != null) {
            instance.shutdown();
        }
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-tomcat-sessionmanager,代码行数:29,代码来源:P2PLifecycleListener.java


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