Search in sources :

Example 1 with PartitionGroupConfig

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;
}
Also used : PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig)

Example 2 with PartitionGroupConfig

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;
}
Also used : MalformedURLException(java.net.MalformedURLException) GlobalSerializerConfig(com.hazelcast.config.GlobalSerializerConfig) SerializationConfig(com.hazelcast.config.SerializationConfig) ExecutorConfig(com.hazelcast.config.ExecutorConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) MemberAddressProviderConfig(com.hazelcast.config.MemberAddressProviderConfig) PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) Config(com.hazelcast.config.Config) GroupConfig(com.hazelcast.config.GroupConfig) NetworkConfig(com.hazelcast.config.NetworkConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) SerializationConfig(com.hazelcast.config.SerializationConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) IOException(java.io.IOException) URL(java.net.URL) ExecutorConfig(com.hazelcast.config.ExecutorConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) GroupConfig(com.hazelcast.config.GroupConfig) PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) StreamSerializer(com.hazelcast.nio.serialization.StreamSerializer) File(java.io.File) StreamSerializer(com.hazelcast.nio.serialization.StreamSerializer) Serializer(com.hazelcast.nio.serialization.Serializer)

Example 3 with PartitionGroupConfig

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());
    }
}
Also used : PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) MemberGroupConfig(com.hazelcast.config.MemberGroupConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 4 with PartitionGroupConfig

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());
}
Also used : PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) Config(com.hazelcast.config.Config) ClasspathXmlConfig(com.hazelcast.config.ClasspathXmlConfig) MemberGroupConfig(com.hazelcast.config.MemberGroupConfig) PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) ClasspathXmlConfig(com.hazelcast.config.ClasspathXmlConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with PartitionGroupConfig

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()));
}
Also used : PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) ConfigMemberGroupFactory(com.hazelcast.internal.partition.membergroup.ConfigMemberGroupFactory) MemberGroupConfig(com.hazelcast.config.MemberGroupConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

PartitionGroupConfig (com.hazelcast.config.PartitionGroupConfig)6 MemberGroupConfig (com.hazelcast.config.MemberGroupConfig)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 Config (com.hazelcast.config.Config)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 ClasspathXmlConfig (com.hazelcast.config.ClasspathXmlConfig)1 ExecutorConfig (com.hazelcast.config.ExecutorConfig)1 GlobalSerializerConfig (com.hazelcast.config.GlobalSerializerConfig)1 GroupConfig (com.hazelcast.config.GroupConfig)1 MemberAddressProviderConfig (com.hazelcast.config.MemberAddressProviderConfig)1 MulticastConfig (com.hazelcast.config.MulticastConfig)1 NetworkConfig (com.hazelcast.config.NetworkConfig)1 ScheduledExecutorConfig (com.hazelcast.config.ScheduledExecutorConfig)1 SerializationConfig (com.hazelcast.config.SerializationConfig)1 TcpIpConfig (com.hazelcast.config.TcpIpConfig)1 ConfigMemberGroupFactory (com.hazelcast.internal.partition.membergroup.ConfigMemberGroupFactory)1 Serializer (com.hazelcast.nio.serialization.Serializer)1 StreamSerializer (com.hazelcast.nio.serialization.StreamSerializer)1 File (java.io.File)1