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 class
ScpJobRunner.RemoteJobRunner
-
Field Summary
Fields Modifier and Type Field Description protected BaseHostname
m_ActualHost
the actual host to connect to.protected boolean
m_AllowLocalExecution
whether to allow fallback for local execution.protected int
m_AttemptInterval
the interval in milli-seconds to wait.protected SSHConnection
m_Connection
the ssh connection to use.protected PlaceholderFile
m_LocalFile
the local file to deserialize the finished jobs from.protected BaseHostname
m_LocalHost
the local host.protected int
m_MaxWait
the maxomum time in milli-seconds to wait.protected int
m_NumAttempts
the maximum number of interval to wait.protected PlaceholderFile
m_RemoteFile
the remote file to serialize the unexecuted jobs to.protected boolean
m_RunLocally
whether jobs are run locally as fallback.protected long
m_StartTime
the 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
-
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 String
allowLocalExecutionTipText()
Returns the tip text for this property.String
attemptIntervalTipText()
Returns the tip text for this property.void
complete(Job j, JobResult jr)
Ignored.void
defineOptions()
Adds options to the internal list of options.protected String
doStart()
Serializes the jobs to the specified export file.protected String
doStop()
Waits for the import file to appear.protected String
doTerminate(boolean wait)
Has no influence on the actual execution of the remote jobs, only when jobs are run locally (as fallback).boolean
getAllowLocalExecution()
Returns whether local execution of jobs is allowed in case SCP fails.int
getAttemptInterval()
Returns the interval to wait in milli-seconds.protected PlaceholderFile
getDefaultLocalFile()
Returns the default local file.protected PlaceholderFile
getDefaultRemoteFile()
Returns the default remote file.PlaceholderFile
getLocalFile()
Returns the local file to import the executed jobs from.BaseHostname
getLocalHost()
Returns the host that the remote host will connect to for sending back the executed jobs.int
getMaxWait()
Returns the maximum time in milli-seconds to wait before giving up on the remote jobs.int
getNumAttempts()
Returns the maximum number of intervals to wait.PlaceholderFile
getRemoteFile()
Returns the remote file for the un-executed jobs.protected boolean
getTransferJobCompleteListeners()
Returns whether to transfer the listeners to the actual job runner.String
globalInfo()
Returns a string describing the object.protected void
initialize()
Initializes the members.String
localFileTipText()
Returns the tip text for this property.String
localHostTipText()
Returns the tip text for this property.String
maxWaitTipText()
Returns the tip text for this property.protected JobRunner
newActualJobRunner()
Returns an instance of the actual job runner to use.String
numAttemptsTipText()
Returns the tip text for this property.protected String
preStart()
Before actual start up.String
remoteFileTipText()
Returns the tip text for this property.void
setAllowLocalExecution(boolean value)
Sets whether to allow local execution of jobs in case SCP fails.void
setAttemptInterval(int value)
Sets the interval in milli-seconds to wait.void
setLocalFile(PlaceholderFile value)
Sets the local file to import the executed jobs from.void
setLocalHost(BaseHostname value)
Sets the host that the remote host will connect to for sending back the executed jobs.void
setMaxWait(int value)
Sets the maximum time in milli-seconds to wait before giving up on the remote jobs.void
setNumAttempts(int value)
Sets the maximum number of intervals to wait.void
setRemoteFile(PlaceholderFile value)
Sets the remote file for the un-executed jobs.void
updateHostname(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:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractMetaJobRunner
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in 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:
setNumAttempts
in interfaceMultiAttemptSupporter
- Parameters:
value
- the maximum
-
getNumAttempts
public int getNumAttempts()
Returns the maximum number of intervals to wait.- Specified by:
getNumAttempts
in interfaceMultiAttemptSupporter
- Returns:
- the maximum
-
numAttemptsTipText
public String numAttemptsTipText()
Returns the tip text for this property.- Specified by:
numAttemptsTipText
in 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:
setAttemptInterval
in interfaceMultiAttemptWithWaitSupporter
- Parameters:
value
- the interval
-
getAttemptInterval
public int getAttemptInterval()
Returns the interval to wait in milli-seconds.- Specified by:
getAttemptInterval
in interfaceMultiAttemptWithWaitSupporter
- Returns:
- the interval
-
attemptIntervalTipText
public String attemptIntervalTipText()
Returns the tip text for this property.- Specified by:
attemptIntervalTipText
in 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:
updateHostname
in interfaceHostnameUpdateSupporter
- Parameters:
host
- the new hostname/port
-
getTransferJobCompleteListeners
protected boolean getTransferJobCompleteListeners()
Returns whether to transfer the listeners to the actual job runner.- Overrides:
getTransferJobCompleteListeners
in 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:
newActualJobRunner
in classAbstractMetaJobRunner
- Returns:
- the job runner to use
-
preStart
protected String preStart()
Before actual start up.- Overrides:
preStart
in classAbstractMetaJobRunner
- Returns:
- null if successful, otherwise error message
-
doStart
protected String doStart()
Serializes the jobs to the specified export file.- Specified by:
doStart
in 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:
doStop
in 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:
doTerminate
in classAbstractJobRunner
- Parameters:
wait
- whether to wait for the jobs to finish- Returns:
- null if successful, otherwise error message
-
-