com.atlassian.confluence.cluster.hazelcast
Class HazelcastClusterManager

java.lang.Object
  extended by 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>

@Internal
public class HazelcastClusterManager
extends java.lang.Object
implements ClusterManager, com.atlassian.beehive.ClusterLockService, com.atlassian.util.concurrent.Supplier<com.hazelcast.core.HazelcastInstance>


Constructor Summary
HazelcastClusterManager(com.atlassian.config.ApplicationConfig applicationConfig, java.lang.ClassLoader applicationClassLoader, java.lang.String configResourceName, SynchronizationManager synchronizationManager)
           
 
Method Summary
 void configure(ClusterConfig clusterConfig)
          Set a new cluster configuration.
 com.hazelcast.core.HazelcastInstance get()
           
 java.util.Collection<ClusterNodeInformation> getAllNodesInformation()
           
 ClusteredLock getClusteredLock(java.lang.String key)
          Get a distributed lock -- getting the lock does *not* imply that it has been acquired.
 ClusterInformation getClusterInformation()
          Get information about the running cluster.
 ClusterInvariants getClusterInvariants()
          Get all attributes of the server that must be consistent between cluster nodes.
<T> com.atlassian.core.task.FifoBuffer<T>
getFifoBuffer(java.lang.String name)
          Get a distributed FIFO buffer
 Lock getLock(java.lang.String name)
          Get a lock -- getting the lock does *not* imply that it has been acquired.
 com.atlassian.confluence.cluster.hazelcast.HazelcastDualLock getLockForName(java.lang.String key)
           
 java.util.Map<java.lang.Integer,NodeStatus> getNodeStatuses()
          Deprecated. 
 java.util.Map<ClusterNodeInformation,NodeStatus> getNodeStatusMap()
          Gets status information from all members of the cluster.
 int getPermittedClusterNodes()
           
 java.io.Serializable getPublishedObject(java.lang.String key)
          Retrieve an object which another node in the cluster has shared, return null if no such object exists
 ClusterNodeInformation getThisNodeInformation()
           Get the identity of this node in the cluster.
 boolean isClustered()
           
 boolean isClusterSupported()
          Check whether this Confluence distribution is capable of running in a cluster.
 boolean isConfigured()
           
 void publishEvent(ConfluenceEvent event)
          Publish an event as a ClusterEventWrapper to other nodes
 void publishObject(java.lang.String key, java.io.Serializable object)
          Share an object to the cluster under a particular key.
 void reconfigure(ClusterConfig config)
          Set a new cluster configuration and cycle the service
 java.net.InetAddress resolveName(java.lang.String name)
           
 void startCluster()
          Start the clustering service
 void stopCluster()
          Stop the clustering service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HazelcastClusterManager

public HazelcastClusterManager(com.atlassian.config.ApplicationConfig applicationConfig,
                               java.lang.ClassLoader applicationClassLoader,
                               java.lang.String configResourceName,
                               SynchronizationManager synchronizationManager)
Method Detail

resolveName

public java.net.InetAddress resolveName(java.lang.String name)
Specified by:
resolveName in interface NameResolver

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

publishObject

public void publishObject(java.lang.String key,
                          java.io.Serializable object)
Description copied from interface: ClusterManager
Share an object to the cluster under a particular key. Note that once an object is published it will remain available for the duration of the cluster.

Specified by:
publishObject in interface ClusterManager

getPublishedObject

public java.io.Serializable getPublishedObject(java.lang.String key)
Description copied from interface: ClusterManager
Retrieve an object which another node in the cluster has shared, return null if no such object exists

Specified by:
getPublishedObject in interface ClusterManager
Returns:
a shared Object

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.

getPermittedClusterNodes

public int getPermittedClusterNodes()
Specified by:
getPermittedClusterNodes in interface ClusterManager
Returns:
if licensed for clustering, then returns Integer.MAX_VALUE, otherwise returns 0.

getClusterInformation

public ClusterInformation getClusterInformation()
Description copied from interface: ClusterManager
Get information about the running cluster.

Specified by:
getClusterInformation in interface ClusterManager

getFifoBuffer

public <T> com.atlassian.core.task.FifoBuffer<T> getFifoBuffer(java.lang.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

Specified by:
publishEvent 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.

getAllNodesInformation

public java.util.Collection<ClusterNodeInformation> getAllNodesInformation()
Specified by:
getAllNodesInformation in interface ClusterManager

configure

public void configure(ClusterConfig clusterConfig)
Description copied from interface: ClusterManager
Set a new cluster configuration.

Specified by:
configure in interface ClusterManager

isConfigured

public boolean isConfigured()
Specified by:
isConfigured in interface ClusterManager
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: ClusterManager
Set a new cluster configuration and cycle the service

Specified by:
reconfigure in interface ClusterManager

stopCluster

@PreDestroy
public void stopCluster()
Description copied from interface: ClusterManager
Stop the clustering service

Specified by:
stopCluster in interface ClusterManager

startCluster

public void startCluster()
Description copied from interface: ClusterManager
Start the clustering service

Specified by:
startCluster in interface ClusterManager

getNodeStatuses

@Deprecated
public java.util.Map<java.lang.Integer,NodeStatus> getNodeStatuses()
Deprecated. 

Gets status information from all members of the cluster.

Specified by:
getNodeStatuses in interface ClusterManager
Returns:
a map of node IDs to node statuses

getNodeStatusMap

public java.util.Map<ClusterNodeInformation,NodeStatus> getNodeStatusMap()
Gets status information from all members of the cluster.

Specified by:
getNodeStatusMap in interface ClusterManager

getClusterInvariants

public ClusterInvariants getClusterInvariants()
                                       throws ClusterException
Description copied from interface: ClusterManager
Get all attributes of the server that must be consistent between cluster nodes. 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.HazelcastDualLock getLockForName(@Nonnull
                                                                                   java.lang.String key)
Specified by:
getLockForName in interface com.atlassian.beehive.ClusterLockService

getClusteredLock

public ClusteredLock getClusteredLock(java.lang.String key)
Description copied from interface: ClusterManager
Get a distributed lock -- getting the lock does *not* imply that it has been acquired. Call Lock.tryLock() or Lock.lock() on the returned object to acquire the lock.

Specified by:
getClusteredLock in interface ClusterManager

getLock

public Lock getLock(java.lang.String name)
Description copied from interface: LockFactory
Get a lock -- getting the lock does *not* imply that it has been acquired. Call Lock.tryLock() or Lock.lock() on the returned object to acquire the lock.

Specified by:
getLock in interface LockFactory

get

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


Copyright © 2003-2014 Atlassian. All Rights Reserved.