Package com.github.fracpete.rsync4j.core
Class AbstractBinaryWithTimeout
- java.lang.Object
-
- com.github.fracpete.rsync4j.core.AbstractBinary
-
- com.github.fracpete.rsync4j.core.AbstractBinaryWithTimeout
-
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 Summary
Fields Modifier and Type Field Description protected intmax_time-
Fields inherited from class com.github.fracpete.rsync4j.core.AbstractBinary
logger, outputCommandline, outputSingleCommandline
-
-
Constructor Summary
Constructors Constructor Description AbstractBinaryWithTimeout()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.github.fracpete.processoutput4j.output.CollectingProcessOutputexecute()Executes the rsync binary for the platform and waits for its completion.intgetMaxTime()Returns the maximum time in seconds for the rsync process to run.protected net.sourceforge.argparse4j.inf.ArgumentParsergetParser()Configures and returns the commandline parser.AbstractBinaryWithTimeoutmaxTime(int max_time)Sets the maximum time in seconds for the rsync process to run.voidreset()Resets the members.static voidrun(AbstractBinaryWithTimeout binary, java.lang.String[] args)Runs the binary with the arguments.protected booleansetOptions(net.sourceforge.argparse4j.inf.Namespace ns)Sets the parsed options.-
Methods inherited from class com.github.fracpete.rsync4j.core.AbstractBinary
builder, commandLine, commandLineArgs, description, getOutputCommandline, getOutputSingleCommandline, options, outputCommandline, outputSingleCommandline, run, setOptions, start
-
-
-
-
Method Detail
-
reset
public void reset()
Resets the members.- Overrides:
resetin classAbstractBinary
-
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.ExceptionExecutes 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 useAbstractBinary.start()and monitor the output yourself.- Overrides:
executein classAbstractBinary- 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:
getParserin classAbstractBinary- Returns:
- the parser
-
setOptions
protected boolean setOptions(net.sourceforge.argparse4j.inf.Namespace ns)
Sets the parsed options.- Overrides:
setOptionsin classAbstractBinary- 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
-
-