com.sun.electric.tool
Class MultiTaskJob<TaskKey,TaskResult,Result>

java.lang.Object
  extended by com.sun.electric.tool.Job
      extended by com.sun.electric.tool.MultiTaskJob<TaskKey,TaskResult,Result>
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
MTDRCTool

public abstract class MultiTaskJob<TaskKey,TaskResult,Result>
extends Job

This generic class supports map-reduce scheme of computation on Electric database. Large computation has three stages: 1) Large computation is splitted into smaller tasks. Smaller tasks are identified by TaskKey class. This stage is performed by prepareTasks method, which schedules each task by startTask method. 2) Tasks run in parallel, each giving result of TaskResult type. This stage is performed by runTask method for each instance of task. 3) TaskResults are combinded into final result of Result type. This stage is performed by mergeTaskResults method. 4) Result is consumed on server. This stage is performed by consumer.consume method.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.sun.electric.tool.Job
Job.Mode, Job.Priority, Job.Type
 
Field Summary
 
Fields inherited from class com.sun.electric.tool.Job
BATCHMODE, endTime, LOCALDEBUGFLAG, startTime
 
Constructor Summary
MultiTaskJob(java.lang.String jobName, Tool t, Job.Type jobType, Consumer<Result> c)
          Constructor creates a new instance of MultiTaskJob.
 
Method Summary
 boolean doIt()
          This method is not overriden by subclasses.
abstract  Result mergeTaskResults(java.util.Map<TaskKey,TaskResult> taskResults)
          This abtract method combines task results into final result.
abstract  void prepareTasks()
          This abstract method split large computation into smaller task.
abstract  TaskResult runTask(TaskKey taskKey)
          This abtract methods performs computation of each task.
 void startTask(java.lang.String taskName, TaskKey taskKey)
          Schedules task.
 
Methods inherited from class com.sun.electric.tool.Job
abort, acquireExamineLock, checkAbort, fieldVariableChanged, getAllJobs, getDatabase, getDebug, getDeleteWhenDone, getDisplay, getExtendedUserInterface, getInfo, getNumThreads, getRunMode, getRunningJob, getScheduledToAbort, getStatus, getUserInterface, initJobManager, invokeExamineLater, isFinished, releaseExamineLock, remove, setDebug, setProgress, setReportExecutionFlag, setThreadMode, startJob, startJob, startJobOnMyResult, terminateFail, terminateIt, terminateOK, threadDatabase, toString, updateIncrementalDRCErrors, updateNetworkErrors, wantUpdateGui
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiTaskJob

public MultiTaskJob(java.lang.String jobName,
                    Tool t,
                    Job.Type jobType,
                    Consumer<Result> c)
Constructor creates a new instance of MultiTaskJob.

Parameters:
jobName - a string that describes this MultiTaskJob.
t - the Tool that originated this MultiTaskJob.
jobType - the Type of this Job (EXAMINE or CHANGE).
c - interface which consumes the result on server
Method Detail

prepareTasks

public abstract void prepareTasks()
                           throws JobException
This abstract method split large computation into smaller task. Smaller tasks are identified by TaskKey class. Each task is scheduled by startTask method.

Throws:
JobException

runTask

public abstract TaskResult runTask(TaskKey taskKey)
                            throws JobException
This abtract methods performs computation of each task.

Parameters:
taskKey - task key which identifies the task
Returns:
result of task computation
Throws:
JobException

mergeTaskResults

public abstract Result mergeTaskResults(java.util.Map<TaskKey,TaskResult> taskResults)
                                 throws JobException
This abtract method combines task results into final result.

Parameters:
taskResults - map which contains result of each completed task.
Returns:
final result which is obtained by merging task results.
Throws:
JobException

startTask

public void startTask(java.lang.String taskName,
                      TaskKey taskKey)
Schedules task. Should be callled from prepareTasks or runTask methods only.

Parameters:
taskName - task name which is appeared in Jobs Explorer Tree
taskKey - task key which identifies the task.

doIt

public final boolean doIt()
                   throws JobException
This method is not overriden by subclasses. Override methods prepareTasks, runTask, mergeTaskResults instead.

Specified by:
doIt in class Job
Throws:
JobException