Class 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 of ClusterManager
    Since:
    5.6
    • 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()
      • isClusterSupported

        public boolean isClusterSupported()
        Description copied from interface: ClusterManager
        Check whether this Confluence distribution is capable of running in a cluster. This differs from ClusterManager.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:
        isClusterSupported in interface ClusterManager
        Returns:
        true if this Confluence installation is capable of running in a cluster
      • getClusterUptime

        public long getClusterUptime()
        Description copied from interface: ClusterManager
        Gets the amount of time that the cluster has been running.
        Specified by:
        getClusterUptime in interface ClusterManager
        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:
        isClustered in interface ClusterManager
        Returns:
        true if this instance is configured to allow clustering with other nodes. Note, this does not mean this instance is licensed to cluster.
      • getFifoBuffer

        public <T> com.atlassian.core.task.FifoBuffer<T> getFifoBuffer​(String name)
        Description copied from interface: ClusterManager
        Get a distributed FIFO buffer
        Specified by:
        getFifoBuffer in interface ClusterManager
      • publishEvent

        public void publishEvent​(ConfluenceEvent event)
        Description copied from interface: ClusterManager
        Publish an event as a ClusterEventWrapper to other nodes

        This waits for any current transaction to be committed successfully before scheduling the event for publishing.

        Specified by:
        publishEvent in interface ClusterManager
      • publishEventImmediately

        public void publishEventImmediately​(ConfluenceEvent event)
        Description copied from interface: ClusterManager
        Publish immediately, an event as a ClusterEventWrapper to other nodes

        This is done immediately regardless of the state of any current transactions.

        Specified by:
        publishEventImmediately in interface ClusterManager
      • getThisNodeInformation

        public ClusterNodeInformation getThisNodeInformation()
        Description copied from interface: ClusterManager

        Get the identity of this node in the cluster. ClusterNodeInformation implements equals().

        Specified by:
        getThisNodeInformation in interface ClusterManager
        Returns:
        the identity of this node in the cluster. May return null if the node is not in a cluster.
      • createHazelcastInstance

        protected com.hazelcast.core.HazelcastInstance createHazelcastInstance()
      • getClusterMembershipCriteria

        public ClusterMembershipCriteria getClusterMembershipCriteria()
                                                               throws ClusterException
        Description copied from interface: ClusterManager
        Get 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:
        getClusterMembershipCriteria in interface ClusterManager
        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: ClusterManager
        Get 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:
        getClusterInvariants in interface ClusterManager
        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:
        getLockForName in interface com.atlassian.beehive.ClusterLockService
      • get

        public com.hazelcast.core.HazelcastInstance get()
        Specified by:
        get in interface com.atlassian.util.concurrent.Supplier<com.hazelcast.core.HazelcastInstance>
        Specified by:
        get in interface com.google.common.base.Supplier<com.hazelcast.core.HazelcastInstance>
        Specified by:
        get in interface Supplier<com.hazelcast.core.HazelcastInstance>
      • submitToKeyOwner

        public <T> CompletionStage<T> submitToKeyOwner​(Callable<T> task,
                                                       String serviceName,
                                                       Object key)
        Description copied from interface: ClusterManager
        Submit 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:
        submitToKeyOwner in interface ClusterManager
        Parameters:
        task - task to be executed on the node that owns the provided key, it must be Serializable
        serviceName - name of service used to execute the task
        key - key used to determined which node is going to execute the task, it must be Serializable
        Returns:
        CompletionStage
      • submitToNode

        public <T> ClusterNodeExecution<T> submitToNode​(String nodeId,
                                                        Callable<T> task,
                                                        String serviceName)
                                                 throws NoSuchClusterNodeException
        Description copied from interface: ClusterManager
        Submit a task to be executed on a node with the specified ID
        Specified by:
        submitToNode in interface ClusterManager
        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 node
        serviceName - 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
      • getSharedSecret

        public String getSharedSecret()
        Get the value of config property confluence.cluster.authentication.secret from confluence.cfg.xml
      • isNodeAuthEnabled

        public boolean isNodeAuthEnabled()
        Get the value of config property confluence.cluster.authentication.enabled from confluence.cfg.xml