本文整理了Java中com.hazelcast.config.Config.setInstanceName()
方法的一些代码示例,展示了Config.setInstanceName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.setInstanceName()
方法的具体详情如下:
包路径:com.hazelcast.config.Config
类名称:Config
方法名:setInstanceName
[英]Sets the instance name uniquely identifying the hazelcast instance created by this configuration. This name is used in different scenarios, such as identifying the hazelcast instance when running multiple instances in the same JVM.
[中]设置唯一标识此配置创建的hazelcast实例的实例名称。此名称用于不同的场景,例如在同一JVM中运行多个实例时标识hazelcast实例。
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public Config setInstanceName(String instanceName) {
return staticConfig.setInstanceName(instanceName);
}
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
public Config setInstanceName(String instanceName) {
return staticConfig.setInstanceName(instanceName);
}
代码示例来源:origin: stackoverflow.com
Config config = new Config();
config.setInstanceName( "my-named-hazelcast-instance" );
代码示例来源:origin: hazelcast/hazelcast-jet
private void handleInstanceName(Node node) {
String instanceName = getTextContent(node);
if (instanceName.isEmpty()) {
throw new InvalidConfigurationException("Instance name in XML configuration is empty");
}
config.setInstanceName(instanceName);
}
代码示例来源:origin: com.hazelcast/hazelcast-all
private void handleInstanceName(Node node) {
String instanceName = getTextContent(node);
if (instanceName.isEmpty()) {
throw new InvalidConfigurationException("Instance name in XML configuration is empty");
}
config.setInstanceName(instanceName);
}
代码示例来源:origin: hazelcast/hazelcast-jet
private Config getConfig(URL configURL, ClassLoader theClassLoader, String instanceName) throws IOException {
Config config = new XmlConfigBuilder(configURL).build()
.setClassLoader(theClassLoader);
if (instanceName != null) {
// if the instance name is specified via properties use it,
// even though instance name is specified in the config
config.setInstanceName(instanceName);
} else if (config.getInstanceName() == null) {
// use the config URL as instance name if instance name is not specified
config.setInstanceName(configURL.toString());
}
return config;
}
代码示例来源:origin: com.hazelcast/hazelcast-all
private Config getConfig(URL configURL, ClassLoader theClassLoader, String instanceName) throws IOException {
Config config = new XmlConfigBuilder(configURL).build()
.setClassLoader(theClassLoader);
if (instanceName != null) {
// if the instance name is specified via properties use it,
// even though instance name is specified in the config
config.setInstanceName(instanceName);
} else if (config.getInstanceName() == null) {
// use the config URL as instance name if instance name is not specified
config.setInstanceName(configURL.toString());
}
return config;
}
代码示例来源:origin: vgoldin/cqrs-eventsourcing-kafka
public static HazelcastInstance getInstance() {
if (hazelcastInstance == null) {
Config config = new XmlConfigBuilder().build();
config.setInstanceName(Thread.currentThread().getName());
hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(config);
}
return hazelcastInstance;
}
代码示例来源:origin: com.sitewhere/sitewhere-core
@Override
public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException {
try {
Config config = new XmlConfigBuilder(new ByteArrayInputStream(baseConfiguration.getContent())).build();
config.setInstanceName(getGroupName());
HazelcastConfiguration.configureManagementCenter(config);
HazelcastConfiguration.performGroupOverrides(config, getGroupName(), getGroupPassword());
HazelcastConfiguration.performSerializationOverrides(config);
HazelcastConfiguration.performPropertyOverrides(config);
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(ServiceLoader.class.getClassLoader());
instance = Hazelcast.newHazelcastInstance(config);
} finally {
Thread.currentThread().setContextClassLoader(loader);
}
LOGGER.info("Hazelcast instance '" + config.getInstanceName() + "' started.");
} catch (Exception e) {
throw new SiteWhereException("Unable to create Hazelcast instance.", e);
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
/**
* Gets an existing {@link HazelcastInstance} by {@code instanceName} or,
* if not found, creates a new {@link HazelcastInstance} with the default
* configuration and given {@code instanceName}.
*
* @param instanceName name to lookup an existing {@link HazelcastInstance}
* or to create a new one
* @return a {@link HazelcastInstance} with the given {@code instanceName}
*/
private HazelcastInstance getOrCreateByInstanceName(String instanceName) {
HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(instanceName);
if (instance == null) {
Config config = getDefaultConfig();
config.setInstanceName(instanceName);
instance = Hazelcast.getOrCreateHazelcastInstance(config);
}
return instance;
}
代码示例来源:origin: com.hazelcast/hazelcast-all
/**
* Gets an existing {@link HazelcastInstance} by {@code instanceName} or,
* if not found, creates a new {@link HazelcastInstance} with the default
* configuration and given {@code instanceName}.
*
* @param instanceName name to lookup an existing {@link HazelcastInstance}
* or to create a new one
* @return a {@link HazelcastInstance} with the given {@code instanceName}
*/
private HazelcastInstance getOrCreateByInstanceName(String instanceName) {
HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(instanceName);
if (instance == null) {
Config config = getDefaultConfig();
config.setInstanceName(instanceName);
instance = Hazelcast.getOrCreateHazelcastInstance(config);
}
return instance;
}
代码示例来源:origin: hazelcast/hazelcast-jet
private Config getDefaultConfig() {
Config config = new XmlConfigBuilder().build();
if (namedDefaultHzInstance && isNullOrEmpty(config.getInstanceName())) {
config.setInstanceName(SHARED_JCACHE_INSTANCE_NAME);
}
return config;
}
代码示例来源:origin: com.hazelcast/hazelcast-all
private Config getDefaultConfig() {
Config config = new XmlConfigBuilder().build();
if (namedDefaultHzInstance && isNullOrEmpty(config.getInstanceName())) {
config.setInstanceName(SHARED_JCACHE_INSTANCE_NAME);
}
return config;
}
代码示例来源:origin: net.di2e.ecdr.libs/cdr-libs-cache
private Properties getConfigProperties() {
Config config = new Config();
config.setClassLoader( getClass().getClassLoader() );
config.setInstanceName( "ecdr-jcache-config-instance" );
NetworkConfig networkConfig = config.getNetworkConfig();
JoinConfig join = networkConfig.getJoin();
join.getMulticastConfig().setEnabled( false );
join.getTcpIpConfig().setEnabled( false );
join.getAwsConfig().setEnabled( false );
// This actually creates the config so it will be available to the CacheManager
Hazelcast.newHazelcastInstance( config );
Properties props = new Properties();
props.setProperty( HazelcastCachingProvider.HAZELCAST_INSTANCE_NAME, config.getInstanceName() );
return props;
}
代码示例来源:origin: kloiasoft/eventapis
@Bean
public Config config() {
Config config = new Config();
GroupConfig groupConfig = config.getGroupConfig();
groupConfig.setName(hazelcastGrid);
groupConfig.setPassword(hazelcastPassword);
config.setGroupConfig(groupConfig);
config.setInstanceName(artifactId);
for (HazelcastConfigurer hazelcastConfigurer : hazelcastConfigurers) {
config = hazelcastConfigurer.configure(config);
}
return config;
}
代码示例来源:origin: com.hazelcast/jetty-core
/**
* 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);
}
}
代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl
/**
* Service INIT
*/
public void init() {
String clientServers = serverConfigurationService.getString("memory.hc.server", null);
boolean clientConfigured = StringUtils.isNotBlank(clientServers);
if (clientConfigured) {
ClientConfig clientConfig = new ClientConfig();
ClientNetworkConfig clientNetworkConfig = new ClientNetworkConfig();
clientNetworkConfig.addAddress(StringUtils.split(clientServers, ','));
clientConfig.setNetworkConfig(clientNetworkConfig);
hcInstance = HazelcastClient.newHazelcastClient(clientConfig);
} else {
// start up a local server instead
Config localConfig = new Config();
localConfig.setInstanceName(serverConfigurationService.getServerIdInstance());
hcInstance = Hazelcast.newHazelcastInstance(localConfig);
}
if (hcInstance == null) {
throw new IllegalStateException("init(): HazelcastInstance is null!");
}
log.info("INIT: " + hcInstance.getName() + " ("+(clientConfigured?"client:"+hcInstance.getClientService():"localServer")+"), cache maps: " + hcInstance.getDistributedObjects());
}
代码示例来源:origin: org.apereo.cas/cas-server-support-hazelcast-core
/**
* Build config.
*
* @param hz the hz
* @return the config
*/
public static Config build(final BaseHazelcastProperties hz) {
val cluster = hz.getCluster();
val config = new Config();
val networkConfig = new NetworkConfig()
.setPort(cluster.getPort())
.setPortAutoIncrement(cluster.isPortAutoIncrement());
val joinConfig = cluster.getDiscovery().isEnabled()
? createDiscoveryJoinConfig(config, hz.getCluster(), networkConfig)
: createDefaultJoinConfig(config, hz.getCluster());
LOGGER.debug("Created Hazelcast join configuration [{}]", joinConfig);
networkConfig.setJoin(joinConfig);
LOGGER.debug("Created Hazelcast network configuration [{}]", networkConfig);
config.setNetworkConfig(networkConfig);
return config.setInstanceName(cluster.getInstanceName())
.setProperty(BaseHazelcastProperties.HAZELCAST_DISCOVERY_ENABLED_PROP, BooleanUtils.toStringTrueFalse(cluster.getDiscovery().isEnabled()))
.setProperty(BaseHazelcastProperties.IPV4_STACK_PROP, String.valueOf(cluster.isIpv4Enabled()))
.setProperty(BaseHazelcastProperties.LOGGING_TYPE_PROP, cluster.getLoggingType())
.setProperty(BaseHazelcastProperties.MAX_HEARTBEAT_SECONDS_PROP, String.valueOf(cluster.getMaxNoHeartbeatSeconds()));
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
private Config getConfigClusterA() {
Config config = new Config();
config.setLicenseKey(ENTERPRISE_LICENSE_KEY);
config.getGroupConfig().setName("clusterA").setPassword("clusterA-pass");
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true).addMember("127.0.0.1:5701");
config.setInstanceName("clusterA");
config.getNetworkConfig().setPort(5701);
config.setClassLoader(createCacheManagerClassLoader());
WanReplicationConfig wanReplicationConfig = new WanReplicationConfig();
wanReplicationConfig.setName("AtoB");
WanPublisherConfig publisherConfigClusterB = new WanPublisherConfig();
publisherConfigClusterB.setClassName(WanBatchReplication.class.getName());
publisherConfigClusterB.setGroupName("clusterB");
Map<String, Comparable> props = publisherConfigClusterB.getProperties();
props.put(WanReplicationProperties.ENDPOINTS.key(), "127.0.0.1:5702");
props.put(WanReplicationProperties.GROUP_PASSWORD.key(), "clusterB-pass");
// setting acknowledge type is optional, defaults to ACK_ON_OPERATION_COMPLETE
props.put(WanReplicationProperties.ACK_TYPE.key(), WanAcknowledgeType.ACK_ON_OPERATION_COMPLETE.name());
wanReplicationConfig.addWanPublisherConfig(publisherConfigClusterB);
config.addWanReplicationConfig(wanReplicationConfig);
WanReplicationRef wanReplicationRef = new WanReplicationRef();
wanReplicationRef.setName("AtoB");
config.setLicenseKey(ENTERPRISE_LICENSE_KEY);
wanReplicationRef.setMergePolicy(HigherHitsCacheMergePolicy.class.getName());
wanReplicationRef.addFilter(SampleCacheWanEventFilter.class.getName());
config.getCacheConfig("default").setWanReplicationRef(wanReplicationRef);
return config;
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
private Config getConfigClusterB() {
Config config = new Config();
config.setLicenseKey(ENTERPRISE_LICENSE_KEY);
config.getGroupConfig().setName("clusterB").setPassword("clusterB-pass");
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true).addMember("127.0.0.1:5702");
config.setInstanceName("clusterB");
config.getNetworkConfig().setPort(5702);
config.setClassLoader(createCacheManagerClassLoader());
return config;
}
内容来源于网络,如有侵权,请联系作者删除!