Class AbstractBinaryWithTimeout

  • Direct Known Subclasses:
    RSync, Ssh

    public abstract class AbstractBinaryWithTimeout
    extends AbstractBinary
    Ancestor for binary wrappers that have an in-built timeout for operations.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • max_time

        protected int max_time
    • Constructor Detail

      • AbstractBinaryWithTimeout

        public AbstractBinaryWithTimeout()
    • Method Detail

      • getMaxTime

        public int getMaxTime()
        Returns the maximum time in seconds for the rsync process to run.
        Returns:
        the maximum in seconds, ignored if less than 1
      • maxTime

        public AbstractBinaryWithTimeout maxTime​(int max_time)
        Sets the maximum time in seconds for the rsync process to run.
        Parameters:
        max_time - the maximum time in seconds, ignored if less than 1
        Returns:
        itself
      • execute

        public com.github.fracpete.processoutput4j.output.CollectingProcessOutput execute()
                                                                                   throws java.lang.Exception
        Executes the rsync binary for the platform and waits for its completion. Collects stdout and stderr output in the result.
        If you want an incremental output, you can use AbstractBinary.start() and monitor the output yourself.
        Overrides:
        execute in class AbstractBinary
        Returns:
        the process result object
        Throws:
        java.lang.Exception - if execution fails or failed to determine binary
        See Also:
        AbstractBinary.commandLineArgs()
      • getParser

        protected net.sourceforge.argparse4j.inf.ArgumentParser getParser()
        Configures and returns the commandline parser.
        Overrides:
        getParser in class AbstractBinary
        Returns:
        the parser
      • setOptions

        protected boolean setOptions​(net.sourceforge.argparse4j.inf.Namespace ns)
        Sets the parsed options.
        Overrides:
        setOptions in class AbstractBinary
        Parameters:
        ns - the parsed options
        Returns:
        if successfully set
      • run

        public static void run​(AbstractBinaryWithTimeout binary,
                               java.lang.String[] args)
                        throws java.lang.Exception
        Runs the binary with the arguments.
        Parameters:
        args - the arguments
        Throws:
        java.lang.Exception