use of com.hazelcast.config.PartitionGroupConfig in project cas by apereo.
the class HazelcastConfigurationFactory method finalizeConfig.
private Config finalizeConfig(final Config config, final BaseHazelcastProperties hz) {
if (StringUtils.hasText(hz.getCluster().getPartitionMemberGroupType())) {
final PartitionGroupConfig partitionGroupConfig = config.getPartitionGroupConfig();
final PartitionGroupConfig.MemberGroupType type = PartitionGroupConfig.MemberGroupType.valueOf(hz.getCluster().getPartitionMemberGroupType().toUpperCase());
LOGGER.debug("Using partition member group type [{}]", type);
partitionGroupConfig.setEnabled(true).setGroupType(type);
}
return config;
}
use of com.hazelcast.config.PartitionGroupConfig in project Payara by payara.
the class HazelcastCore method buildConfiguration.
private Config buildConfiguration() {
Config config = new Config();
String hazelcastFilePath = "";
URL serverConfigURL;
try {
serverConfigURL = new URL(context.getServerConfigURL());
File serverConfigFile = new File(serverConfigURL.getPath());
hazelcastFilePath = serverConfigFile.getParentFile().getAbsolutePath() + File.separator + configuration.getHazelcastConfigurationFile();
File file = new File(hazelcastFilePath);
if (file.exists()) {
config = ConfigLoader.load(hazelcastFilePath);
if (config == null) {
Logger.getLogger(HazelcastCore.class.getName()).log(Level.WARNING, "Hazelcast Core could not find configuration file {0} using default configuration", hazelcastFilePath);
config = new Config();
}
config.setClassLoader(clh.getCommonClassLoader());
if (ctxUtil == null) {
Logger.getLogger(HazelcastCore.class.getName()).log(Level.WARNING, "Hazelcast Application Object Serialization Not Available");
} else {
SerializationConfig serConfig = config.getSerializationConfig();
if (serConfig == null) {
serConfig = new SerializationConfig();
setPayaraSerializerConfig(serConfig);
config.setSerializationConfig(serConfig);
} else {
if (serConfig.getGlobalSerializerConfig() == null) {
setPayaraSerializerConfig(serConfig);
} else {
Serializer ser = serConfig.getGlobalSerializerConfig().getImplementation();
if (ser instanceof StreamSerializer) {
config.getSerializationConfig().getGlobalSerializerConfig().setImplementation(new PayaraHazelcastSerializer(ctxUtil, (StreamSerializer<?>) ser));
} else {
Logger.getLogger(HazelcastCore.class.getName()).log(Level.WARNING, "Global serializer is not StreamSerializer: {0}", ser.getClass().getName());
}
}
}
}
} else {
// there is no config override
config.setClassLoader(clh.getCommonClassLoader());
if (ctxUtil != null) {
SerializationConfig serializationConfig = new SerializationConfig();
setPayaraSerializerConfig(serializationConfig);
config.setSerializationConfig(serializationConfig);
}
buildNetworkConfiguration(config);
config.setLicenseKey(configuration.getLicenseKey());
config.setLiteMember(Boolean.parseBoolean(nodeConfig.getLite()));
// set group config
GroupConfig gc = config.getGroupConfig();
gc.setName(configuration.getClusterGroupName());
gc.setPassword(configuration.getClusterGroupPassword());
// build the configuration
if ("true".equals(configuration.getHostAwarePartitioning())) {
PartitionGroupConfig partitionGroupConfig = config.getPartitionGroupConfig();
partitionGroupConfig.setEnabled(enabled);
partitionGroupConfig.setGroupType(PartitionGroupConfig.MemberGroupType.HOST_AWARE);
}
// build the executor config
ExecutorConfig executorConfig = config.getExecutorConfig(CLUSTER_EXECUTOR_SERVICE_NAME);
executorConfig.setStatisticsEnabled(true);
executorConfig.setPoolSize(Integer.valueOf(nodeConfig.getExecutorPoolSize()));
executorConfig.setQueueCapacity(Integer.valueOf(nodeConfig.getExecutorQueueCapacity()));
ScheduledExecutorConfig scheduledExecutorConfig = config.getScheduledExecutorConfig(SCHEDULED_CLUSTER_EXECUTOR_SERVICE_NAME);
scheduledExecutorConfig.setDurability(1);
scheduledExecutorConfig.setCapacity(Integer.valueOf(nodeConfig.getScheduledExecutorQueueCapacity()));
scheduledExecutorConfig.setPoolSize(Integer.valueOf(nodeConfig.getScheduledExecutorPoolSize()));
config.setProperty("hazelcast.jmx", "true");
}
} catch (MalformedURLException ex) {
Logger.getLogger(HazelcastCore.class.getName()).log(Level.WARNING, "Unable to parse server config URL", ex);
} catch (IOException ex) {
Logger.getLogger(HazelcastCore.class.getName()).log(Level.WARNING, "Hazelcast Core could not load configuration file " + hazelcastFilePath + " using default configuration", ex);
}
return config;
}
use of com.hazelcast.config.PartitionGroupConfig in project hazelcast by hazelcast.
the class TestFullApplicationContext method testPartitionGroupConfig.
@Test
public void testPartitionGroupConfig() {
PartitionGroupConfig pgc = config.getPartitionGroupConfig();
assertFalse(pgc.isEnabled());
assertEquals(PartitionGroupConfig.MemberGroupType.CUSTOM, pgc.getGroupType());
assertEquals(2, pgc.getMemberGroupConfigs().size());
for (MemberGroupConfig mgc : pgc.getMemberGroupConfigs()) {
assertEquals(2, mgc.getInterfaces().size());
}
}
use of com.hazelcast.config.PartitionGroupConfig in project hazelcast by hazelcast.
the class PartitionStateGeneratorTest method testXmlPartitionGroupConfig.
@Test
public void testXmlPartitionGroupConfig() {
Config config = new ClasspathXmlConfig("hazelcast-fullconfig.xml");
PartitionGroupConfig partitionGroupConfig = config.getPartitionGroupConfig();
assertTrue(partitionGroupConfig.isEnabled());
assertEquals(PartitionGroupConfig.MemberGroupType.CUSTOM, partitionGroupConfig.getGroupType());
assertEquals(2, partitionGroupConfig.getMemberGroupConfigs().size());
}
use of com.hazelcast.config.PartitionGroupConfig in project hazelcast by hazelcast.
the class PartitionStateGeneratorTest method testConfigCustomPartitionStateGenerator.
@Test
public void testConfigCustomPartitionStateGenerator() throws Exception {
PartitionGroupConfig config = new PartitionGroupConfig();
config.setEnabled(true);
config.setGroupType(PartitionGroupConfig.MemberGroupType.CUSTOM);
MemberGroupConfig mgCfg0 = new MemberGroupConfig();
MemberGroupConfig mgCfg1 = new MemberGroupConfig();
MemberGroupConfig mgCfg2 = new MemberGroupConfig();
MemberGroupConfig mgCfg3 = new MemberGroupConfig();
config.addMemberGroupConfig(mgCfg0);
config.addMemberGroupConfig(mgCfg1);
config.addMemberGroupConfig(mgCfg2);
config.addMemberGroupConfig(mgCfg3);
for (int k = 0; k < 3; k++) {
for (int i = 0; i < 255; i++) {
MemberGroupConfig mg;
switch(i % 4) {
case 0:
mg = mgCfg0;
break;
case 1:
mg = mgCfg1;
break;
case 2:
mg = mgCfg2;
break;
case 3:
mg = mgCfg3;
break;
default:
throw new IllegalArgumentException();
}
mg.addInterface("10.10." + k + "." + i);
}
}
test(new ConfigMemberGroupFactory(config.getMemberGroupConfigs()));
}
Aggregations