Class ClusterNode
- java.lang.Object
-
- org.apache.jackrabbit.core.cluster.ClusterNode
-
- All Implemented Interfaces:
Runnable
,ClusterRecordProcessor
,NamespaceEventChannel
,NodeTypeEventChannel
,PrivilegeEventChannel
,WorkspaceEventChannel
,RecordConsumer
public class ClusterNode extends Object implements Runnable, NamespaceEventChannel, NodeTypeEventChannel, RecordConsumer, ClusterRecordProcessor, WorkspaceEventChannel, PrivilegeEventChannel
Default clustered node implementation.
-
-
Field Summary
Fields Modifier and Type Field Description static String
SYSTEM_PROPERTY_NODE_ID
System property specifying a node id to use.
-
Constructor Summary
Constructors Constructor Description ClusterNode()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
consume(Record record)
Consume a record.LockEventChannel
createLockChannel(String workspace)
Create aLockEventChannel
for some workspace.UpdateEventChannel
createUpdateChannel(String workspace)
Create anUpdateEventChannel
for some workspace.protected void
disableAutoSync()
Disable periodic background synchronization.void
ended(DefaultClusterOperation operation, boolean successful)
Invoked when a cluster operation has ended.String
getId()
Return the unique identifier of the records this consumer will be able to handle.Journal
getJournal()
Return the journal created by this cluster node.long
getRevision()
Return the revision this consumer has last seen.long
getStopDelay()
Return the stop delay.protected void
init()
Initialize this cluster node (overridable).void
init(ClusterContext clusterContext)
Initialize this cluster node.void
process(ChangeLogRecord record)
Process a change log record.void
process(LockRecord record)
Process a lock record.void
process(NamespaceRecord record)
Process a namespace record.void
process(NodeTypeRecord record)
Process a node type recordvoid
process(PrivilegeRecord record)
Process a privilege recordvoid
process(WorkspaceRecord record)
Process a workspace recordvoid
registered(Collection ntDefs)
Called when one or more node types have been registered.void
registeredPrivileges(Collection<PrivilegeDefinition> definitions)
void
remapped(String oldPrefix, String newPrefix, String uri)
Called when a namespace has been remapped.void
reregistered(QNodeTypeDefinition ntDef)
Called when a node types has been re-registered.void
run()
Run loop that will sync this node after some delay.void
setListener(NamespaceEventListener listener)
Set listener that will receive information about incoming, external namespace events.void
setListener(NodeTypeEventListener listener)
Set listener that will receive information about incoming, external node type events.void
setListener(PrivilegeEventListener listener)
void
setListener(WorkspaceListener listener)
void
setRevision(long revision)
Set the revision this consumer has last seen.void
setStopDelay(long stopDelay)
Set the stop delay, i.e.void
start()
Starts this cluster node.void
stop()
Stops this cluster node.void
sync()
Synchronize contents from journal.void
syncOnStartup()
Synchronize contents from journal when aClusterNode
starts up.void
unregistered(Collection qnames)
Called when one or more node types have been unregistered.void
workspaceCreated(String workspaceName, ClonedInputSource inputSource)
-
-
-
Field Detail
-
SYSTEM_PROPERTY_NODE_ID
public static final String SYSTEM_PROPERTY_NODE_ID
System property specifying a node id to use.- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init(ClusterContext clusterContext) throws ClusterException
Initialize this cluster node.- Parameters:
clusterContext
- The cluster context.- Throws:
ClusterException
- if an error occurs
-
init
protected void init() throws ClusterException
Initialize this cluster node (overridable).- Throws:
ClusterException
- if an error occurs
-
setStopDelay
public void setStopDelay(long stopDelay)
Set the stop delay, i.e. number of millseconds to wait for the synchronization thread to stop.- Parameters:
stopDelay
- stop delay in milliseconds
-
getStopDelay
public long getStopDelay()
Return the stop delay.- Returns:
- stop delay
- See Also:
setStopDelay(long)
-
disableAutoSync
protected void disableAutoSync()
Disable periodic background synchronization. Used for testing purposes, only.
-
start
public void start() throws ClusterException
Starts this cluster node.- Throws:
ClusterException
- if an error occurs
-
run
public void run()
Run loop that will sync this node after some delay.
-
sync
public void sync() throws ClusterException
Synchronize contents from journal.- Throws:
ClusterException
- if an error occurs
-
syncOnStartup
public void syncOnStartup() throws ClusterException
Synchronize contents from journal when aClusterNode
starts up.- Throws:
ClusterException
- if an error occurs
-
stop
public void stop()
Stops this cluster node.
-
createUpdateChannel
public UpdateEventChannel createUpdateChannel(String workspace)
Create anUpdateEventChannel
for some workspace.- Parameters:
workspace
- workspace name- Returns:
- lock event channel
-
createLockChannel
public LockEventChannel createLockChannel(String workspace)
Create aLockEventChannel
for some workspace.- Parameters:
workspace
- workspace name- Returns:
- lock event channel
-
getJournal
public Journal getJournal()
Return the journal created by this cluster node.- Returns:
- journal
-
remapped
public void remapped(String oldPrefix, String newPrefix, String uri)
Called when a namespace has been remapped.- Specified by:
remapped
in interfaceNamespaceEventChannel
- Parameters:
oldPrefix
- old prefix. ifnull
this is a fresh mappingnewPrefix
- new prefix. ifnull
this is an unmap operationuri
- uri to map prefix to
-
setListener
public void setListener(NamespaceEventListener listener)
Description copied from interface:NamespaceEventChannel
Set listener that will receive information about incoming, external namespace events.- Specified by:
setListener
in interfaceNamespaceEventChannel
- Parameters:
listener
- namespace event listener
-
registered
public void registered(Collection ntDefs)
Called when one or more node types have been registered.- Specified by:
registered
in interfaceNodeTypeEventChannel
- Parameters:
ntDefs
- collection of node type definitions
-
reregistered
public void reregistered(QNodeTypeDefinition ntDef)
Called when a node types has been re-registered.- Specified by:
reregistered
in interfaceNodeTypeEventChannel
- Parameters:
ntDef
- node type definition
-
unregistered
public void unregistered(Collection qnames)
Called when one or more node types have been unregistered.- Specified by:
unregistered
in interfaceNodeTypeEventChannel
- Parameters:
qnames
- collection of node type qnames
-
setListener
public void setListener(NodeTypeEventListener listener)
Set listener that will receive information about incoming, external node type events.- Specified by:
setListener
in interfaceNodeTypeEventChannel
- Parameters:
listener
- node type event listener
-
registeredPrivileges
public void registeredPrivileges(Collection<PrivilegeDefinition> definitions)
- Specified by:
registeredPrivileges
in interfacePrivilegeEventChannel
- See Also:
PrivilegeEventChannel.registeredPrivileges(java.util.Collection)
-
setListener
public void setListener(PrivilegeEventListener listener)
- Specified by:
setListener
in interfacePrivilegeEventChannel
-
getId
public String getId()
Return the unique identifier of the records this consumer will be able to handle.- Specified by:
getId
in interfaceRecordConsumer
- Returns:
- unique identifier
-
getRevision
public long getRevision()
Return the revision this consumer has last seen.- Specified by:
getRevision
in interfaceRecordConsumer
- Returns:
- revision
-
consume
public void consume(Record record)
Consume a record.- Specified by:
consume
in interfaceRecordConsumer
- Parameters:
record
- record to consume
-
setRevision
public void setRevision(long revision)
Set the revision this consumer has last seen.- Specified by:
setRevision
in interfaceRecordConsumer
- Parameters:
revision
- revision
-
process
public void process(ChangeLogRecord record)
Process a change log record.- Specified by:
process
in interfaceClusterRecordProcessor
- Parameters:
record
- change log record
-
process
public void process(LockRecord record)
Process a lock record.- Specified by:
process
in interfaceClusterRecordProcessor
- Parameters:
record
- lock record
-
process
public void process(NamespaceRecord record)
Process a namespace record.- Specified by:
process
in interfaceClusterRecordProcessor
- Parameters:
record
- namespace record
-
process
public void process(NodeTypeRecord record)
Process a node type record- Specified by:
process
in interfaceClusterRecordProcessor
- Parameters:
record
- node type record
-
process
public void process(PrivilegeRecord record)
Description copied from interface:ClusterRecordProcessor
Process a privilege record- Specified by:
process
in interfaceClusterRecordProcessor
- Parameters:
record
- privilege record
-
process
public void process(WorkspaceRecord record)
Description copied from interface:ClusterRecordProcessor
Process a workspace record- Specified by:
process
in interfaceClusterRecordProcessor
- Parameters:
record
- workspace record
-
setListener
public void setListener(WorkspaceListener listener)
- Specified by:
setListener
in interfaceWorkspaceEventChannel
-
workspaceCreated
public void workspaceCreated(String workspaceName, ClonedInputSource inputSource)
- Specified by:
workspaceCreated
in interfaceWorkspaceEventChannel
-
ended
public void ended(DefaultClusterOperation operation, boolean successful)
Invoked when a cluster operation has ended. Ifsuccessful
, attempts to fill the journal record and update it, otherwise cancels the update.- Parameters:
operation
- cluster operationsuccessful
-true
if the operation was successful and the journal record should be updated;false
to revoke changes
-
-