Search in sources :

Example 11 with ExecutorConfig

use of com.hazelcast.config.ExecutorConfig 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());
            // The below are to test split-brain scenario,
            // see https://github.com/hazelcast/hazelcast/issues/17586
            // and https://github.com/hazelcast/hazelcast/issues/17260
            // config.setProperty(MAX_NO_HEARTBEAT_SECONDS.getName(), "5");
            // config.setProperty(HEARTBEAT_INTERVAL_SECONDS.getName(), "1");
            // config.setProperty(MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "5");
            // config.setProperty(MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "5");
            // can't quite set it to zero yet because of:
            // https://github.com/hazelcast/hazelcast/issues/17586
            config.setProperty(WAIT_SECONDS_BEFORE_JOIN.getName(), "1");
            if (ctxUtil != null) {
                SerializationConfig serializationConfig = new SerializationConfig();
                setPayaraSerializerConfig(serializationConfig);
                config.setSerializationConfig(serializationConfig);
            }
            buildNetworkConfiguration(config);
            config.setLicenseKey(configuration.getLicenseKey());
            config.setLiteMember(Boolean.parseBoolean(nodeConfig.getLite()));
            config.setClusterName(configuration.getClusterGroupName());
            // 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");
        }
        if (config.getCPSubsystemConfig().getCPMemberCount() == 0) {
            config.getCPSubsystemConfig().setCPMemberCount(Integer.getInteger("hazelcast.cp-subsystem.cp-member-count", 0));
        }
    } 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) 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) StreamSerializer(com.hazelcast.nio.serialization.StreamSerializer) File(java.io.File) StreamSerializer(com.hazelcast.nio.serialization.StreamSerializer) Serializer(com.hazelcast.nio.serialization.Serializer)

Example 12 with ExecutorConfig

use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.

the class DistributedExecutorService method execute.

public void execute(String name, String uuid, Callable callable, Operation op) {
    ExecutorConfig cfg = getOrFindExecutorConfig(name);
    if (cfg.isStatisticsEnabled()) {
        startPending(name);
    }
    CallableProcessor processor = new CallableProcessor(name, uuid, callable, op, cfg.isStatisticsEnabled());
    if (uuid != null) {
        submittedTasks.put(uuid, processor);
    }
    try {
        executionService.execute(name, processor);
    } catch (RejectedExecutionException e) {
        if (cfg.isStatisticsEnabled()) {
            rejectExecution(name);
        }
        logger.warning("While executing " + callable + " on Executor[" + name + "]", e);
        if (uuid != null) {
            submittedTasks.remove(uuid);
        }
        processor.sendResponse(e);
    }
}
Also used : RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutorConfig(com.hazelcast.config.ExecutorConfig)

Example 13 with ExecutorConfig

use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.

the class ExecutionServiceImpl method register.

@Override
public ManagedExecutorService register(String name, int defaultPoolSize, int defaultQueueCapacity, ExecutorType type) {
    ExecutorConfig config = nodeEngine.getConfig().getExecutorConfigs().get(name);
    int poolSize = defaultPoolSize;
    int queueCapacity = defaultQueueCapacity;
    if (config != null) {
        poolSize = config.getPoolSize();
        if (config.getQueueCapacity() <= 0) {
            queueCapacity = Integer.MAX_VALUE;
        } else {
            queueCapacity = config.getQueueCapacity();
        }
    }
    ManagedExecutorService executor = createExecutor(name, poolSize, queueCapacity, type);
    if (executors.putIfAbsent(name, executor) != null) {
        throw new IllegalArgumentException("ExecutorService['" + name + "'] already exists!");
    }
    metricsRegistry.scanAndRegister(executor, "executor.[" + name + "]");
    return executor;
}
Also used : ManagedExecutorService(com.hazelcast.util.executor.ManagedExecutorService) ExecutorConfig(com.hazelcast.config.ExecutorConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig)

Example 14 with ExecutorConfig

use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.

the class ConsoleApp method main.

/**
     * Starts the test application.
     *
     * Loads the config from classpath hazelcast.xml, if it fails to load, will use default config.
     */
public static void main(String[] args) throws Exception {
    Config config;
    try {
        config = new FileSystemXmlConfig("hazelcast.xml");
    } catch (FileNotFoundException e) {
        config = new Config();
    }
    for (int i = 1; i <= LOAD_EXECUTORS_COUNT; i++) {
        config.addExecutorConfig(new ExecutorConfig(EXECUTOR_NAMESPACE + " " + i).setPoolSize(i));
    }
    ConsoleApp consoleApp = new ConsoleApp(Hazelcast.newHazelcastInstance(config));
    consoleApp.start();
}
Also used : ExecutorConfig(com.hazelcast.config.ExecutorConfig) FileSystemXmlConfig(com.hazelcast.config.FileSystemXmlConfig) Config(com.hazelcast.config.Config) FileNotFoundException(java.io.FileNotFoundException) FileSystemXmlConfig(com.hazelcast.config.FileSystemXmlConfig) ExecutorConfig(com.hazelcast.config.ExecutorConfig)

Example 15 with ExecutorConfig

use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.

the class AddExecutorConfigMessageTask method getConfig.

@Override
protected IdentifiedDataSerializable getConfig() {
    ExecutorConfig config = new ExecutorConfig(parameters.name, parameters.poolSize);
    config.setQueueCapacity(parameters.queueCapacity);
    config.setStatisticsEnabled(parameters.statisticsEnabled);
    return config;
}
Also used : ExecutorConfig(com.hazelcast.config.ExecutorConfig)

Aggregations

ExecutorConfig (com.hazelcast.config.ExecutorConfig)30 DurableExecutorConfig (com.hazelcast.config.DurableExecutorConfig)15 ScheduledExecutorConfig (com.hazelcast.config.ScheduledExecutorConfig)15 Config (com.hazelcast.config.Config)12 Test (org.junit.Test)11 QuickTest (com.hazelcast.test.annotation.QuickTest)10 HazelcastInstance (com.hazelcast.core.HazelcastInstance)9 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)9 IExecutorService (com.hazelcast.core.IExecutorService)6 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)5 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)5 FlakeIdGeneratorConfig (com.hazelcast.config.FlakeIdGeneratorConfig)5 ListConfig (com.hazelcast.config.ListConfig)5 MapConfig (com.hazelcast.config.MapConfig)5 MultiMapConfig (com.hazelcast.config.MultiMapConfig)5 PNCounterConfig (com.hazelcast.config.PNCounterConfig)5 QueueConfig (com.hazelcast.config.QueueConfig)5 ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)5 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)5 RingbufferConfig (com.hazelcast.config.RingbufferConfig)5