com.continuent.tungsten.replicator.pipeline
Class StageTaskGroup

java.lang.Object
  extended by com.continuent.tungsten.replicator.pipeline.StageTaskGroup
All Implemented Interfaces:
ReplicatorPlugin

public class StageTaskGroup
extends java.lang.Object
implements ReplicatorPlugin

This class encapsulates a group of tasks that run together in a single stage. It handles life-cycle operations ranging from instantiation to release.

Version:
1.0
Author:
Robert Hodges

Constructor Summary
StageTaskGroup(Stage stage, int taskCount, StageProgressTracker tracker)
          Instantiated a task group including underlying tasks and their respective extractors, filters, and appliers.
 
Method Summary
 void configure(PluginContext context)
          Complete plug-in configuration.
 SingleThreadStageTask getTask(int id)
           
 int getTaskCount()
           
 SingleThreadStageTask[] getTasks()
           
 boolean isShutdown()
          Returns true if the stage has stopped.
 void notifyTasks()
          Interrupts currently running tasks.
 void prepare(PluginContext context)
          Prepare plug-in for use.
 void release(PluginContext context)
          Release all resources used by plug-in.
 void reportTaskShutdown(java.lang.Thread taskThread, SingleThreadStageTask task)
          Reports that a task has shut down.
 void start(com.continuent.tungsten.fsm.event.EventDispatcher dispatcher)
          Start all tasks in the group.
 void stop(boolean immediate)
          Stop all tasks in the group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StageTaskGroup

public StageTaskGroup(Stage stage,
                      int taskCount,
                      StageProgressTracker tracker)
Instantiated a task group including underlying tasks and their respective extractors, filters, and appliers.

Parameters:
taskCount - Number of tasks in the group
Method Detail

getTaskCount

public int getTaskCount()

getTasks

public SingleThreadStageTask[] getTasks()

getTask

public SingleThreadStageTask getTask(int id)

configure

public void configure(PluginContext context)
               throws ReplicatorException,
                      java.lang.InterruptedException
Complete plug-in configuration. This is called after setters are invoked at the time that the replicator goes through configuration.

Specified by:
configure in interface ReplicatorPlugin
Throws:
ReplicatorException - Thrown if configuration is incomplete or fails
java.lang.InterruptedException
See Also:
ReplicatorPlugin.configure(com.continuent.tungsten.replicator.plugin.PluginContext)

prepare

public void prepare(PluginContext context)
             throws ReplicatorException,
                    java.lang.InterruptedException
Prepare plug-in for use. This method is assumed to allocate all required resources. It is called before the plug-in performs any operations.

Specified by:
prepare in interface ReplicatorPlugin
Throws:
ReplicatorException - Thrown if resource allocation fails
java.lang.InterruptedException
See Also:
ReplicatorPlugin.prepare(com.continuent.tungsten.replicator.plugin.PluginContext)

release

public void release(PluginContext context)
Release all resources used by plug-in. This is called before the plug-in is deallocated.

Specified by:
release in interface ReplicatorPlugin
See Also:
ReplicatorPlugin.release(com.continuent.tungsten.replicator.plugin.PluginContext)

start

public void start(com.continuent.tungsten.fsm.event.EventDispatcher dispatcher)
           throws ReplicatorException
Start all tasks in the group.

Throws:
ReplicatorException

stop

public void stop(boolean immediate)
          throws java.lang.InterruptedException
Stop all tasks in the group.

Parameters:
immediate - If true, interrupt and exit immediately
Throws:
java.lang.InterruptedException

reportTaskShutdown

public void reportTaskShutdown(java.lang.Thread taskThread,
                               SingleThreadStageTask task)
Reports that a task has shut down. If no threads remain, we report that the stage has shut down.


notifyTasks

public void notifyTasks()
Interrupts currently running tasks.


isShutdown

public boolean isShutdown()
Returns true if the stage has stopped.