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 StringSYSTEM_PROPERTY_NODE_IDSystem 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 voidconsume(Record record)Consume a record.LockEventChannelcreateLockChannel(String workspace)Create aLockEventChannelfor some workspace.UpdateEventChannelcreateUpdateChannel(String workspace)Create anUpdateEventChannelfor some workspace.protected voiddisableAutoSync()Disable periodic background synchronization.voidended(DefaultClusterOperation operation, boolean successful)Invoked when a cluster operation has ended.StringgetId()Return the unique identifier of the records this consumer will be able to handle.JournalgetJournal()Return the journal created by this cluster node.longgetRevision()Return the revision this consumer has last seen.longgetStopDelay()Return the stop delay.protected voidinit()Initialize this cluster node (overridable).voidinit(ClusterContext clusterContext)Initialize this cluster node.voidprocess(ChangeLogRecord record)Process a change log record.voidprocess(LockRecord record)Process a lock record.voidprocess(NamespaceRecord record)Process a namespace record.voidprocess(NodeTypeRecord record)Process a node type recordvoidprocess(PrivilegeRecord record)Process a privilege recordvoidprocess(WorkspaceRecord record)Process a workspace recordvoidregistered(Collection ntDefs)Called when one or more node types have been registered.voidregisteredPrivileges(Collection<PrivilegeDefinition> definitions)voidremapped(String oldPrefix, String newPrefix, String uri)Called when a namespace has been remapped.voidreregistered(QNodeTypeDefinition ntDef)Called when a node types has been re-registered.voidrun()Run loop that will sync this node after some delay.voidsetListener(NamespaceEventListener listener)Set listener that will receive information about incoming, external namespace events.voidsetListener(NodeTypeEventListener listener)Set listener that will receive information about incoming, external node type events.voidsetListener(PrivilegeEventListener listener)voidsetListener(WorkspaceListener listener)voidsetRevision(long revision)Set the revision this consumer has last seen.voidsetStopDelay(long stopDelay)Set the stop delay, i.e.voidstart()Starts this cluster node.voidstop()Stops this cluster node.voidsync()Synchronize contents from journal.voidsyncOnStartup()Synchronize contents from journal when aClusterNodestarts up.voidunregistered(Collection qnames)Called when one or more node types have been unregistered.voidworkspaceCreated(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 ClusterExceptionInitialize 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 ClusterExceptionStarts 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 ClusterExceptionSynchronize contents from journal.- Throws:
ClusterException- if an error occurs
-
syncOnStartup
public void syncOnStartup() throws ClusterExceptionSynchronize contents from journal when aClusterNodestarts up.- Throws:
ClusterException- if an error occurs
-
stop
public void stop()
Stops this cluster node.
-
createUpdateChannel
public UpdateEventChannel createUpdateChannel(String workspace)
Create anUpdateEventChannelfor some workspace.- Parameters:
workspace- workspace name- Returns:
- lock event channel
-
createLockChannel
public LockEventChannel createLockChannel(String workspace)
Create aLockEventChannelfor 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:
remappedin interfaceNamespaceEventChannel- Parameters:
oldPrefix- old prefix. ifnullthis is a fresh mappingnewPrefix- new prefix. ifnullthis is an unmap operationuri- uri to map prefix to
-
setListener
public void setListener(NamespaceEventListener listener)
Description copied from interface:NamespaceEventChannelSet listener that will receive information about incoming, external namespace events.- Specified by:
setListenerin interfaceNamespaceEventChannel- Parameters:
listener- namespace event listener
-
registered
public void registered(Collection ntDefs)
Called when one or more node types have been registered.- Specified by:
registeredin 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:
reregisteredin interfaceNodeTypeEventChannel- Parameters:
ntDef- node type definition
-
unregistered
public void unregistered(Collection qnames)
Called when one or more node types have been unregistered.- Specified by:
unregisteredin 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:
setListenerin interfaceNodeTypeEventChannel- Parameters:
listener- node type event listener
-
registeredPrivileges
public void registeredPrivileges(Collection<PrivilegeDefinition> definitions)
- Specified by:
registeredPrivilegesin interfacePrivilegeEventChannel- See Also:
PrivilegeEventChannel.registeredPrivileges(java.util.Collection)
-
setListener
public void setListener(PrivilegeEventListener listener)
- Specified by:
setListenerin interfacePrivilegeEventChannel
-
getId
public String getId()
Return the unique identifier of the records this consumer will be able to handle.- Specified by:
getIdin interfaceRecordConsumer- Returns:
- unique identifier
-
getRevision
public long getRevision()
Return the revision this consumer has last seen.- Specified by:
getRevisionin interfaceRecordConsumer- Returns:
- revision
-
consume
public void consume(Record record)
Consume a record.- Specified by:
consumein interfaceRecordConsumer- Parameters:
record- record to consume
-
setRevision
public void setRevision(long revision)
Set the revision this consumer has last seen.- Specified by:
setRevisionin interfaceRecordConsumer- Parameters:
revision- revision
-
process
public void process(ChangeLogRecord record)
Process a change log record.- Specified by:
processin interfaceClusterRecordProcessor- Parameters:
record- change log record
-
process
public void process(LockRecord record)
Process a lock record.- Specified by:
processin interfaceClusterRecordProcessor- Parameters:
record- lock record
-
process
public void process(NamespaceRecord record)
Process a namespace record.- Specified by:
processin interfaceClusterRecordProcessor- Parameters:
record- namespace record
-
process
public void process(NodeTypeRecord record)
Process a node type record- Specified by:
processin interfaceClusterRecordProcessor- Parameters:
record- node type record
-
process
public void process(PrivilegeRecord record)
Description copied from interface:ClusterRecordProcessorProcess a privilege record- Specified by:
processin interfaceClusterRecordProcessor- Parameters:
record- privilege record
-
process
public void process(WorkspaceRecord record)
Description copied from interface:ClusterRecordProcessorProcess a workspace record- Specified by:
processin interfaceClusterRecordProcessor- Parameters:
record- workspace record
-
setListener
public void setListener(WorkspaceListener listener)
- Specified by:
setListenerin interfaceWorkspaceEventChannel
-
workspaceCreated
public void workspaceCreated(String workspaceName, ClonedInputSource inputSource)
- Specified by:
workspaceCreatedin 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-trueif the operation was successful and the journal record should be updated;falseto revoke changes
-
-