
com.hazelcast.spi.properties.ClusterProperty Maven / Gradle / Ivy
/*
* Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hazelcast.spi.properties;
import com.hazelcast.instance.BuildInfoProvider;
import com.hazelcast.internal.util.RuntimeAvailableProcessors;
import java.util.function.Function;
import static java.lang.Math.max;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
/**
* Defines the name and default value for Hazelcast properties.
*/
@SuppressWarnings({"checkstyle:magicnumber"})
public final class ClusterProperty {
/**
* If the bytebuffers used in the socket should be a direct bytebuffer ({@code true})
* or a regular bytebuffer ({@code false}).
*/
public static final HazelcastProperty SOCKET_CLIENT_BUFFER_DIRECT
= new HazelcastProperty("hazelcast.socket.client.buffer.direct", false);
/**
* The number of threads doing socket input and the number of threads doing
* socket output.
*
* E.g., if 3 is configured, then you get 3 threads doing input and 3 doing
* output. For individual control, check { #IO_INPUT_THREAD_COUNT} and
* { #IO_OUTPUT_THREAD_COUNT}.
*
* The default is depends on the number of available processors. If the
* available processors count is smaller than 20, there will be 3+3 io threads,
* otherwise 4+4.
*
* If SSL is enabled, then the default number of IO threads will be corecount/2.
*/
@SuppressWarnings("AnonInnerLength")
public static final HazelcastProperty IO_THREAD_COUNT
= new HazelcastProperty("hazelcast.io.thread.count", new Function() {
@Override
public Integer apply(HazelcastProperties properties) {
return getWhenNoSSLDetected();
}
private int getWhenNoSSLDetected() {
return RuntimeAvailableProcessors.get() >= 20 ? 4 : 3;
}
});
/**
* Client protocol message size limit (in bytes) for unverified connections
* (i.e. maximal length of authentication message).
*/
public static final HazelcastProperty CLIENT_PROTOCOL_UNVERIFIED_MESSAGE_BYTES =
new HazelcastProperty("hazelcast.client.protocol.max.message.bytes", 4096);
/*
* CLUSTER / MEMBERSHIP / JOIN / DISCOVERY / PARTITIONING PROPERTIES
*/
/**
* Total number of partitions in the Hazelcast cluster.
*/
public static final HazelcastProperty PARTITION_COUNT
= new HazelcastProperty("hazelcast.partition.count", 271);
/**
* Enables the Discovery SPI lookup
* Discovery SPI is disabled by default
*/
public static final HazelcastProperty DISCOVERY_SPI_ENABLED
= new HazelcastProperty("hazelcast.discovery.enabled", false);
/**
* Class name implementing { com.hazelcast.partition.PartitioningStrategy}, which
* defines key to partition mapping. Member-side equivalent of client property
* { com.hazelcast.client.properties.ClientProperty#PARTITIONING_STRATEGY_CLASS}.
*/
public static final HazelcastProperty PARTITIONING_STRATEGY_CLASS
= new HazelcastProperty("hazelcast.partitioning.strategy.class", "");
/**
* Result size limit for query operations on maps.
*
* This value defines the maximum number of returned elements for a single
* query result. If a query exceeds this number of elements, a
* { QueryResultSizeExceededException} will be thrown.
*
* This feature prevents an OOME if a single node is requesting the whole
* data set of the cluster, such as by executing a query with
* { Predicates#alwaysTrue()} predicate. This applies internally for
* the { IMap#values()}, { IMap#keySet()} and { IMap#entrySet()}
* methods, which are good candidates for OOME in large clusters.
*
* This feature depends on an equal distribution of the data on the cluster
* nodes to calculate the result size limit per node.
* Therefore, there is a minimum value of
* { QueryResultSizeLimiter#MINIMUM_MAX_RESULT_LIMIT} defined in
* { QueryResultSizeLimiter}. Configured values below the minimum will
* be increased to the minimum.
*
* The feature can be disabled by setting its value to {@code -1} (which is
* the default value).
*/
public static final HazelcastProperty QUERY_RESULT_SIZE_LIMIT
= new HazelcastProperty("hazelcast.query.result.size.limit", -1);
/**
* If an operation has backups, this property specifies how long the
* invocation will wait for acks from the backup replicas.
* If acks are not received from some backups, there will not be any
* rollback on other successful replicas.
*/
public static final HazelcastProperty OPERATION_BACKUP_TIMEOUT_MILLIS
= new HazelcastProperty("hazelcast.operation.backup.timeout.millis", 5000, MILLISECONDS);
/**
* Using back pressure, you can prevent an overload of pending asynchronous
* backups. With a map with a single asynchronous backup, producing asynchronous
* backups could happen at a higher rate than the consumption of the backup.
* This can eventually lead to an OOME (especially if the backups are slow).
*
* With back-pressure enabled, this can't happen.
*
* Back pressure is implemented by making asynchronous backups operations
* synchronous. This prevents the internal queues from overflowing because
* the invoker will wait for the primary and for the backups to complete.
* The frequency of this is determined by the sync-window.
*
* To deal with overloads of backups, the property
* { #OPERATION_BACKUP_TIMEOUT_MILLIS} should be set to a larger value;
* above 60000 is recommended. Otherwise it can still happen backups
* accumulate.
*/
public static final HazelcastProperty BACKPRESSURE_ENABLED
= new HazelcastProperty("hazelcast.backpressure.enabled", false);
/**
* The number of partition operation handler threads per member.
*
* If this is less than the number of partitions on a member, partition operations
* will queue behind other operations of different partitions.
*/
public static final HazelcastProperty PARTITION_OPERATION_THREAD_COUNT
= new HazelcastProperty("hazelcast.operation.thread.count",
(Function) properties -> max(2, RuntimeAvailableProcessors.get()));
/**
* The number of generic operation handler threads per member.
*
* The default is max(2, processors/2);
*/
public static final HazelcastProperty GENERIC_OPERATION_THREAD_COUNT
= new HazelcastProperty("hazelcast.operation.generic.thread.count",
(Function) o -> {
// default generic operation thread count
int processors = RuntimeAvailableProcessors.get();
return max(2, processors / 2);
});
/**
* Number of threads for the { com.hazelcast.spi.impl.eventservice.impl.EventServiceImpl}
* executor.
* The executor is responsible for executing the events. If you process a
* lot of events and have many cores, setting a higher value is a good practice.
* This way, more events can be processed in parallel.
*/
public static final HazelcastProperty EVENT_THREAD_COUNT
= new HazelcastProperty("hazelcast.event.thread.count", 5);
/**
* Name of logging framework type to send logging events.
*/
public static final HazelcastProperty LOGGING_TYPE
= new HazelcastProperty("hazelcast.logging.type", "jdk");
/**
* Controls whether cluster name, ip and version should be included in all
* log messages.
*/
public static final HazelcastProperty LOGGING_ENABLE_DETAILS
= new HazelcastProperty("hazelcast.logging.details.enabled", true);
/**
* Controls whether Hazelcast will explicitly shutdown the logging implementation as part of
* Hazelcast graceful shutdown procedure. Default value is {@code false}.
*
* This property can be enabled when Hazelcast is the only application being executed in the JVM,
* for example, when running a Hazelcast cluster member in its own process.
* If the JVM process is expected to continue executing other application bits after Hazelcast is shut down, then
* if this property is {@code true}, logging may be disrupted.
*
* @since 5.4.0
*/
public static final HazelcastProperty LOGGING_SHUTDOWN
= new HazelcastProperty("hazelcast.logging.shutdown", false);
/**
* Hazelcast serialization version. This is single byte value between 1 and
* Max supported serialization version.
* BuildInfo#getSerializationVersion()
*/
public static final HazelcastProperty SERIALIZATION_VERSION
= new HazelcastProperty("hazelcast.serialization.version",
BuildInfoProvider.getBuildInfo().getSerializationVersion());
private ClusterProperty() {
}
}