com.continuent.tungsten.replicator.pipeline
Class SimpleSchedule

java.lang.Object
  extended by com.continuent.tungsten.replicator.pipeline.SimpleSchedule
All Implemented Interfaces:
Schedule

public class SimpleSchedule
extends java.lang.Object
implements Schedule

Defines a basic schedule implementation that tracks watches on events and task termination logic.

Version:
1.0
Author:
Robert Hodges

Field Summary
 
Fields inherited from interface com.continuent.tungsten.replicator.pipeline.Schedule
CONTINUE_NEXT, CONTINUE_NEXT_COMMIT, PROCEED, QUIT
 
Constructor Summary
SimpleSchedule(Stage stage, SingleThreadStageTask task)
          Creates a new schedule instance.
 
Method Summary
 int advise(ReplEvent replEvent)
          Task must call this method after extracting event but before processing to decide disposition.
 void cancel()
          Signal that task has been cancelled.
 void commit()
          Marks the last processed exception as committed.
 boolean isCancelled()
          Returns true if the task is canceled.
 void setLastProcessedEvent(ReplDBMSHeader event)
          Set the last processed event, which triggers checks for watches.
 boolean skip(ReplDBMSEvent event)
          Skips the given event
 void taskEnd()
          Task must call this method before exit to tell the schedule that it has completed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSchedule

public SimpleSchedule(Stage stage,
                      SingleThreadStageTask task)
Creates a new schedule instance.

Parameters:
stage - Stage to which this applies.
Method Detail

advise

public int advise(ReplEvent replEvent)
           throws java.lang.InterruptedException
Task must call this method after extracting event but before processing to decide disposition.

Specified by:
advise in interface Schedule
Returns:
A disposition for the event.
Throws:
java.lang.InterruptedException
See Also:
Schedule.advise(com.continuent.tungsten.replicator.event.ReplEvent)

isCancelled

public boolean isCancelled()
Returns true if the task is canceled. Tasks must check this each iteration to decide whether to continue.

Specified by:
isCancelled in interface Schedule
See Also:
Schedule.isCancelled()

setLastProcessedEvent

public void setLastProcessedEvent(ReplDBMSHeader event)
                           throws java.lang.InterruptedException
Set the last processed event, which triggers checks for watches. If a fulfilled watch directs the task to terminate, the isCancelled call will return true.

Specified by:
setLastProcessedEvent in interface Schedule
Throws:
java.lang.InterruptedException - Thrown if thread is interrupted.
See Also:
Schedule.setLastProcessedEvent(com.continuent.tungsten.replicator.event.ReplDBMSHeader)

commit

public void commit()
            throws java.lang.InterruptedException
Marks the last processed exception as committed. This information is used by upstream stages that implement synchronous pipeline processing, e.g., not dropping logs before they are safely committed downstream.

Specified by:
commit in interface Schedule
Throws:
java.lang.InterruptedException - Thrown if thread is interrupted.
See Also:
Schedule.commit()

taskEnd

public void taskEnd()
Task must call this method before exit to tell the schedule that it has completed.

Specified by:
taskEnd in interface Schedule
See Also:
Schedule.taskEnd()

skip

public boolean skip(ReplDBMSEvent event)
             throws java.lang.InterruptedException
Skips the given event

Throws:
java.lang.InterruptedException
See Also:
StageProgressTracker.skip(ReplDBMSEvent)

cancel

public void cancel()
Signal that task has been cancelled. Causes the isCancelled() call to return true.