Package adams.multiprocess
Class ScpJobRunner
-
- All Implemented Interfaces:
HostnameUpdateSupporter,CleanUpHandler,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,MultiAttemptSupporter,MultiAttemptWithWaitSupporter,OptionHandler,Pausable,QuickInfoSupporter,SizeOfHandler,JobRunner,Serializable
public class ScpJobRunner extends AbstractMetaJobRunner implements MultiAttemptWithWaitSupporter, HostnameUpdateSupporter
Wraps another jobrunner and serializes it, scp's it to the specified remote file and then waits for the specified import file (containing the serialized, executed jobs) to appear.
Requires a adams.flow.standalone.SSHConnection standalone for defining the SSH connection.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-job-runner <adams.multiprocess.JobRunner> (property: jobRunner) The base jobrunner to use. default: adams.multiprocess.LocalJobRunner
-remote-file <adams.core.io.PlaceholderFile> (property: remoteFile) The remote file for the un-executed jobs. default: ${CWD}-local-host <adams.core.base.BaseHostname> (property: localHost) The host (name/IP address:port) that the remote host will connect to when sending back the executed jobs; leave empty to use auto-detection. default: :22
-local-file <adams.core.io.PlaceholderFile> (property: localFile) The file to deserialize the executed jobs from. default: ${CWD}-max-wait <int> (property: maxWait) The maximum time to wait in milli-seconds before giving up on remote jobs; -1 for indefinite. default: -1 minimum: -1
-max-attempts <int> (property: numAttempts) The maximum number of intervals to wait. default: 10 minimum: 1
-attempt-interval <int> (property: attemptInterval) The interval in milli-seconds to wait before continuing with the execution. default: 1000 minimum: 1
-allow-local-execution <boolean> (property: allowLocalExecution) If enabled, executes the jobs locally in case the SCP operation fails. default: false
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classScpJobRunner.RemoteJobRunner
-
Field Summary
Fields Modifier and Type Field Description protected BaseHostnamem_ActualHostthe actual host to connect to.protected booleanm_AllowLocalExecutionwhether to allow fallback for local execution.protected intm_AttemptIntervalthe interval in milli-seconds to wait.protected SSHConnectionm_Connectionthe ssh connection to use.protected PlaceholderFilem_LocalFilethe local file to deserialize the finished jobs from.protected BaseHostnamem_LocalHostthe local host.protected intm_MaxWaitthe maxomum time in milli-seconds to wait.protected intm_NumAttemptsthe maximum number of interval to wait.protected PlaceholderFilem_RemoteFilethe remote file to serialize the unexecuted jobs to.protected booleanm_RunLocallywhether jobs are run locally as fallback.protected longm_StartTimethe start time.-
Fields inherited from class adams.multiprocess.AbstractMetaJobRunner
m_ActualJobRunner, m_JobCompleteListeners, m_JobRunner, m_Jobs
-
Fields inherited from class adams.multiprocess.AbstractJobRunner
m_FlowContext, m_Paused, m_Running, m_Terminating
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description ScpJobRunner()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringallowLocalExecutionTipText()Returns the tip text for this property.StringattemptIntervalTipText()Returns the tip text for this property.voidcomplete(Job j, JobResult jr)Ignored.voiddefineOptions()Adds options to the internal list of options.protected StringdoStart()Serializes the jobs to the specified export file.protected StringdoStop()Waits for the import file to appear.protected StringdoTerminate(boolean wait)Has no influence on the actual execution of the remote jobs, only when jobs are run locally (as fallback).booleangetAllowLocalExecution()Returns whether local execution of jobs is allowed in case SCP fails.intgetAttemptInterval()Returns the interval to wait in milli-seconds.protected PlaceholderFilegetDefaultLocalFile()Returns the default local file.protected PlaceholderFilegetDefaultRemoteFile()Returns the default remote file.PlaceholderFilegetLocalFile()Returns the local file to import the executed jobs from.BaseHostnamegetLocalHost()Returns the host that the remote host will connect to for sending back the executed jobs.intgetMaxWait()Returns the maximum time in milli-seconds to wait before giving up on the remote jobs.intgetNumAttempts()Returns the maximum number of intervals to wait.PlaceholderFilegetRemoteFile()Returns the remote file for the un-executed jobs.protected booleangetTransferJobCompleteListeners()Returns whether to transfer the listeners to the actual job runner.StringglobalInfo()Returns a string describing the object.protected voidinitialize()Initializes the members.StringlocalFileTipText()Returns the tip text for this property.StringlocalHostTipText()Returns the tip text for this property.StringmaxWaitTipText()Returns the tip text for this property.protected JobRunnernewActualJobRunner()Returns an instance of the actual job runner to use.StringnumAttemptsTipText()Returns the tip text for this property.protected StringpreStart()Before actual start up.StringremoteFileTipText()Returns the tip text for this property.voidsetAllowLocalExecution(boolean value)Sets whether to allow local execution of jobs in case SCP fails.voidsetAttemptInterval(int value)Sets the interval in milli-seconds to wait.voidsetLocalFile(PlaceholderFile value)Sets the local file to import the executed jobs from.voidsetLocalHost(BaseHostname value)Sets the host that the remote host will connect to for sending back the executed jobs.voidsetMaxWait(int value)Sets the maximum time in milli-seconds to wait before giving up on the remote jobs.voidsetNumAttempts(int value)Sets the maximum number of intervals to wait.voidsetRemoteFile(PlaceholderFile value)Sets the remote file for the un-executed jobs.voidupdateHostname(BaseHostname host)Sets the actual host to use - overrides the one from the SSHConnection actor.-
Methods inherited from class adams.multiprocess.AbstractMetaJobRunner
add, add, addJobCompleteListener, cleanUp, clear, getDefaultJobRunner, getJobRunner, getJobs, getQuickInfo, jobRunnerTipText, removeJobCompleteListener, setJobRunner
-
Methods inherited from class adams.multiprocess.AbstractJobRunner
getFlowContext, isPaused, isRunning, pauseExecution, postStart, postStop, postTerminate, preStop, preTerminate, resumeExecution, setFlowContext, start, stop, terminate, terminate
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.Destroyable
destroy
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Field Detail
-
m_RemoteFile
protected PlaceholderFile m_RemoteFile
the remote file to serialize the unexecuted jobs to.
-
m_LocalHost
protected BaseHostname m_LocalHost
the local host.
-
m_LocalFile
protected PlaceholderFile m_LocalFile
the local file to deserialize the finished jobs from.
-
m_MaxWait
protected int m_MaxWait
the maxomum time in milli-seconds to wait.
-
m_NumAttempts
protected int m_NumAttempts
the maximum number of interval to wait.
-
m_AttemptInterval
protected int m_AttemptInterval
the interval in milli-seconds to wait.
-
m_AllowLocalExecution
protected boolean m_AllowLocalExecution
whether to allow fallback for local execution.
-
m_Connection
protected transient SSHConnection m_Connection
the ssh connection to use.
-
m_ActualHost
protected BaseHostname m_ActualHost
the actual host to connect to.
-
m_RunLocally
protected boolean m_RunLocally
whether jobs are run locally as fallback.
-
m_StartTime
protected long m_StartTime
the start time.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractMetaJobRunner
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractMetaJobRunner
-
getDefaultRemoteFile
protected PlaceholderFile getDefaultRemoteFile()
Returns the default remote file.- Returns:
- the remote file
-
setRemoteFile
public void setRemoteFile(PlaceholderFile value)
Sets the remote file for the un-executed jobs.- Parameters:
value- the remote file
-
getRemoteFile
public PlaceholderFile getRemoteFile()
Returns the remote file for the un-executed jobs.- Returns:
- the remote file
-
remoteFileTipText
public String remoteFileTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setLocalHost
public void setLocalHost(BaseHostname value)
Sets the host that the remote host will connect to for sending back the executed jobs. Leave empty to use auto-discovery.- Parameters:
value- the host name/ip:port
-
getLocalHost
public BaseHostname getLocalHost()
Returns the host that the remote host will connect to for sending back the executed jobs. Leave empty to use auto-discovery.- Returns:
- the host name/ip:port
-
localHostTipText
public String localHostTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultLocalFile
protected PlaceholderFile getDefaultLocalFile()
Returns the default local file.- Returns:
- the local file
-
setLocalFile
public void setLocalFile(PlaceholderFile value)
Sets the local file to import the executed jobs from.- Parameters:
value- the local file
-
getLocalFile
public PlaceholderFile getLocalFile()
Returns the local file to import the executed jobs from.- Returns:
- the local file
-
localFileTipText
public String localFileTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setMaxWait
public void setMaxWait(int value)
Sets the maximum time in milli-seconds to wait before giving up on the remote jobs.- Parameters:
value- the time in milli-second, -1 for indefinite
-
getMaxWait
public int getMaxWait()
Returns the maximum time in milli-seconds to wait before giving up on the remote jobs.- Returns:
- the time in milli-second, -1 for indefinite
-
maxWaitTipText
public String maxWaitTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNumAttempts
public void setNumAttempts(int value)
Sets the maximum number of intervals to wait.- Specified by:
setNumAttemptsin interfaceMultiAttemptSupporter- Parameters:
value- the maximum
-
getNumAttempts
public int getNumAttempts()
Returns the maximum number of intervals to wait.- Specified by:
getNumAttemptsin interfaceMultiAttemptSupporter- Returns:
- the maximum
-
numAttemptsTipText
public String numAttemptsTipText()
Returns the tip text for this property.- Specified by:
numAttemptsTipTextin interfaceMultiAttemptSupporter- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setAttemptInterval
public void setAttemptInterval(int value)
Sets the interval in milli-seconds to wait.- Specified by:
setAttemptIntervalin interfaceMultiAttemptWithWaitSupporter- Parameters:
value- the interval
-
getAttemptInterval
public int getAttemptInterval()
Returns the interval to wait in milli-seconds.- Specified by:
getAttemptIntervalin interfaceMultiAttemptWithWaitSupporter- Returns:
- the interval
-
attemptIntervalTipText
public String attemptIntervalTipText()
Returns the tip text for this property.- Specified by:
attemptIntervalTipTextin interfaceMultiAttemptWithWaitSupporter- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setAllowLocalExecution
public void setAllowLocalExecution(boolean value)
Sets whether to allow local execution of jobs in case SCP fails.- Parameters:
value- true if to allow local execution
-
getAllowLocalExecution
public boolean getAllowLocalExecution()
Returns whether local execution of jobs is allowed in case SCP fails.- Returns:
- true if local execution allowed
-
allowLocalExecutionTipText
public String allowLocalExecutionTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
updateHostname
public void updateHostname(BaseHostname host)
Sets the actual host to use - overrides the one from the SSHConnection actor.- Specified by:
updateHostnamein interfaceHostnameUpdateSupporter- Parameters:
host- the new hostname/port
-
getTransferJobCompleteListeners
protected boolean getTransferJobCompleteListeners()
Returns whether to transfer the listeners to the actual job runner.- Overrides:
getTransferJobCompleteListenersin classAbstractMetaJobRunner- Returns:
- true if to transfer
- See Also:
AbstractMetaJobRunner.addJobCompleteListener(JobCompleteListener),AbstractMetaJobRunner.removeJobCompleteListener(JobCompleteListener)
-
newActualJobRunner
protected JobRunner newActualJobRunner()
Returns an instance of the actual job runner to use.- Overrides:
newActualJobRunnerin classAbstractMetaJobRunner- Returns:
- the job runner to use
-
preStart
protected String preStart()
Before actual start up.- Overrides:
preStartin classAbstractMetaJobRunner- Returns:
- null if successful, otherwise error message
-
doStart
protected String doStart()
Serializes the jobs to the specified export file.- Specified by:
doStartin classAbstractJobRunner- Returns:
- null if successful, otherwise error message
- See Also:
AbstractJobRunner.preStart()
-
doStop
protected String doStop()
Waits for the import file to appear.- Specified by:
doStopin classAbstractJobRunner- Returns:
- null if successful, otherwise error message
-
doTerminate
protected String doTerminate(boolean wait)
Has no influence on the actual execution of the remote jobs, only when jobs are run locally (as fallback).- Specified by:
doTerminatein classAbstractJobRunner- Parameters:
wait- whether to wait for the jobs to finish- Returns:
- null if successful, otherwise error message
-
-