@Override public String getInstanceName() { return staticConfig.getInstanceName(); }
@Override public String getInstanceName() { return staticConfig.getInstanceName(); }
/** * 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()); } }
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; }
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; }
/** * 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())); }
@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); } }
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; }
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; }
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); }
private Config getDefaultConfig() { Config config = new XmlConfigBuilder().build(); if (namedDefaultHzInstance && isNullOrEmpty(config.getInstanceName())) { config.setInstanceName(SHARED_JCACHE_INSTANCE_NAME); } return config; }
private Config getDefaultConfig() { Config config = new XmlConfigBuilder().build(); if (namedDefaultHzInstance && isNullOrEmpty(config.getInstanceName())) { config.setInstanceName(SHARED_JCACHE_INSTANCE_NAME); } return config; }
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; }
/** * 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() ); }
Properties properties = HazelcastCachingProvider.propertiesByInstanceName(clusterB.getConfig().getInstanceName()); URI cacheManagerName; try {
Properties properties = HazelcastCachingProvider.propertiesByInstanceName(clusterA.getConfig().getInstanceName()); URI cacheManagerName; try {
/** * 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() ); }
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); } }
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); } }
.close() .node("license-key", getOrMaskValue(config.getLicenseKey())) .node("instance-name", config.getInstanceName());