Class AbstractLockingPausableProcess<T extends StatusBean>
java.lang.Object
org.eclipse.scanning.api.event.core.AbstractLockingPausableProcess<T>
- All Implemented Interfaces:
IBeanProcess<T>,IPublishable<T>
- Direct Known Subclasses:
CommandProcess
public abstract class AbstractLockingPausableProcess<T extends StatusBean>
extends Object
implements IBeanProcess<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Tprotected PrintStreamprotected final IPublisher<T> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractLockingPausableProcess(T bean, IPublisher<T> publisher) -
Method Summary
Modifier and TypeMethodDescriptionvoidbroadcast(StatusBean tbean) Notify any clients of the beans statusprotected voidBlocks until process is not paused.protected voiddoPause()Override this method to do work on a pause once the pause lock has been received.protected voiddoResume()Override this method to do work on a resume once the pause lock has been received.protected voidprotected voiddryRun()protected voiddryRun(int size) protected voiddryRun(int size, boolean complete) getBean()protected final FilebooleanbooleanisPaused()Returns whether the process is paused.protected static final booleanvoidpause()Implements paused using a standard designvoidresume()Implements resume using a standard designvoidsetCancelled(boolean isCancelled) protected voidsetLoggingFile(File logFile) protected voidsetLoggingFile(File logFile, boolean append) Calling this method redirects the logging of this Java object which is available through the field 'out' to a known file.voidPlease provide a termination for the process by implementing this method.protected voidwriteProjectBean(File dir, String fileName) Writes the project bean at the point where it is run.protected voidwriteProjectBean(String dir, String fileName) Writes the project bean at the point where it is run.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.scanning.api.event.core.IBeanProcess
execute, isBlocking, start
-
Field Details
-
bean
-
publisher
-
out
-
-
Constructor Details
-
AbstractLockingPausableProcess
-
-
Method Details
-
getBean
- Specified by:
getBeanin interfaceIPublishable<T extends StatusBean>- Returns:
- the bean which this process is currently running.
-
getPublisher
- Specified by:
getPublisherin interfaceIPublishable<T extends StatusBean>- Returns:
- the bean which this process is currently running.
-
checkPaused
Blocks until process is not paused.- Throws:
EventException
-
pause
Implements paused using a standard design- Specified by:
pausein interfaceIBeanProcess<T extends StatusBean>- Throws:
EventException
-
doPause
Override this method to do work on a pause once the pause lock has been received.- Throws:
Exception
-
resume
Implements resume using a standard design- Specified by:
resumein interfaceIBeanProcess<T extends StatusBean>- Throws:
EventException
-
isPaused
public boolean isPaused()Description copied from interface:IBeanProcessReturns whether the process is paused. If usingAbstractLockingPausableProcess, it will be automatically.- Specified by:
isPausedin interfaceIBeanProcess<T extends StatusBean>- Returns:
trueif the process is paused,falseotherwise
-
doResume
Override this method to do work on a resume once the pause lock has been received.- Throws:
Exception
-
terminate
Description copied from interface:IBeanProcessPlease provide a termination for the process by implementing this method. If the process has a stop file, write it now; if it needs to be killed, get its pid and kill it; if it is running on a cluster, use the qdel or dramaa api.- Specified by:
terminatein interfaceIBeanProcess<T extends StatusBean>- Throws:
EventException
-
doTerminate
- Throws:
Exception
-
isWindowsOS
protected static final boolean isWindowsOS()- Returns:
- true if windows
-
getUnique
- Parameters:
dir-template-i-ext-- Returns:
- file
-
setLoggingFile
- Throws:
IOException
-
setLoggingFile
Calling this method redirects the logging of this Java object which is available through the field 'out' to a known file.- Parameters:
logFile-- Throws:
IOException
-
writeProjectBean
Writes the project bean at the point where it is run.- Parameters:
dir- directory to write tofileName- file name to write bean to- Throws:
Exception
-
writeProjectBean
Writes the project bean at the point where it is run.- Parameters:
dir- directory to write tofileName- file name to write bean to- Throws:
Exception
-
broadcast
Notify any clients of the beans status- Parameters:
bean-
-
dryRun
- Throws:
EventExceptionInterruptedException
-
dryRun
- Throws:
EventExceptionInterruptedException
-
dryRun
- Throws:
EventExceptionInterruptedException
-
isCancelled
public boolean isCancelled() -
setCancelled
public void setCancelled(boolean isCancelled)
-