Refine search
/** * Initialization of HazelCast with default config. * * @param hazelCastConfig */ public CacheManagerHazelCast() { this(new XmlConfigBuilder().build(), null); }
private void parseAndBuildConfig(Config config) throws Exception { this.config = config; Document doc = parse(in); Element root = doc.getDocumentElement(); checkRootElement(root); try { root.getTextContent(); } catch (Throwable e) { domLevel3 = false; } process(root); if (shouldValidateTheSchema()) { schemaValidation(root.getOwnerDocument()); } handleConfig(root); }
private int getPort(WorkerJvmSettings settings) throws UnsupportedEncodingException { Config config = new XmlConfigBuilder(new ByteArrayInputStream(settings.hzConfig.getBytes("UTF-8"))).build(); return config.getNetworkConfig().getPort(); }
config = new XmlConfigBuilder(hazelcastConfigFile).build(); config = new Config(); MapConfig cacheMapConfig = config.getMapConfig(HazelcastCacheProvider.MAP_PREFIX + "*"); cacheMapConfig.setMaxIdleSeconds(1 * 60 * 60); /* Objects are removed if they are idle for 1 hour */ cacheMapConfig.setEvictionPolicy(EvictionPolicy.LRU); cacheMapConfig.setTimeToLiveSeconds(12 * 60 * 60); /* Objects are always refreshed every 12 hours */ cacheMapConfig.setBackupCount(0); /* We're a cache we don't care if we need to visit the backing store */ cacheMapConfig.setAsyncBackupCount(0); /* We're a cache we don't care if we need to visit the backing store */ cacheMapNLConfig.setTimeToLiveSeconds(1 * 60 * 60); /* 1 hour TTL */ cacheMapConfig.setNearCacheConfig(cacheMapNLConfig); config.addMapConfig(cacheMapConfig);
if(is != null) { logger.info("customized hazelcast.xml is loaded from config."); config = new XmlConfigBuilder(is).build(); } else { logger.info("default hazelcast.xml is loaded."); config = new Config(); config.getSerializationConfig().addDataSerializableFactory(1, new UserDataSerializableFactory()); config.getSerializationConfig().addDataSerializableFactory(2, new ClientDataSerializableFactory()); config.getSerializationConfig().addDataSerializableFactory(3, new ServiceDataSerializableFactory()); config.getSerializationConfig().addDataSerializableFactory(4, new RefreshTokenDataSerializableFactory()); MapConfig serviceConfig = new MapConfig(); serviceConfig.setName("services"); NearCacheConfig serviceCacheConfig = new NearCacheConfig(); serviceCacheConfig.setEvictionPolicy("NONE"); serviceCacheConfig.setInMemoryFormat(InMemoryFormat.OBJECT); serviceCacheConfig.setCacheLocalEntries(true); // this enables the local caching serviceConfig.setNearCacheConfig(serviceCacheConfig); serviceConfig.getMapStoreConfig()
this.hazelcastConfig = new XmlConfigBuilder(hazelcastConfigFile).build(); this.hazelcastConfig = new Config(); MapConfig sessionMapConfig = this.hazelcastConfig.getMapConfig("balsa.sessions"); sessionMapConfig.setMaxIdleSeconds(this.getSessionLifetime() * 60); sessionMapConfig.setEvictionPolicy(EvictionPolicy.LRU); sessionMapConfig.setEvictionPercentage(Integer.getInteger("balsa.hazelcast.eviction-percentage", 0)); sessionMapConfig.setInMemoryFormat(InMemoryFormat.OBJECT); this.hazelcastConfig.addMapConfig(sessionMapConfig);
setImplementation(new SessionDataSerializer()). setTypeClass(SessionData.class); config = new Config(); config.getSerializationConfig().addSerializerConfig(sc); mapConfig = new MapConfig(); mapConfig.setName( mapName ); mapName = mapConfig.getName(); config.addMapConfig( mapConfig ); config = new XmlConfigBuilder( configurationLocation ).build(); config.setInstanceName( hazelcastInstanceName );
/** * Build a Hazelcast {@link com.hazelcast.config.Config}. * * @return the Hazelcast configuration. */ public Config getHazelcastConfig() { System.setProperty("hazelcast.config", xmlConfigLocation); Config config = new XmlConfigBuilder().build(); if (System.getProperty("hazelcast.instanceName") != null) { config.setInstanceName(System.getProperty("hazelcast.instanceName")); } else { config.setInstanceName("cellar"); } if (config.getNetworkConfig().getJoin().getTcpIpConfig().isEnabled() && discoveredMemberSet != null) { if (discoveryServices != null && !discoveryServices.isEmpty()) { for (DiscoveryService service : discoveryServices) { service.refresh(); Set<String> discovered = service.discoverMembers(); discoveredMemberSet.addAll(discovered); LOGGER.trace("HAZELCAST STARTUP DISCOVERY: service {} found members {}", service, discovered); } } TcpIpConfig tcpIpConfig = config.getNetworkConfig().getJoin().getTcpIpConfig(); tcpIpConfig.getMembers().addAll(discoveredMemberSet); } 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; }
@Bean public Config hazelcastConfig() { Resource location = hp.getConfigLocation(); if (location != null && location.exists()) { try { return new XmlConfigBuilder(hp.getConfigLocation() .getInputStream()).build(); } catch (IOException e) { throw new IllegalArgumentException( "Unable to use config location " + location, e); } } else { return new Config(); } }
this.hazelcastConfig = new XmlConfigBuilder(hazelcastConfigFile).build(); this.hazelcastConfig = new Config(); this.hazelcastConfig.setInstanceName(this.getBalsaApplication().getInstanceName());
/** * Creates new Config which is loaded from the given url. * * @param url the URL pointing to the Hazelcast XML file * @param properties the properties for replacing variables * @throws IOException if something fails while loading the resource * @throws IllegalArgumentException if the url or properties is {@code null} * @throws com.hazelcast.core.HazelcastException if the XML content is invalid */ public UrlXmlConfig(URL url, Properties properties) throws IOException { if (url == null) { throw new IllegalArgumentException("url can't be null"); } if (properties == null) { throw new IllegalArgumentException("properties can't be null"); } LOGGER.info("Configuring Hazelcast from '" + url.toString() + "'."); InputStream in = url.openStream(); new XmlConfigBuilder(in).setProperties(properties).build(this); } }
/** * Configure a connection as a cluster node. * * @return ClientConfig */ private com.hazelcast.config.Config loadConfig() throws Exception { final String configFile = config.getString("server.hazelcast.config"); final com.hazelcast.config.Config config = new XmlConfigBuilder( configFile ).build(); config.setProperty( "hazelcast.logging.type", "slf4j" ); return config; } }
protected static Config newDeclarativeConfig() { try { Config config = new XmlConfigBuilder("src/main/resources/hazelcast-splitbrain.xml").build(); config.setProperty("hazelcast.merge.first.run.delay.seconds", "5"); config.setProperty("hazelcast.merge.next.run.delay.seconds", "3"); config.getGroupConfig().setName(generateRandomString(10)); return config; } catch (FileNotFoundException e) { throw ExceptionUtil.rethrow(e); } }
private static HazelcastInstance createInstance(ClusteredSessionService sessionService, WebFilterConfig filterConfig) throws ServletException { LOGGER.info("Creating a new HazelcastInstance for session replication"); Config config; if (filterConfig.getConfigUrl() == null) { config = new XmlConfigBuilder().build(); } else { try { config = new UrlXmlConfig(filterConfig.getConfigUrl()); } catch (IOException e) { throw new ServletException(e); } } config.getMapConfig(filterConfig.getMapName()).setMaxIdleSeconds(filterConfig.getSessionTtlSeconds()); config.addListenerConfig(new ListenerConfig(new ServerLifecycleListener(sessionService))); return Hazelcast.newHazelcastInstance(config); }
/** * 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() ); }
private Config getConfig(Config config) { if (config == null) { config = new XmlConfigBuilder().build(); } GroupConfig groupConfig = config.getGroupConfig(); if (shouldSetGroupName(groupConfig)) { String groupName = id; if (groupConfig == null) { config.setGroupConfig(new GroupConfig(groupName)); } else { groupConfig.setName(groupName); } } return config; }
private static Config createNewConfig(String mapName) { SimpleStore simpleStore = new SimpleStore(); MapStoreConfig mapStoreConfig = new MapStoreConfig(); mapStoreConfig.setImplementation(simpleStore); mapStoreConfig.setWriteDelaySeconds(0); XmlConfigBuilder configBuilder = new XmlConfigBuilder(); Config config = configBuilder.build(); MapConfig mapConfig = config.getMapConfig(mapName); mapConfig.setMapStoreConfig(mapStoreConfig); return config; }
public static HazelcastInstance getInstance() { if (hazelcastInstance == null) { Config config = new XmlConfigBuilder().build(); config.setInstanceName(Thread.currentThread().getName()); hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(config); } return hazelcastInstance; }