Package org.nuxeo.runtime.cluster
Class ClusterServiceImpl
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.runtime.cluster.ClusterServiceImpl
-
- All Implemented Interfaces:
ClusterService
,Adaptable
,Component
,Extensible
,TimestampedService
public class ClusterServiceImpl extends DefaultComponent implements ClusterService
Implementation for the Cluster Service.- Since:
- 11.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ClusterServiceImpl.ClusterLockHelper
-
Field Summary
Fields Modifier and Type Field Description static int
APPLICATION_STARTED_ORDER
Deprecated.since 2023.0, useComponentStartOrders.CLUSTER_SERVICE
insteadstatic String
CAPABILITY_CLUSTER
static String
CLUSTERING_ENABLED_OLD_PROP
protected boolean
enabled
static String
NODE_ID_OLD_PROP
protected String
nodeId
protected static Random
RANDOM
static String
XP_CONFIG
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description ClusterServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getApplicationStartedOrder()
The component notification order forComponent.applicationStarted(org.nuxeo.runtime.model.ComponentContext)
.String
getNodeId()
Returns the node id.boolean
isEnabled()
Checks if cluster mode is enabled.void
runAtomically(String key, Duration duration, Duration pollDelay, Runnable runnable)
Runs aRunnable
atomically in a cluster-wide critical section, outside a transaction.void
setNodeId(String nodeId)
Allows tests to set the node id without a reload.void
start(ComponentContext context)
Start the component.-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, registerExtension, setLastModified, setModifiedNow, setName, stop, unregister, unregisterContribution, unregisterExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted
-
-
-
-
Field Detail
-
APPLICATION_STARTED_ORDER
@Deprecated public static final int APPLICATION_STARTED_ORDER
Deprecated.since 2023.0, useComponentStartOrders.CLUSTER_SERVICE
insteadVery early as other services depend on us.- See Also:
- Constant Field Values
-
XP_CONFIG
public static final String XP_CONFIG
- See Also:
- Constant Field Values
-
CLUSTERING_ENABLED_OLD_PROP
public static final String CLUSTERING_ENABLED_OLD_PROP
- See Also:
- Constant Field Values
-
NODE_ID_OLD_PROP
public static final String NODE_ID_OLD_PROP
- See Also:
- Constant Field Values
-
CAPABILITY_CLUSTER
public static final String CAPABILITY_CLUSTER
- Since:
- 11.5
- See Also:
- Constant Field Values
-
RANDOM
protected static final Random RANDOM
-
enabled
protected boolean enabled
-
nodeId
protected String nodeId
-
-
Method Detail
-
getApplicationStartedOrder
public int getApplicationStartedOrder()
Description copied from interface:Component
The component notification order forComponent.applicationStarted(org.nuxeo.runtime.model.ComponentContext)
.Components are notified in increasing order. Order 1000 is the default order for components that don't care. Order 100 is the repository initialization.
- Specified by:
getApplicationStartedOrder
in interfaceComponent
- Returns:
- the order, 1000 by default
-
start
public void start(ComponentContext context)
Description copied from interface:Component
Start the component. This method is called after all the components were resolved and activated- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
isEnabled
public boolean isEnabled()
Description copied from interface:ClusterService
Checks if cluster mode is enabled.- Specified by:
isEnabled
in interfaceClusterService
- Returns:
true
if cluster mode is enabled,false
if not
-
getNodeId
public String getNodeId()
Description copied from interface:ClusterService
Returns the node id. This is nevernull
.- Specified by:
getNodeId
in interfaceClusterService
- Returns:
- the node id
-
setNodeId
public void setNodeId(String nodeId)
Allows tests to set the node id without a reload.
-
runAtomically
public void runAtomically(String key, Duration duration, Duration pollDelay, Runnable runnable)
Description copied from interface:ClusterService
Runs aRunnable
atomically in a cluster-wide critical section, outside a transaction.- Specified by:
runAtomically
in interfaceClusterService
- Parameters:
key
- the key used to determine atomicityduration
- the duration during which we attempt to acquire the lockpollDelay
- the delay between two subsequent polls of the lockrunnable
- the runnable
-
-