public abstract class Job
extends java.lang.Object
implements java.io.Serializable
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.
Modifier and Type | Class and Description |
---|---|
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).
|
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
Job(java.lang.String jobName,
Tool tool,
Job.Type jobType,
Cell upCell,
Cell downCell,
Job.Priority priority)
Constructor creates a new instance of Job.
|
Modifier and Type | Method and Description |
---|---|
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) |
public static boolean LOCALDEBUGFLAG
public static final int MIN_NUM_SECONDS
public long startTime
public long endTime
public boolean finished
public boolean reportExecution
public Job(java.lang.String jobName, Tool tool, Job.Type jobType, Cell upCell, Cell downCell, Job.Priority priority)
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.public static boolean getDebug()
public static void setDebug(boolean f)
public static void initJobManager(int numThreads, java.lang.String loggingFilePath, int socketPort, AbstractUserInterface ui, Job initDatabaseJob)
public static void pipeServer(int numThreads, java.lang.String loggingFilePath, int socketPort)
public static void socketClient(java.lang.String serverMachineName, int socketPort, AbstractUserInterface ui, Job initDatabaseJob)
public static void pipeClient(java.lang.Process process, AbstractUserInterface ui, Job initDatabaseJob, boolean skipOneLine)
public void startJob()
startJob(true, true)
.public void startJobOnMyResult()
public void startJob(boolean deleteWhenDone)
deleteWhenDone
is true, Job will be deleted
after it is done (frees all data and references it stores/created)deleteWhenDone
- delete when job is done if true, otherwise leave it aroundprotected void fieldVariableChanged(java.lang.String variableName)
variableName
- the name of the variable that changed.public abstract boolean doIt() throws JobException
JobException
- TODOpublic void terminateIt(java.lang.Throwable jobException)
jobException
- null if doIt terminated normally, otherwise exception thrown by doIt.public void terminateOK()
public void terminateFail(java.lang.Throwable jobException)
jobException
- null exception thrown by doIt.protected void setReportExecutionFlag(boolean flag)
protected void setProgress(java.lang.String progress)
public boolean isFinished()
public void abort()
protected boolean getScheduledToAbort()
public boolean getDeleteWhenDone()
public boolean checkAbort()
public static java.util.Iterator<Job> getAllJobs()
public static Job getRunningJob()
public static boolean inServerThread()
public static void setCurrentLibraryInJob(Library lib)
public java.lang.String getStatus()
public boolean remove()
public static UserInterface getUserInterface()
public static AbstractUserInterface getExtendedUserInterface()
public static boolean isClientThread()
public EDatabase getDatabase()
public Environment getEnvironment()
public TechPool getTechPool()
public Tool getTool()
public EditingPreferences getEditingPreferences()
public static void updateNetworkErrors(Cell cell, java.util.List<ErrorLogger.MessageLog> errors)
public static void updateIncrementalDRCErrors(Cell cell, java.util.List<ErrorLogger.MessageLog> newErrors, java.util.List<ErrorLogger.MessageLog> delErrors)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getInfo()
public Job.Key getKey()
public Job.Inform getInform()