Package fish.payara.nucleus.config
Class ClusteredConfig
- java.lang.Object
-
- com.hazelcast.cluster.MembershipAdapter
-
- fish.payara.nucleus.config.ClusteredConfig
-
- All Implemented Interfaces:
com.hazelcast.cluster.MembershipListener
,EventListener
@Service @RunLevel(10) public class ClusteredConfig extends com.hazelcast.cluster.MembershipAdapter
TheClusteredConfig
can hold configurations that should have a common values that is based on local configuration values but at the same time accessible to all instances in the cluster. Such cases are not supported by the configuration originating fromdomain.xml
. First of all non DAS instances only have their own data available. Secondly with micro instances involved multiple instances can see themselves as the DAS instance each with its own local value. This configurations allows to take a local configuration property and share it with the other instances. The effective value for each instance will be computed from a mergeBiFunction
on the basis of the local values shared by the other instances.- Since:
- 5.201
- Author:
- Jan Bernitt
-
-
Constructor Summary
Constructors Constructor Description ClusteredConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearSharedConfiguration(String name)
Can be used to clear the shared value of this instance before the instance is shut down.<T extends Number>
TgetSharedConfiguration(String name, T localValue, BiFunction<T,T,T> merge)
Accesses and merges a shared configuration property.void
memberRemoved(com.hazelcast.cluster.MembershipEvent event)
void
postConstruct()
void
preDestroy()
-
-
-
Method Detail
-
postConstruct
@PostConstruct public void postConstruct()
-
preDestroy
@PreDestroy public void preDestroy()
-
getSharedConfiguration
public <T extends Number> T getSharedConfiguration(String name, T localValue, BiFunction<T,T,T> merge)
Accesses and merges a shared configuration property. Shared configurations are values that use a common value for each instance. The value used is computed by a merge function from all local values when those become relevant. For example a local value of a disabled feature for that instance is not relevant and therefore not considered for the shared value. In practice this means when an instance is accessing a value that is a common or shared configuration it calls this method with its local configuration value which makes it effective for this and other instances.- Parameters:
name
- the globally unique name for the configuration property to readlocalValue
- the value as configured locally or a fallback or default valuemerge
- the function to use to resolve both local and shared value being present. The resolved value is always going to be the new shared value. If no value was shared so far the local value is always the new shared and result value.- Returns:
- the merged value, local value is the default in case no other instances shared the configuration
-
clearSharedConfiguration
public void clearSharedConfiguration(String name)
Can be used to clear the shared value of this instance before the instance is shut down.- Parameters:
name
- the globally unique name for the configuration property to clear
-
memberRemoved
public void memberRemoved(com.hazelcast.cluster.MembershipEvent event)
- Specified by:
memberRemoved
in interfacecom.hazelcast.cluster.MembershipListener
- Overrides:
memberRemoved
in classcom.hazelcast.cluster.MembershipAdapter
-
-