org.apache.jackrabbit.core.cluster
Class ClusterNode

java.lang.Object
  extended by org.apache.jackrabbit.core.cluster.ClusterNode
All Implemented Interfaces:
Runnable, ClusterRecordProcessor, NamespaceEventChannel, NodeTypeEventChannel, WorkspaceEventChannel, RecordConsumer

public class ClusterNode
extends Object
implements Runnable, NamespaceEventChannel, NodeTypeEventChannel, RecordConsumer, ClusterRecordProcessor, WorkspaceEventChannel

Default clustered node implementation.


Field Summary
static String SYSTEM_PROPERTY_NODE_ID
          System property specifying a node id to use.
 
Constructor Summary
ClusterNode()
           
 
Method Summary
 void consume(Record record)
          Consume a record.
 LockEventChannel createLockChannel(String workspace)
          Create a LockEventChannel for some workspace.
 UpdateEventChannel createUpdateChannel(String workspace)
          Create an UpdateEventChannel for some workspace.
 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 record
 void process(WorkspaceRecord record)
          Process a workspace record
 void registered(Collection ntDefs)
          Called when one or more node types have been registered.
 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(WorkspaceListener listener)
           
 void setRevision(long revision)
          Set the revision this consumer has last seen.
 void setStopDelay(long stopDelay)
          Set the stop delay, i.e. number of millseconds to wait for the synchronization thread to stop.
 void start()
          Starts this cluster node.
 void stop()
          Stops this cluster node.
 void sync()
          Synchronize contents from journal.
 void unregistered(Collection qnames)
          Called when one or more node types have been unregistered.
 void workspaceCreated(String workspaceName, ClonedInputSource inputSource)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Constructor Detail

ClusterNode

public ClusterNode()
Method Detail

init

public void init(ClusterContext clusterContext)
          throws ClusterException
Initialize this cluster node.

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)

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.

Specified by:
run in interface Runnable

sync

public void sync()
          throws ClusterException
Synchronize contents from journal.

Throws:
ClusterException - if an error occurs

stop

public void stop()
Stops this cluster node.


createUpdateChannel

public UpdateEventChannel createUpdateChannel(String workspace)
Create an UpdateEventChannel for some workspace.

Parameters:
workspace - workspace name
Returns:
lock event channel

createLockChannel

public LockEventChannel createLockChannel(String workspace)
Create a LockEventChannel 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 interface NamespaceEventChannel
Parameters:
oldPrefix - old prefix. if null this is a fresh mapping
newPrefix - new prefix. if null this is an unmap operation
uri - 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 interface NamespaceEventChannel
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 interface NodeTypeEventChannel
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 interface NodeTypeEventChannel
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 interface NodeTypeEventChannel
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 interface NodeTypeEventChannel
Parameters:
listener - node type event listener

getId

public String getId()
Return the unique identifier of the records this consumer will be able to handle.

Specified by:
getId in interface RecordConsumer
Returns:
unique identifier

getRevision

public long getRevision()
Return the revision this consumer has last seen.

Specified by:
getRevision in interface RecordConsumer
Returns:
revision

consume

public void consume(Record record)
Consume a record.

Specified by:
consume in interface RecordConsumer
Parameters:
record - record to consume

setRevision

public void setRevision(long revision)
Set the revision this consumer has last seen.

Specified by:
setRevision in interface RecordConsumer
Parameters:
revision - revision

process

public void process(ChangeLogRecord record)
Process a change log record.

Specified by:
process in interface ClusterRecordProcessor
Parameters:
record - change log record

process

public void process(LockRecord record)
Process a lock record.

Specified by:
process in interface ClusterRecordProcessor
Parameters:
record - lock record

process

public void process(NamespaceRecord record)
Process a namespace record.

Specified by:
process in interface ClusterRecordProcessor
Parameters:
record - namespace record

process

public void process(NodeTypeRecord record)
Process a node type record

Specified by:
process in interface ClusterRecordProcessor
Parameters:
record - node type record

process

public void process(WorkspaceRecord record)
Description copied from interface: ClusterRecordProcessor
Process a workspace record

Specified by:
process in interface ClusterRecordProcessor
Parameters:
record - workspace record

setListener

public void setListener(WorkspaceListener listener)
Specified by:
setListener in interface WorkspaceEventChannel

workspaceCreated

public void workspaceCreated(String workspaceName,
                             ClonedInputSource inputSource)
Specified by:
workspaceCreated in interface WorkspaceEventChannel

ended

public void ended(DefaultClusterOperation operation,
                  boolean successful)
Invoked when a cluster operation has ended. If successful, attempts to fill the journal record and update it, otherwise cancels the update.

Parameters:
operation - cluster operation
successful - true if the operation was successful and the journal record should be updated; false to revoke changes


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.