@Service
@RunLevel(value=10)
public class ClusteredConfig
extends com.hazelcast.cluster.MembershipAdapter
ClusteredConfig
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 from domain.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 merge BiFunction
on the basis of the local values
shared by the other instances.Constructor and Description |
---|
ClusteredConfig() |
Modifier and Type | Method and 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> |
getSharedConfiguration(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() |
@PostConstruct public void postConstruct()
@PreDestroy public void preDestroy()
public <T extends Number> T getSharedConfiguration(String name, T localValue, BiFunction<T,T,T> merge)
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.public void clearSharedConfiguration(String name)
name
- the globally unique name for the configuration property to clearpublic void memberRemoved(com.hazelcast.cluster.MembershipEvent event)
memberRemoved
in interface com.hazelcast.cluster.MembershipListener
memberRemoved
in class com.hazelcast.cluster.MembershipAdapter
Copyright © 2021. All rights reserved.