Package com.log4rich.util
Class CompressionManager
java.lang.Object
com.log4rich.util.CompressionManager
Manages external compression of log files.
Supports configurable compression programs and arguments.
This class handles the execution of external compression programs
with timeout support and proper error handling.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new CompressionManager with default settings.CompressionManager
(String program, String arguments, long timeoutMillis) Creates a new CompressionManager with the specified settings. -
Method Summary
Modifier and TypeMethodDescriptioncompressFile
(File sourceFile) Compresses a file using the configured compression program.Gets the compression program arguments.Gets the compression program name.long
Gets the compression timeout in milliseconds.boolean
Checks if the compression program is available.
-
Constructor Details
-
CompressionManager
public CompressionManager()Creates a new CompressionManager with default settings. Uses gzip as the compression program with no additional arguments and a 30-second timeout. -
CompressionManager
Creates a new CompressionManager with the specified settings.- Parameters:
program
- the compression program to use (e.g., "gzip", "bzip2", "xz")arguments
- additional arguments for the compression programtimeoutMillis
- the timeout in milliseconds for compression operations
-
-
Method Details
-
compressFile
Compresses a file using the configured compression program. If compression fails, the original file is returned.- Parameters:
sourceFile
- the file to compress- Returns:
- the compressed file, or the original file if compression failed
-
isProgramAvailable
public boolean isProgramAvailable()Checks if the compression program is available. Tests if the program can be executed by running it with --version.- Returns:
- true if the program can be executed, false otherwise
-
getProgram
Gets the compression program name.- Returns:
- the compression program name
-
getArguments
Gets the compression program arguments.- Returns:
- the compression program arguments
-
getTimeoutMillis
public long getTimeoutMillis()Gets the compression timeout in milliseconds.- Returns:
- the compression timeout in milliseconds
-