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;
}
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);
}
}
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;
}
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();
}
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;
}
Aggregations