use of com.hazelcast.config.Config in project cas by apereo.
the class ProvidedHazelcastInstanceConfigurationTests method hazelcastInstanceIsCreatedNormally.
@Test
public void hazelcastInstanceIsCreatedNormally() throws Exception {
assertNotNull(this.hzInstance);
final Config config = this.hzInstance.getConfig();
assertTrue(config.getNetworkConfig().getJoin().getMulticastConfig().isEnabled());
assertEquals(Arrays.asList("127.0.0.1"), config.getNetworkConfig().getJoin().getTcpIpConfig().getMembers());
assertFalse(config.getNetworkConfig().isPortAutoIncrement());
assertEquals(5801, config.getNetworkConfig().getPort());
final MapConfig mapConfig = config.getMapConfig("tickets-from-external-config");
assertNotNull(mapConfig);
assertEquals(20000, mapConfig.getMaxIdleSeconds());
assertEquals(EvictionPolicy.LFU, mapConfig.getEvictionPolicy());
assertEquals(99, mapConfig.getEvictionPercentage());
}
use of com.hazelcast.config.Config in project Openfire by igniterealtime.
the class ClusteredCacheFactory method startCluster.
public boolean startCluster() {
state = State.starting;
// Set the serialization strategy to use for transmitting objects between node clusters
serializationStrategy = ExternalizableUtil.getInstance().getStrategy();
ExternalizableUtil.getInstance().setStrategy(new ClusterExternalizableUtil());
// Set session locator to use when in a cluster
XMPPServer.getInstance().setRemoteSessionLocator(new RemoteSessionLocator());
// Set packet router to use to deliver packets to remote cluster nodes
XMPPServer.getInstance().getRoutingTable().setRemotePacketRouter(new ClusterPacketRouter());
ClassLoader oldLoader = null;
// Store previous class loader (in case we change it)
oldLoader = Thread.currentThread().getContextClassLoader();
ClassLoader loader = new ClusterClassLoader();
Thread.currentThread().setContextClassLoader(loader);
int retry = 0;
do {
try {
Config config = new ClasspathXmlConfig(HAZELCAST_CONFIG_FILE);
config.setInstanceName("openfire");
config.setClassLoader(loader);
if (JMXManager.isEnabled() && HAZELCAST_JMX_ENABLED) {
config.setProperty("hazelcast.jmx", "true");
config.setProperty("hazelcast.jmx.detailed", "true");
}
hazelcast = Hazelcast.newHazelcastInstance(config);
cluster = hazelcast.getCluster();
// Update the running state of the cluster
state = cluster != null ? State.started : State.stopped;
// Set the ID of this cluster node
XMPPServer.getInstance().setNodeID(NodeID.getInstance(getClusterMemberID()));
// CacheFactory is now using clustered caches. We can add our listeners.
clusterListener = new ClusterListener(cluster);
lifecycleListener = hazelcast.getLifecycleService().addLifecycleListener(clusterListener);
membershipListener = cluster.addMembershipListener(clusterListener);
break;
} catch (Exception e) {
if (retry < CLUSTER_STARTUP_RETRY_COUNT) {
logger.warn("Failed to start clustering (" + e.getMessage() + "); " + "will retry in " + CLUSTER_STARTUP_RETRY_TIME + " seconds");
try {
Thread.sleep(CLUSTER_STARTUP_RETRY_TIME * 1000);
} catch (InterruptedException ie) {
/* ignore */
}
} else {
logger.error("Unable to start clustering - continuing in local mode", e);
state = State.stopped;
}
}
} while (retry++ < CLUSTER_STARTUP_RETRY_COUNT);
if (oldLoader != null) {
// Restore previous class loader
Thread.currentThread().setContextClassLoader(oldLoader);
}
return cluster != null;
}
use of com.hazelcast.config.Config in project spring-boot by spring-projects.
the class HazelcastInstanceFactory method getConfig.
private Config getConfig(Resource configLocation) throws IOException {
URL configUrl = configLocation.getURL();
Config config = new XmlConfigBuilder(configUrl).build();
if (ResourceUtils.isFileURL(configUrl)) {
config.setConfigurationFile(configLocation.getFile());
} else {
config.setConfigurationUrl(configUrl);
}
return config;
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class DefaultNodeExtension method createSerializationService.
public InternalSerializationService createSerializationService() {
InternalSerializationService ss;
try {
Config config = node.getConfig();
ClassLoader configClassLoader = node.getConfigClassLoader();
HazelcastInstanceImpl hazelcastInstance = node.hazelcastInstance;
PartitioningStrategy partitioningStrategy = getPartitioningStrategy(configClassLoader);
SerializationServiceBuilder builder = new DefaultSerializationServiceBuilder();
SerializationConfig serializationConfig = config.getSerializationConfig() != null ? config.getSerializationConfig() : new SerializationConfig();
byte version = (byte) node.getProperties().getInteger(GroupProperty.SERIALIZATION_VERSION);
ss = (InternalSerializationService) builder.setClassLoader(configClassLoader).setConfig(serializationConfig).setManagedContext(hazelcastInstance.managedContext).setPartitioningStrategy(partitioningStrategy).setHazelcastInstance(hazelcastInstance).setVersion(version).build();
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
return ss;
}
use of com.hazelcast.config.Config in project hazelcast by hazelcast.
the class MemberConfigRequest method writeResponse.
@Override
public void writeResponse(ManagementCenterService mcs, JsonObject root) {
final JsonObject result = new JsonObject();
ConfigXmlGenerator configXmlGenerator = new ConfigXmlGenerator(true);
Config config = mcs.getHazelcastInstance().getConfig();
String configXmlString = configXmlGenerator.generate(config);
result.add("configXmlString", configXmlString);
root.add("result", result);
}
Aggregations