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
    • 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.
    • Constructor Detail

      • ScpJobRunner

        public ScpJobRunner()
    • Method Detail

      • 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 interface MultiAttemptSupporter
        Parameters:
        value - the maximum
      • getNumAttempts

        public int getNumAttempts()
        Returns the maximum number of intervals to wait.
        Specified by:
        getNumAttempts in interface MultiAttemptSupporter
        Returns:
        the maximum
      • numAttemptsTipText

        public String numAttemptsTipText()
        Returns the tip text for this property.
        Specified by:
        numAttemptsTipText in interface MultiAttemptSupporter
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • attemptIntervalTipText

        public String attemptIntervalTipText()
        Returns the tip text for this property.
        Specified by:
        attemptIntervalTipText in interface MultiAttemptWithWaitSupporter
        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 interface HostnameUpdateSupporter
        Parameters:
        host - the new hostname/port
      • doStop

        protected String doStop()
        Waits for the import file to appear.
        Specified by:
        doStop in class AbstractJobRunner
        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 class AbstractJobRunner
        Parameters:
        wait - whether to wait for the jobs to finish
        Returns:
        null if successful, otherwise error message
      • complete

        public void complete​(Job j,
                             JobResult jr)
        Ignored.
        Specified by:
        complete in interface JobRunner
        Parameters:
        j - job
        jr - job result