Class HazelcastClusterManager
- java.lang.Object
-
- com.atlassian.confluence.cluster.hazelcast.HazelcastClusterManager
-
- All Implemented Interfaces:
com.atlassian.beehive.ClusterLockService,ClusterManager,NameResolver,LockFactory,com.atlassian.util.concurrent.Supplier<com.hazelcast.core.HazelcastInstance>,com.google.common.base.Supplier<com.hazelcast.core.HazelcastInstance>,Supplier<com.hazelcast.core.HazelcastInstance>
@ParametersAreNonnullByDefault @Internal public class HazelcastClusterManager extends Object implements ClusterManager, com.atlassian.beehive.ClusterLockService, com.google.common.base.Supplier<com.hazelcast.core.HazelcastInstance>, com.atlassian.util.concurrent.Supplier<com.hazelcast.core.HazelcastInstance>, Supplier<com.hazelcast.core.HazelcastInstance>
Hazelcast implementation ofClusterManager- Since:
- 5.6
-
-
Field Summary
-
Fields inherited from interface com.atlassian.confluence.cluster.ClusterManager
DEFAULT_EXECUTOR_SVC_NAME
-
-
Constructor Summary
Constructors Constructor Description HazelcastClusterManager(com.atlassian.config.ApplicationConfig applicationConfig, ClassLoader classLoader, String configResourceName, SynchronizationManager synchronizationManager, com.atlassian.hazelcast.serialization.OsgiSafeStreamSerializer osgiSafeStreamSerializer, com.hazelcast.core.OutOfMemoryHandler outOfMemoryHandler, io.micrometer.core.instrument.MeterRegistry micrometerRegistry, MBeanServer mbeanServer)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidconfigure(ClusterConfig clusterConfig)Set a new cluster configuration.protected com.hazelcast.core.HazelcastInstancecreateHazelcastInstance()com.hazelcast.core.HazelcastInstanceget()Collection<ClusterNodeInformation>getAllNodesInformation()ClusteredLockgetClusteredLock(String key)Get a distributed lock -- getting the lock does *not* imply that it has been acquired.ClusterInformationgetClusterInformation()Get information about the running cluster.ClusterInvariantsgetClusterInvariants()Get all attributes of the server that must be consistent between the nodes of a stable cluster.ClusterMembershipCriteriagetClusterMembershipCriteria()Get all attributes of the server that must be used as criteria when determining whether a new node can join this cluster.longgetClusterUptime()Gets the amount of time that the cluster has been running.<T> com.atlassian.core.task.FifoBuffer<T>getFifoBuffer(String name)Get a distributed FIFO bufferLockgetLock(String name)Get a lock -- getting the lock does *not* imply that it has been acquired.com.atlassian.confluence.cluster.hazelcast.DualLockgetLockForName(@NonNull String key)Map<Integer,NodeStatus>getNodeStatuses()Deprecated.Map<ClusterNodeInformation,NodeStatus>getNodeStatusMap()Gets status information from all members of the cluster.Map<ClusterNodeInformation,CompletionStage<NodeStatus>>getNodeStatusMapAsync()GetsCompletionStageof status information from all members of the cluster.StringgetSharedSecret()Get the value of config propertyconfluence.cluster.authentication.secretfrom confluence.cfg.xmlClusterNodeInformationgetThisNodeInformation()Get the identity of this node in the cluster.voidinitOutOfmemoryhandler()booleanisClustered()booleanisClusterSupported()Check whether this Confluence distribution is capable of running in a cluster.booleanisConfigured()booleanisNodeAuthEnabled()Get the value of config propertyconfluence.cluster.authentication.enabledfrom confluence.cfg.xmlvoidpublishEvent(ConfluenceEvent event)Publish an event as a ClusterEventWrapper to other nodesvoidpublishEventImmediately(ConfluenceEvent event)Publish immediately, an event as a ClusterEventWrapper to other nodesvoidreconfigure(ClusterConfig config)Set a new cluster configuration and cycle the serviceInetAddressresolveName(String name)voidstartCluster()Start the clustering servicevoidstopCluster()Stop the clustering service<T> List<ClusterNodeExecution<T>>submitToAllNodes(Callable<T> task, String serviceName)Submit a task to be executed on all nodes in the cluster.<T> CompletionStage<T>submitToKeyOwner(Callable<T> task, String serviceName, Object key)Submit a task to be executed by a service given by its name on one node of the cluster that own a given key.<T> ClusterNodeExecution<T>submitToNode(String nodeId, Callable<T> task, String serviceName)Submit a task to be executed on a node with the specified ID
-
-
-
Constructor Detail
-
HazelcastClusterManager
public HazelcastClusterManager(com.atlassian.config.ApplicationConfig applicationConfig, ClassLoader classLoader, String configResourceName, SynchronizationManager synchronizationManager, com.atlassian.hazelcast.serialization.OsgiSafeStreamSerializer osgiSafeStreamSerializer, com.hazelcast.core.OutOfMemoryHandler outOfMemoryHandler, io.micrometer.core.instrument.MeterRegistry micrometerRegistry, MBeanServer mbeanServer)
-
-
Method Detail
-
initOutOfmemoryhandler
@PostConstruct public void initOutOfmemoryhandler()
-
resolveName
public InetAddress resolveName(String name)
- Specified by:
resolveNamein interfaceNameResolver
-
isClusterSupported
public boolean isClusterSupported()
Description copied from interface:ClusterManagerCheck whether this Confluence distribution is capable of running in a cluster. This differs fromClusterManager.isClustered()in that it will return true if the code to support clustering is present, even if this instance does not have a clustered license or a current clustering configuration.- Specified by:
isClusterSupportedin interfaceClusterManager- Returns:
- true if this Confluence installation is capable of running in a cluster
-
getClusterUptime
public long getClusterUptime()
Description copied from interface:ClusterManagerGets the amount of time that the cluster has been running.- Specified by:
getClusterUptimein interfaceClusterManager- Returns:
- the time in milliseconds since the first node in the cluster came up, or the node uptime if not clustered.
-
isClustered
public boolean isClustered()
- Specified by:
isClusteredin interfaceClusterManager- Returns:
- true if this instance is configured to allow clustering with other nodes. Note, this does not mean this instance is licensed to cluster.
-
getClusterInformation
public ClusterInformation getClusterInformation()
Description copied from interface:ClusterManagerGet information about the running cluster.- Specified by:
getClusterInformationin interfaceClusterManager
-
getFifoBuffer
public <T> com.atlassian.core.task.FifoBuffer<T> getFifoBuffer(String name)
Description copied from interface:ClusterManagerGet a distributed FIFO buffer- Specified by:
getFifoBufferin interfaceClusterManager
-
publishEvent
public void publishEvent(ConfluenceEvent event)
Description copied from interface:ClusterManagerPublish an event as a ClusterEventWrapper to other nodesThis waits for any current transaction to be committed successfully before scheduling the event for publishing.
- Specified by:
publishEventin interfaceClusterManager
-
publishEventImmediately
public void publishEventImmediately(ConfluenceEvent event)
Description copied from interface:ClusterManagerPublish immediately, an event as a ClusterEventWrapper to other nodesThis is done immediately regardless of the state of any current transactions.
- Specified by:
publishEventImmediatelyin interfaceClusterManager
-
getThisNodeInformation
public ClusterNodeInformation getThisNodeInformation()
Description copied from interface:ClusterManagerGet the identity of this node in the cluster. ClusterNodeInformation implements equals().
- Specified by:
getThisNodeInformationin interfaceClusterManager- Returns:
- the identity of this node in the cluster. May return null if the node is not in a cluster.
-
getAllNodesInformation
public Collection<ClusterNodeInformation> getAllNodesInformation()
- Specified by:
getAllNodesInformationin interfaceClusterManager
-
configure
public void configure(ClusterConfig clusterConfig)
Description copied from interface:ClusterManagerSet a new cluster configuration.- Specified by:
configurein interfaceClusterManager
-
isConfigured
public boolean isConfigured()
- Specified by:
isConfiguredin interfaceClusterManager- Returns:
- true if
ClusterManager.configure(ClusterConfig)has been called with a valid configuration, otherwise false.
-
reconfigure
public void reconfigure(ClusterConfig config)
Description copied from interface:ClusterManagerSet a new cluster configuration and cycle the service- Specified by:
reconfigurein interfaceClusterManager
-
stopCluster
@PreDestroy public void stopCluster()
Description copied from interface:ClusterManagerStop the clustering service- Specified by:
stopClusterin interfaceClusterManager
-
startCluster
public void startCluster()
Description copied from interface:ClusterManagerStart the clustering service- Specified by:
startClusterin interfaceClusterManager
-
createHazelcastInstance
protected com.hazelcast.core.HazelcastInstance createHazelcastInstance()
-
getNodeStatuses
@Deprecated public Map<Integer,NodeStatus> getNodeStatuses()
Deprecated.Gets status information from all members of the cluster.- Specified by:
getNodeStatusesin interfaceClusterManager- Returns:
- a map of node IDs to node statuses
-
getNodeStatusMap
public Map<ClusterNodeInformation,NodeStatus> getNodeStatusMap()
Gets status information from all members of the cluster.- Specified by:
getNodeStatusMapin interfaceClusterManager
-
getNodeStatusMapAsync
public Map<ClusterNodeInformation,CompletionStage<NodeStatus>> getNodeStatusMapAsync()
GetsCompletionStageof status information from all members of the cluster.- Specified by:
getNodeStatusMapAsyncin interfaceClusterManager
-
getClusterMembershipCriteria
public ClusterMembershipCriteria getClusterMembershipCriteria() throws ClusterException
Description copied from interface:ClusterManagerGet all attributes of the server that must be used as criteria when determining whether a new node can join this cluster. They are to be retrieved from another member in the cluster. If there are no other members currently active in the cluster, then return null.- Specified by:
getClusterMembershipCriteriain interfaceClusterManager- Returns:
- the cluster membership criteria of this server
- Throws:
ClusterException- if the criteria cannot be gathered for some reason
-
getClusterInvariants
public ClusterInvariants getClusterInvariants() throws ClusterException
Description copied from interface:ClusterManagerGet all attributes of the server that must be consistent between the nodes of a stable cluster. They are to be retrieved from another member in the cluster. If there are no other members currently active in the cluster, then return null.- Specified by:
getClusterInvariantsin interfaceClusterManager- Returns:
- the cluster invariants of this server
- Throws:
ClusterException- if the invariants can not be gathered for some reason
-
getLockForName
public com.atlassian.confluence.cluster.hazelcast.DualLock getLockForName(@NonNull String key)
- Specified by:
getLockForNamein interfacecom.atlassian.beehive.ClusterLockService
-
getClusteredLock
public ClusteredLock getClusteredLock(String key)
Description copied from interface:ClusterManagerGet a distributed lock -- getting the lock does *not* imply that it has been acquired. CallLock.tryLock()orLock.lock()on the returned object to acquire the lock.- Specified by:
getClusteredLockin interfaceClusterManager
-
getLock
public Lock getLock(String name)
Description copied from interface:LockFactoryGet a lock -- getting the lock does *not* imply that it has been acquired. CallLock.tryLock()orLock.lock()on the returned object to acquire the lock.- Specified by:
getLockin interfaceLockFactory
-
get
public com.hazelcast.core.HazelcastInstance get()
-
submitToKeyOwner
public <T> CompletionStage<T> submitToKeyOwner(Callable<T> task, String serviceName, Object key)
Description copied from interface:ClusterManagerSubmit a task to be executed by a service given by its name on one node of the cluster that own a given key.- Specified by:
submitToKeyOwnerin interfaceClusterManager- Parameters:
task- task to be executed on the node that owns the provided key, it must beSerializableserviceName- name of service used to execute the taskkey- key used to determined which node is going to execute the task, it must beSerializable- Returns:
- CompletionStage
-
submitToNode
public <T> ClusterNodeExecution<T> submitToNode(String nodeId, Callable<T> task, String serviceName) throws NoSuchClusterNodeException
Description copied from interface:ClusterManagerSubmit a task to be executed on a node with the specified ID- Specified by:
submitToNodein interfaceClusterManager- Parameters:
nodeId- ID of the node that should execute the task. If null, task will be executed locally.task- task to be executed on the specified nodeserviceName- name of service used to execute the task- Returns:
- node execution result
- Throws:
NoSuchClusterNodeException- if there's no node in the cluster with the specified ID
-
submitToAllNodes
public <T> List<ClusterNodeExecution<T>> submitToAllNodes(Callable<T> task, String serviceName)
Description copied from interface:ClusterManagerSubmit a task to be executed on all nodes in the cluster.- Specified by:
submitToAllNodesin interfaceClusterManager- Parameters:
task- task to be executed on the node that owns the provided key, it must beSerializableserviceName- name of service used to execute the task- Returns:
- List of
ClusterNodeExecution, one element from each node
-
getSharedSecret
public String getSharedSecret()
Get the value of config propertyconfluence.cluster.authentication.secretfrom confluence.cfg.xml
-
isNodeAuthEnabled
public boolean isNodeAuthEnabled()
Get the value of config propertyconfluence.cluster.authentication.enabledfrom confluence.cfg.xml
-
-