com.hazelcast.config.Config.getInstanceName()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中com.hazelcast.config.Config.getInstanceName()方法的一些代码示例,展示了Config.getInstanceName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.getInstanceName()方法的具体详情如下:
包路径:com.hazelcast.config.Config
类名称:Config
方法名:getInstanceName

Config.getInstanceName介绍

[英]Returns 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 String getInstanceName() {
  return staticConfig.getInstanceName();
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@Override
public String getInstanceName() {
  return staticConfig.getInstanceName();
}

代码示例来源:origin: org.apereo.cas/cas-server-support-hazelcast-ticket-registry

/**
 * Make sure we shutdown HazelCast when the context is destroyed.
 */
public void shutdown() {
  try {
    LOGGER.info("Shutting down Hazelcast instance [{}]", this.hazelcastInstance.getConfig().getInstanceName());
    this.hazelcastInstance.shutdown();
  } catch (final Exception e) {
    LOGGER.debug(e.getMessage());
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet

private HazelcastInstance getDefaultInstance() {
  if (hazelcastInstance == null) {
    // if there is no default instance in use (not created yet and not specified):
    // 1. locate default ClientConfig: if it specifies an instance name, get-or-create an instance by that name
    // 2. otherwise start a new Hazelcast member
    Config config = getDefaultConfig();
    if (isNullOrEmptyAfterTrim(config.getInstanceName())) {
      hazelcastInstance = Hazelcast.newHazelcastInstance();
    } else {
      hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(config);
    }
  }
  return hazelcastInstance;
}

代码示例来源:origin: com.hazelcast/hazelcast-all

private HazelcastInstance getDefaultInstance() {
  if (hazelcastInstance == null) {
    // if there is no default instance in use (not created yet and not specified):
    // 1. locate default ClientConfig: if it specifies an instance name, get-or-create an instance by that name
    // 2. otherwise start a new Hazelcast member
    Config config = getDefaultConfig();
    if (isNullOrEmptyAfterTrim(config.getInstanceName())) {
      hazelcastInstance = Hazelcast.newHazelcastInstance();
    } else {
      hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(config);
    }
  }
  return hazelcastInstance;
}

代码示例来源:origin: hazelcast/hazelcast-jet

/**
 * Creates a member of the Jet cluster with the given configuration.
 */
public static JetInstance newJetInstance(JetConfig config) {
  return newJetInstanceImpl(config, cfg ->
      HazelcastInstanceFactory.newHazelcastInstance(cfg, cfg.getInstanceName(), new JetNodeContext()));
}

代码示例来源: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: 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: 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: org.geoserver.community/gs-hz-cluster

private void initDelegate() throws ServletException {
  // Set up init-params for the delegate instance
  // TODO Maybe make these configurable in cluster.properties
  final Map<String, String> params = new HashMap<String, String>();
  params.put("map-name", "geoserver-sessions");
  params.put("sticky-session", Boolean.toString(getCluster().isStickySession()));
  params.put("instance-name", getCluster().getHz().getConfig().getInstanceName());
  FilterConfig config =
      new FilterConfig() {
        @Override
        public String getFilterName() {
          return "hazelcast";
        }
        @Override
        public ServletContext getServletContext() {
          return srvCtx;
        }
        @Override
        public String getInitParameter(String name) {
          return params.get(name);
        }
        @Override
        public Enumeration<String> getInitParameterNames() {
          return Iterators.asEnumeration(params.keySet().iterator());
        }
      };
  delegate.init(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: 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: 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: hazelcast/hazelcast-jet

/**
 * Creates a new Hazelcast instance.
 *
 * @param config the configuration to use; if <code>null</code>, the set of defaults
 *               as specified in the XSD for the configuration XML will be used.
 * @return the configured {@link HazelcastInstance}
 */
public static HazelcastInstance newHazelcastInstance(Config config) {
  if (config == null) {
    config = new XmlConfigBuilder().build();
  }
  return newHazelcastInstance(
      config,
      config.getInstanceName(),
      new DefaultNodeContext()
  );
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

Properties properties = HazelcastCachingProvider.propertiesByInstanceName(clusterB.getConfig().getInstanceName());
URI cacheManagerName;
try {

代码示例来源:origin: hazelcast/hazelcast-code-samples

Properties properties = HazelcastCachingProvider.propertiesByInstanceName(clusterA.getConfig().getInstanceName());
URI cacheManagerName;
try {

代码示例来源:origin: com.hazelcast/hazelcast-all

/**
 * Creates a new Hazelcast instance.
 *
 * @param config the configuration to use; if <code>null</code>, the set of defaults
 *               as specified in the XSD for the configuration XML will be used.
 * @return the configured {@link HazelcastInstance}
 */
public static HazelcastInstance newHazelcastInstance(Config config) {
  if (config == null) {
    config = new XmlConfigBuilder().build();
  }
  return newHazelcastInstance(
      config,
      config.getInstanceName(),
      new DefaultNodeContext()
  );
}

代码示例来源:origin: hazelcast/hazelcast-jet

public static HazelcastInstance getOrCreateHazelcastInstance(Config config) {
  if (config == null) {
    config = new XmlConfigBuilder().build();
  }
  String name = config.getInstanceName();
  checkHasText(name, "instanceName must contain text");
  InstanceFuture future = INSTANCE_MAP.get(name);
  if (future != null) {
    return future.get();
  }
  future = new InstanceFuture();
  InstanceFuture found = INSTANCE_MAP.putIfAbsent(name, future);
  if (found != null) {
    return found.get();
  }
  try {
    return constructHazelcastInstance(config, name, new DefaultNodeContext(), future);
  } catch (Throwable t) {
    INSTANCE_MAP.remove(name, future);
    future.setFailure(t);
    throw ExceptionUtil.rethrow(t);
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

public static HazelcastInstance getOrCreateHazelcastInstance(Config config) {
  if (config == null) {
    config = new XmlConfigBuilder().build();
  }
  String name = config.getInstanceName();
  checkHasText(name, "instanceName must contain text");
  InstanceFuture future = INSTANCE_MAP.get(name);
  if (future != null) {
    return future.get();
  }
  future = new InstanceFuture();
  InstanceFuture found = INSTANCE_MAP.putIfAbsent(name, future);
  if (found != null) {
    return found.get();
  }
  try {
    return constructHazelcastInstance(config, name, new DefaultNodeContext(), future);
  } catch (Throwable t) {
    INSTANCE_MAP.remove(name, future);
    future.setFailure(t);
    throw ExceptionUtil.rethrow(t);
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

.close()
.node("license-key", getOrMaskValue(config.getLicenseKey()))
.node("instance-name", config.getInstanceName());

相关文章

微信公众号

最新文章

更多

Config类方法