本文整理汇总了Java中com.hazelcast.config.Config.setInstanceName方法的典型用法代码示例。如果您正苦于以下问题:Java Config.setInstanceName方法的具体用法?Java Config.setInstanceName怎么用?Java Config.setInstanceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hazelcast.config.Config
的用法示例。
在下文中一共展示了Config.setInstanceName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hazelcastInstance
import com.hazelcast.config.Config; //导入方法依赖的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);
}
示例2: hazelcastInstance
import com.hazelcast.config.Config; //导入方法依赖的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);
}
示例3: hazelcastInstance
import com.hazelcast.config.Config; //导入方法依赖的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);
}
示例4: hazelcastInstance
import com.hazelcast.config.Config; //导入方法依赖的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);
}
示例5: hazelcastInstance
import com.hazelcast.config.Config; //导入方法依赖的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);
}
示例6: createHazelcastFullInstance
import com.hazelcast.config.Config; //导入方法依赖的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);
}
示例7: testNamedInstance
import com.hazelcast.config.Config; //导入方法依赖的package包/类
@Test
public void testNamedInstance() {
TestHazelcastFactory factory = new TestHazelcastFactory();
Config config = new Config();
config.setInstanceName("hibernate");
HazelcastInstance hz = factory.newHazelcastInstance(config);
Properties props = new Properties();
props.setProperty(Environment.CACHE_REGION_FACTORY, HazelcastCacheRegionFactory.class.getName());
props.put(CacheEnvironment.HAZELCAST_INSTANCE_NAME, "hibernate");
props.put(CacheEnvironment.SHUTDOWN_ON_STOP, "false");
props.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
Configuration configuration = new Configuration();
configuration.addProperties(props);
SessionFactory sf = configuration.buildSessionFactory();
assertTrue(hz.equals(HazelcastAccessor.getHazelcastInstance(sf)));
sf.close();
assertTrue(hz.getLifecycleService().isRunning());
factory.shutdownAll();
}
示例8: testNamedInstance_noInstance
import com.hazelcast.config.Config; //导入方法依赖的package包/类
@Test
public void testNamedInstance_noInstance() {
exception.expect(CacheException.class);
exception.expectMessage("No instance with name [hibernate] could be found.");
Config config = new Config();
config.setInstanceName("hibernate");
Properties props = new Properties();
props.setProperty(Environment.CACHE_REGION_FACTORY, HazelcastCacheRegionFactory.class.getName());
props.put(CacheEnvironment.HAZELCAST_INSTANCE_NAME, "hibernate");
props.put(CacheEnvironment.SHUTDOWN_ON_STOP, "false");
props.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
Configuration configuration = new Configuration();
configuration.addProperties(props);
SessionFactory sf = configuration.buildSessionFactory();
sf.close();
}
示例9: hazelcastInstance
import com.hazelcast.config.Config; //导入方法依赖的package包/类
@Bean
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
log.debug("Configuring Hazelcast");
HazelcastInstance hazelCastInstance = Hazelcast.getHazelcastInstanceByName("uaa");
if (hazelCastInstance != null) {
log.debug("Hazelcast already initialized");
return hazelCastInstance;
}
Config config = new Config();
config.setInstanceName("uaa");
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.uaa.domain.*", initializeDomainMapConfig(jHipsterProperties));
// Uncomment if session needed
//config.getMapConfigs().put("clustered-http-sessions", initializeClusteredSession(jHipsterProperties));
return Hazelcast.newHazelcastInstance(config);
}
示例10: hazelCastConfig
import com.hazelcast.config.Config; //导入方法依赖的package包/类
@Bean
public Config hazelCastConfig() {
Config config = new Config();
config.setInstanceName("hazelcast-packt-cache");
config.setProperty("hazelcast.jmx", "true");
MapConfig deptCache = new MapConfig();
deptCache.setTimeToLiveSeconds(20);
deptCache.setEvictionPolicy(EvictionPolicy.LFU);
config.getMapConfigs().put("hazeldept",deptCache);
return config;
}
示例11: start
import com.hazelcast.config.Config; //导入方法依赖的package包/类
void start() {
LOGGER.info(getClass().getSimpleName() + " started");
java.util.logging.Logger.getLogger("com.hazelcast").setLevel(Level.WARNING);
Config config = new Config();
config.setInstanceName(INSTANCE_NAME);
config.getNetworkConfig()
.setPort(5701)
.getJoin()
.getMulticastConfig()
.setEnabled(false);
hazelcastInstance = Hazelcast.newHazelcastInstance(config);
}
示例12: hazelcastInstance
import com.hazelcast.config.Config; //导入方法依赖的package包/类
@Bean
public HazelcastInstance hazelcastInstance(MessageServerConfig serverConfig) {
log.debug("Configuring Hazelcast");
HazelcastInstance hazelCastInstance =
Hazelcast.getHazelcastInstanceByName("message-server");
if (hazelCastInstance != null) {
log.debug("Hazelcast already initialized");
return hazelCastInstance;
}
Config config = new Config();
config.setInstanceName("message-server");
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
if (this.registration == null) {
log.warn("No discovery service is set up, Hazelcast cannot create a cluster.");
} else {
// The serviceId is by default the application's name, see Spring Boot's
// eureka.instance.appname property
String serviceId = registration.getServiceId();
log.debug("Configuring Hazelcast clustering for instanceId: {}", serviceId);
config.getNetworkConfig().setPort(5701);
config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true);
for (ServiceInstance instance : discoveryClient.getInstances(serviceId)) {
String clusterMember = instance.getHost() + ":5701";
log.debug("Adding Hazelcast (prod) cluster member " + clusterMember);
config.getNetworkConfig().getJoin().getTcpIpConfig().addMember(clusterMember);
}
}
config.getMapConfigs().put("default", initializeDefaultMapConfig());
config.getMapConfigs().put("com.blt.talk.domain.*",
initializeDomainMapConfig(serverConfig));
return Hazelcast.newHazelcastInstance(config);
}
示例13: Transport
import com.hazelcast.config.Config; //导入方法依赖的package包/类
/**
* Initializes the {@link HazelcastInstance} for this global runtime instance.
*
* @param runtime
* the global runtime instance
* @param master
* member to connect to or null
* @param localhost
* the preferred ip address of this host or null
* @param compact
* reduce thread creation if set
* @param kryo
* use kryo serialization if set
*/
protected Transport(GlobalRuntimeImpl runtime, String master,
String localhost, boolean compact, boolean kryo) {
this.runtime = runtime;
// config
final Config config = new Config();
config.setProperty("hazelcast.logging.type", "none");
config.setProperty("hazelcast.wait.seconds.before.join", "0");
config.setProperty("hazelcast.socket.connect.timeout.seconds", "1");
config.setProperty("hazelcast.connection.monitor.max.faults", "0");
if (compact) {
config.setProperty("hazelcast.operation.thread.count", "2");
config.setProperty("hazelcast.operation.generic.thread.count", "2");
config.setProperty("hazelcast.io.thread.count", "2");
config.setProperty("hazelcast.event.thread.count", "2");
config.addExecutorConfig(
new ExecutorConfig(ExecutionService.ASYNC_EXECUTOR, 2));
config.addExecutorConfig(
new ExecutorConfig(ExecutionService.SYSTEM_EXECUTOR, 2));
config.addExecutorConfig(
new ExecutorConfig(ExecutionService.SCHEDULED_EXECUTOR, 2));
}
// kryo
if (kryo) {
config.getSerializationConfig().addSerializerConfig(
new SerializerConfig().setTypeClass(SerializableRunnable.class)
.setImplementation(new KryoSerializer()));
}
config.addMapConfig(
new MapConfig(APGAS_FINISH).setInMemoryFormat(InMemoryFormat.OBJECT));
// join config
final JoinConfig join = config.getNetworkConfig().getJoin();
join.getMulticastConfig().setEnabled(false);
join.getTcpIpConfig().setEnabled(true);
if (localhost != null) {
System.setProperty("hazelcast.local.localAddress", localhost);
}
if (master != null) {
join.getTcpIpConfig().addMember(master);
}
config.setInstanceName(APGAS);
hazelcast = Hazelcast.newHazelcastInstance(config);
me = hazelcast.getCluster().getLocalMember();
allMembers = hazelcast.getList(APGAS_PLACES);
allMembers.add(me);
int id = 0;
for (final Member member : allMembers) {
if (member.getUuid().equals(me.getUuid())) {
break;
}
++id;
}
here = id;
executor = hazelcast.getExecutorService(APGAS_EXECUTOR);
}
示例14: getHazelcast
import com.hazelcast.config.Config; //导入方法依赖的package包/类
public synchronized HazelcastInstance getHazelcast() {
if (hazelcast == null) {
Config config = new ClasspathXmlConfig("org/j2server/j2cache/cache/hazelcast/hazelcast-cache-config.xml");
config.setInstanceName("j2cache");
hazelcast = Hazelcast.newHazelcastInstance(config);
}
return hazelcast;
}
示例15: getInstance
import com.hazelcast.config.Config; //导入方法依赖的package包/类
public static HazelcastInstance getInstance() {
if (hazelcastInstance == null) {
Config config = new XmlConfigBuilder().build();
config.setInstanceName(Thread.currentThread().getName());
hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(config);
}
return hazelcastInstance;
}