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 classClusterServiceImpl.ClusterLockHelper
-
Field Summary
Fields Modifier and Type Field Description static intAPPLICATION_STARTED_ORDERDeprecated.since 2023.0, useComponentStartOrders.CLUSTER_SERVICEinsteadstatic StringCAPABILITY_CLUSTERstatic StringCLUSTERING_ENABLED_OLD_PROPprotected booleanenabledstatic StringNODE_ID_OLD_PROPprotected StringnodeIdprotected static RandomRANDOMstatic StringXP_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 intgetApplicationStartedOrder()The component notification order forComponent.applicationStarted(org.nuxeo.runtime.model.ComponentContext).StringgetNodeId()Returns the node id.booleanisEnabled()Checks if cluster mode is enabled.voidrunAtomically(String key, Duration duration, Duration pollDelay, Runnable runnable)Runs aRunnableatomically in a cluster-wide critical section, outside a transaction.voidsetNodeId(String nodeId)Allows tests to set the node id without a reload.voidstart(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_SERVICEinsteadVery 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:ComponentThe 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:
getApplicationStartedOrderin interfaceComponent- Returns:
- the order, 1000 by default
-
start
public void start(ComponentContext context)
Description copied from interface:ComponentStart the component. This method is called after all the components were resolved and activated- Specified by:
startin interfaceComponent- Overrides:
startin classDefaultComponent
-
isEnabled
public boolean isEnabled()
Description copied from interface:ClusterServiceChecks if cluster mode is enabled.- Specified by:
isEnabledin interfaceClusterService- Returns:
trueif cluster mode is enabled,falseif not
-
getNodeId
public String getNodeId()
Description copied from interface:ClusterServiceReturns the node id. This is nevernull.- Specified by:
getNodeIdin 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:ClusterServiceRuns aRunnableatomically in a cluster-wide critical section, outside a transaction.- Specified by:
runAtomicallyin 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
-
-