org.sakaiproject.component.legacy.event
Class ClusterEventTracking

java.lang.Object
  extended byorg.sakaiproject.component.legacy.event.BaseEventTrackingService
      extended byorg.sakaiproject.component.legacy.event.ClusterEventTracking
All Implemented Interfaces:
EventTrackingService, Runnable

public class ClusterEventTracking
extends BaseEventTrackingService
implements Runnable

ClusterEventTracking is the implmentation for the EventTracking service for use in a clustered multi-app server configuration. Events are backed in the cluster database, and this database is polled to read and process locally events posted by the other cluster members.

Version:
$Revision: 5604 $
Author:
University of Michigan, Sakai Software Development Team

Nested Class Summary
 
Nested classes inherited from class org.sakaiproject.component.legacy.event.BaseEventTrackingService
BaseEventTrackingService.BaseEvent, BaseEventTrackingService.MyObservable
 
Field Summary
protected  boolean m_autoDdl
          Configuration: to run the ddl on init or not.
protected  boolean m_batchWrite
          If true, batch events for bulk write.
protected  boolean m_checkDb
          Unless false, check the db for events from the other cluster servers.
protected  Collection m_eventQueue
          Queue of events to write if we are batching.
protected  long m_lastEventSeq
          Last event code read from the db
protected static String m_logId
          String used to identify this service in the logs
protected  long m_period
          How long to wait between checks for new events from the db.
protected  ServerConfigurationService m_serverConfigurationService
          Dependency: configuration service.
protected  SqlService m_sqlService
          Dependency: SqlService.
protected  Thread m_thread
          The db event checker thread.
protected  boolean m_threadStop
          The thread quit flag.
protected  TimeService m_timeService
          Dependency: TimeService.
 
Fields inherited from class org.sakaiproject.component.legacy.event.BaseEventTrackingService
m_localObservableHelper, m_logger, m_observableHelper, m_priorityObservableHelper
 
Fields inherited from interface org.sakaiproject.service.legacy.event.EventTrackingService
SERVICE_NAME
 
Constructor Summary
ClusterEventTracking()
           
 
Method Summary
protected  void bindValues(Event event, Object[] fields)
          Bind the event values into an array of fields for inserting.
 void destroy()
          Final cleanup.
 void init()
          Final initialization, once all dependencies are set.
protected  void initLastEvent()
          Check the db for the largest event seq number, and set this as the one after which we will next get event.
protected  String insertStatement()
          Form the proper event insert statement for the database technology.
protected  void postEvent(Event event)
          Cause this new event to get to wherever it has to go for persistence, etc.
 void run()
          Run the event checking thread.
 void setAutoDdl(String value)
          Configuration: to run the ddl on init or not.
 void setBatchWrite(String value)
          Configuration: set the batch writing flag.
 void setCheckDb(String value)
          Configuration: set the check-db.
 void setPeriod(String time)
          Set the # seconds to wait between db checks for new events.
 void setServerConfigurationService(ServerConfigurationService service)
          Dependency: configuration service
 void setSqlService(SqlService service)
          Dependency: SqlService.
 void setTimeService(TimeService service)
          Dependency: TimeService.
protected  void start()
          Start the clean and report thread.
protected  void stop()
          Stop the clean and report thread.
protected  void writeBatchEvents(Collection events)
          Write a batch of events to the db
protected  void writeEvent(Event event, Connection conn)
          Write a single event to the db
 
Methods inherited from class org.sakaiproject.component.legacy.event.BaseEventTrackingService
addLocalObserver, addObserver, addPriorityObserver, deleteObserver, newEvent, newEvent, notifyObservers, post, post, post, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_logId

protected static String m_logId
String used to identify this service in the logs


m_thread

protected Thread m_thread
The db event checker thread.


m_threadStop

protected boolean m_threadStop
The thread quit flag.


m_lastEventSeq

protected long m_lastEventSeq
Last event code read from the db


m_eventQueue

protected Collection m_eventQueue
Queue of events to write if we are batching.


m_checkDb

protected boolean m_checkDb
Unless false, check the db for events from the other cluster servers.


m_batchWrite

protected boolean m_batchWrite
If true, batch events for bulk write.


m_sqlService

protected SqlService m_sqlService
Dependency: SqlService.


m_serverConfigurationService

protected ServerConfigurationService m_serverConfigurationService
Dependency: configuration service.


m_timeService

protected TimeService m_timeService
Dependency: TimeService.


m_autoDdl

protected boolean m_autoDdl
Configuration: to run the ddl on init or not.


m_period

protected long m_period
How long to wait between checks for new events from the db.

Constructor Detail

ClusterEventTracking

public ClusterEventTracking()
Method Detail

setCheckDb

public void setCheckDb(String value)
Configuration: set the check-db.

Parameters:
value - The check-db value.

setBatchWrite

public void setBatchWrite(String value)
Configuration: set the batch writing flag.

Parameters:
value - The batch writing value.

setSqlService

public void setSqlService(SqlService service)
Dependency: SqlService.


setServerConfigurationService

public void setServerConfigurationService(ServerConfigurationService service)
Dependency: configuration service


setTimeService

public void setTimeService(TimeService service)
Dependency: TimeService.


setAutoDdl

public void setAutoDdl(String value)
Configuration: to run the ddl on init or not.

Parameters:
value - the auto ddl value.

setPeriod

public void setPeriod(String time)
Set the # seconds to wait between db checks for new events.

Parameters:
time - The # seconds to wait between db checks for new events.

init

public void init()
Final initialization, once all dependencies are set.

Overrides:
init in class BaseEventTrackingService

destroy

public void destroy()
Final cleanup.

Overrides:
destroy in class BaseEventTrackingService

postEvent

protected void postEvent(Event event)
Cause this new event to get to wherever it has to go for persistence, etc.

Specified by:
postEvent in class BaseEventTrackingService
Parameters:
event - The new event to post.

writeEvent

protected void writeEvent(Event event,
                          Connection conn)
Write a single event to the db

Parameters:
event - The event to write.

writeBatchEvents

protected void writeBatchEvents(Collection events)
Write a batch of events to the db

Parameters:
events - The collection of event to write.

insertStatement

protected String insertStatement()
Form the proper event insert statement for the database technology.

Returns:
The SQL insert statement for writing an event.

bindValues

protected void bindValues(Event event,
                          Object[] fields)
Bind the event values into an array of fields for inserting.

Parameters:
event - The event to write.
fields - The object[] to hold bind variables.

start

protected void start()
Start the clean and report thread.


stop

protected void stop()
Stop the clean and report thread.


run

public void run()
Run the event checking thread.

Specified by:
run in interface Runnable

initLastEvent

protected void initLastEvent()
Check the db for the largest event seq number, and set this as the one after which we will next get event.