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