com.sun.electric.tool
Class Job

java.lang.Object
  extended by com.sun.electric.tool.Job
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AddCellJob, AddFlagAnnotationJob, AddLibraryJob, AddRemove.AddRemoveJob, AddRemove.UndoAddRemoveJob, AllSchemNamesToLay.RenameJob, AnnularRing.MakeAnnulus, CancelCheckOutJob, CellChangeJobs.DeleteCell, CellChangeJobs.DeleteCellGroup, CellChangeJobs.DeleteManyCells, CellChangeJobs.DuplicateCell, CellChangeJobs.ExtractCellInstances, CellChangeJobs.GraphCells, CellChangeJobs.NewCellVersion, CellChangeJobs.PackageCell, CellChangeJobs.RenameCell, CellChangeJobs.RenameCellGroup, CellMenu.DeleteMultiPageJob, CellMenu.SetMultiPageJob, CheckInJob, CheckOutJob, CircuitChangeJobs.AlignNodes, CircuitChangeJobs.AlignObjects, CircuitChangeJobs.ChangeArcProperties, CircuitChangeJobs.CheckAndRepairJob, CircuitChangeJobs.CleanupChanges, CircuitChangeJobs.ClearCellLocked, CircuitChangeJobs.ClearNodeLocked, CircuitChangeJobs.DeleteArcs, CircuitChangeJobs.DeleteSelected, CircuitChangeJobs.DeleteSelectedGeometry, CircuitChangeJobs.ManyMove, CircuitChangeJobs.ReloadLibraryJob, CircuitChangeJobs.RenameLibrary, CircuitChangeJobs.RenameTechnology, CircuitChangeJobs.RipTheBus, CircuitChangeJobs.RotateSelected, CircuitChangeJobs.ShortenArcs, CircuitChangeJobs.ToggleNegationJob, CrossLibCopy.CrossLibraryCopyJob, DeleteCellJob, DRC.CheckDRCJob, Edit.EditConsistencyCheckJob, Edit.ListEditorsJob, Edit.MarkForEditJob, ExportChanges.FollowExport, ExportChanges.ReExportPorts, ExportChanges.RenumberNumericExports, FileMenu.ClearCellDate, FileMenu.ImportLibrary, FileMenu.QuitJob, FileMenu.ReadLibrary, FileMenu.SaveAllLibrariesInFormatJob, FillGenJob, FlagJob, FlagLibraryCheckerJob, GateLayoutGenerator.GenerateFromSchematicsJob, GateRegression, J3DClientApp, LETool.AnalyzeCell, LETool.ClearStoredSizes, LETool.ClearStoredSizesLibrary, Log.RevertToVersion, MultiTaskJob, NccJob, Output.WriteJELIB, PaletteFrame.PlaceNewNode, ProjSettings.ImportSettingsJob, Router.CreateRouteJob, SchemNamesToLay.RenameJob, SkewTreeJob, StitchFillJob, Undo.UndoJob, UniversalJob, UpdateJob, ViewChanges.CreateAndViewCell, ViewChanges.MakeLayoutView

public abstract class Job
extends java.lang.Object
implements java.io.Serializable

Jobs are processes that will run in the background, such as DRC, NCC, Netlisters, etc. Each Job gets placed in a Job window, and reports its status. A job can be cancelled.

To start a new job, do:

Job job = new Job(name);

job.start();

Job subclass must implement "doIt" method, it may override "terminateOK" method.

Job subclass is activated by "Job.startJob()". In case of exception in constructor it is not activated. Hence "doIt" and "terminateOK" method are not called.

Job subclass must be serializable for CHANGE and REMOTE_EXAMINE mode. Serialization occurs at the moment when "Job.startJob()" is called. Fields that are not needed on the server are escaped from serialization by "transient" keyword. "doIt" is executed on serverDatabase for CHANGE and REMOTE_EXAMINE mode. "doIt" is executed on clientDatabase for EXAMINE mode, Job subclass need not be serializable.

"doIt" may return true, may return false, may throw JobException or any other Exception/Error. Return true is considered normal termination. Return false and throwing any Exception/Throwable are failure terminations.

On normal termination in CHANGE or REMOTE_EXAMINE mode "fieldVariableChanged" variables are serialized. In case of REMOTE_EXAMINE they are serialized on read-only database state. In case of CHANGE they are serialized on database state after Constraint propagation. In case of EXAMINE they are not serialized, but they are checked for valid field names. Some time later the changed variables are deserialized on client database. If serialization on server and deserialization on client was OK then terminateOK method is called on client database for all three modes CHANGE, REMOTE_EXAMINE, EXAMINE. If serialization/deserialization failed then terminateOK is not called, error message is issued.

In case of failure termination no terminateOK is called, error message is issued,

The extendig class may override getProgress(), which returns a string indicating the current status. Job also contains boolean abort, which gets set when the user decides to abort the Job. The extending class' code should check abort when/where applicable.

Note that if your Job calls methods outside of this thread that access shared data, those called methods should be synchronized.

Author:
gainsley
See Also:
Serialized Form

Nested Class Summary
static class Job.Inform
           
static class Job.Key
          Identifies a Job in a given Electric client/server session.
static class Job.Priority
          Priority is a typesafe enum class that describes the priority of a job.
static class Job.Type
          Type is a typesafe enum class that describes the type of job (CHANGE or EXAMINE).
 
Field Summary
 long endTime
          job end time
 boolean finished
          is job finished?
static boolean LOCALDEBUGFLAG
           
static int MIN_NUM_SECONDS
          default execution time in milis
 boolean reportExecution
          report execution time regardless MIN_NUM_SECONDS
 long startTime
          job start time
 
Constructor Summary
Job(java.lang.String jobName, Tool tool, Job.Type jobType, Cell upCell, Cell downCell, Job.Priority priority)
          Constructor creates a new instance of Job.
 
Method Summary
 void abort()
          Tell thread to abort.
 boolean checkAbort()
          Check if we are scheduled to abort.
abstract  boolean doIt()
          This is the main work method.
protected  void fieldVariableChanged(java.lang.String variableName)
          Method to remember that a field variable of the Job has been changed by the doIt() method.
static java.util.Iterator<Job> getAllJobs()
          get all jobs iterator
 EDatabase getDatabase()
           
static boolean getDebug()
          Method to tell whether Electric is running in "debug" mode.
 boolean getDeleteWhenDone()
          get deleteWhenDone status
 EditingPreferences getEditingPreferences()
           
 Environment getEnvironment()
           
static AbstractUserInterface getExtendedUserInterface()
          Low-level method.
 java.lang.String getInfo()
          Get info on Job
 Job.Inform getInform()
           
 Job.Key getKey()
           
static Job getRunningJob()
          If this current thread is a EThread running a Job return the Job.
protected  boolean getScheduledToAbort()
          get scheduled to abort status
 java.lang.String getStatus()
          get status
 TechPool getTechPool()
           
 Tool getTool()
           
static UserInterface getUserInterface()
           
static void initJobManager(int numThreads, java.lang.String loggingFilePath, int socketPort, AbstractUserInterface ui, Job initDatabaseJob)
           
static boolean inServerThread()
          Returns true if this current thread is a EThread running a server Job.
static boolean isClientThread()
           
 boolean isFinished()
          Return run status
static void pipeClient(java.lang.Process process, AbstractUserInterface ui, Job initDatabaseJob, boolean skipOneLine)
           
static void pipeServer(int numThreads, java.lang.String loggingFilePath, int socketPort)
           
 boolean remove()
          Remove job from Job list if it is done
static void setCurrentLibraryInJob(Library lib)
           
static void setDebug(boolean f)
           
protected  void setProgress(java.lang.String progress)
           
protected  void setReportExecutionFlag(boolean flag)
          Set reportExecution flag on/off
static void socketClient(java.lang.String serverMachineName, int socketPort, AbstractUserInterface ui, Job initDatabaseJob)
           
 void startJob()
          Start a job.
 void startJob(boolean deleteWhenDone)
          Start the job by placing it on the JobThread queue.
 void startJobOnMyResult()
          Start a job on snapshot obtained at the end of current job.
 void terminateFail(java.lang.Throwable jobException)
          This method executes in the Client side after exceptional termination of doIt method.
 void terminateIt(java.lang.Throwable jobException)
          This method executes in the Client side after termination of doIt method.
 void terminateOK()
          This method executes in the Client side after normal termination of doIt method.
 java.lang.String toString()
           
static void updateIncrementalDRCErrors(Cell cell, java.util.List<ErrorLogger.MessageLog> newErrors, java.util.List<ErrorLogger.MessageLog> delErrors)
           
static void updateNetworkErrors(Cell cell, java.util.List<ErrorLogger.MessageLog> errors)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOCALDEBUGFLAG

public static boolean LOCALDEBUGFLAG

MIN_NUM_SECONDS

public static final int MIN_NUM_SECONDS
default execution time in milis

See Also:
Constant Field Values

startTime

public long startTime
job start time


endTime

public long endTime
job end time


finished

public boolean finished
is job finished?


reportExecution

public boolean reportExecution
report execution time regardless MIN_NUM_SECONDS

Constructor Detail

Job

public Job(java.lang.String jobName,
           Tool tool,
           Job.Type jobType,
           Cell upCell,
           Cell downCell,
           Job.Priority priority)
Constructor creates a new instance of Job.

Parameters:
jobName - a string that describes this Job.
tool - the Tool that originated this Job.
jobType - the Type of this Job (EXAMINE or CHANGE).
upCell - the Cell at the bottom of a hierarchical "up cone" of change. If this and "downCell" are null, the entire database is presumed.
downCell - the Cell at the top of a hierarchical "down tree" of changes/examinations. If this and "upCell" are null, the entire database is presumed.
priority - the priority of this Job.
Method Detail

getDebug

public static boolean getDebug()
Method to tell whether Electric is running in "debug" mode. If the program is started with the "-debug" switch, debug mode is enabled.

Returns:
true if running in debug mode.

setDebug

public static void setDebug(boolean f)

initJobManager

public static void initJobManager(int numThreads,
                                  java.lang.String loggingFilePath,
                                  int socketPort,
                                  AbstractUserInterface ui,
                                  Job initDatabaseJob)

pipeServer

public static void pipeServer(int numThreads,
                              java.lang.String loggingFilePath,
                              int socketPort)

socketClient

public static void socketClient(java.lang.String serverMachineName,
                                int socketPort,
                                AbstractUserInterface ui,
                                Job initDatabaseJob)

pipeClient

public static void pipeClient(java.lang.Process process,
                              AbstractUserInterface ui,
                              Job initDatabaseJob,
                              boolean skipOneLine)

startJob

public void startJob()
Start a job. By default displays Job on Job List UI, and delete Job when done. Jobs that have state the user would like to use after the Job finishes (like DRC, NCC, etc) should call startJob(true, true).


startJobOnMyResult

public void startJobOnMyResult()
Start a job on snapshot obtained at the end of current job. By default displays Job on Job List UI, and delete Job when done.


startJob

public void startJob(boolean deleteWhenDone)
Start the job by placing it on the JobThread queue. If deleteWhenDone is true, Job will be deleted after it is done (frees all data and references it stores/created)

Parameters:
deleteWhenDone - delete when job is done if true, otherwise leave it around

fieldVariableChanged

protected void fieldVariableChanged(java.lang.String variableName)
Method to remember that a field variable of the Job has been changed by the doIt() method.

Parameters:
variableName - the name of the variable that changed.

doIt

public abstract boolean doIt()
                      throws JobException
This is the main work method. This method should perform all needed tasks.

Throws:
JobException - TODO

terminateIt

public void terminateIt(java.lang.Throwable jobException)
This method executes in the Client side after termination of doIt method. This method should perform all needed termination actions.

Parameters:
jobException - null if doIt terminated normally, otherwise exception thrown by doIt.

terminateOK

public void terminateOK()
This method executes in the Client side after normal termination of doIt method. This method should perform all needed termination actions.


terminateFail

public void terminateFail(java.lang.Throwable jobException)
This method executes in the Client side after exceptional termination of doIt method.

Parameters:
jobException - null exception thrown by doIt.

setReportExecutionFlag

protected void setReportExecutionFlag(boolean flag)
Set reportExecution flag on/off


setProgress

protected void setProgress(java.lang.String progress)

isFinished

public boolean isFinished()
Return run status


abort

public void abort()
Tell thread to abort. Extending class should check abort when/where applicable


getScheduledToAbort

protected boolean getScheduledToAbort()
get scheduled to abort status


getDeleteWhenDone

public boolean getDeleteWhenDone()
get deleteWhenDone status


checkAbort

public boolean checkAbort()
Check if we are scheduled to abort. If so, print msg if non null and return true. This is because setAbort and getScheduledToAbort are protected in Job.

Returns:
true on abort, false otherwise. If job is scheduled for abort or aborted. and it will report it to std output

getAllJobs

public static java.util.Iterator<Job> getAllJobs()
get all jobs iterator


getRunningJob

public static Job getRunningJob()
If this current thread is a EThread running a Job return the Job. Return null otherwise.

Returns:
a running Job or null

inServerThread

public static boolean inServerThread()
Returns true if this current thread is a EThread running a server Job.

Returns:
true if this current thread is a EThread running a server Job.

setCurrentLibraryInJob

public static void setCurrentLibraryInJob(Library lib)

getStatus

public java.lang.String getStatus()
get status


remove

public boolean remove()
Remove job from Job list if it is done


getUserInterface

public static UserInterface getUserInterface()

getExtendedUserInterface

public static AbstractUserInterface getExtendedUserInterface()
Low-level method.


isClientThread

public static boolean isClientThread()

getDatabase

public EDatabase getDatabase()

getEnvironment

public Environment getEnvironment()

getTechPool

public TechPool getTechPool()

getTool

public Tool getTool()

getEditingPreferences

public EditingPreferences getEditingPreferences()

updateNetworkErrors

public static void updateNetworkErrors(Cell cell,
                                       java.util.List<ErrorLogger.MessageLog> errors)

updateIncrementalDRCErrors

public static void updateIncrementalDRCErrors(Cell cell,
                                              java.util.List<ErrorLogger.MessageLog> newErrors,
                                              java.util.List<ErrorLogger.MessageLog> delErrors)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getInfo

public java.lang.String getInfo()
Get info on Job


getKey

public Job.Key getKey()

getInform

public Job.Inform getInform()