Package org.codelibs.fess.job
Class ExecJob
java.lang.Object
org.codelibs.fess.job.ExecJob
- Direct Known Subclasses:
CrawlJob,GenerateThumbnailJob,PythonJob,SuggestJob
Abstract base class for executable jobs in the Fess search engine.
This class provides common functionality for job execution including process management,
logging configuration, JVM options, and timeout handling.
Subclasses must implement the abstract methods to define specific job behavior and execution type identification.
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JobExecutorThe job executor responsible for running this jobList of JVM options to apply when executing the jobprotected StringLasta environment configurationprotected StringPath to the log file for this job executionprotected StringLog level for this job executionprotected StringSuffix to append to log file namesprotected booleanFlag indicating whether the process has timed outprotected StringUnique session identifier for this job executionprotected intTimeout in seconds for job execution (-1 means no timeout)protected booleanFlag indicating whether to use local Fesen instance -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddFessConfigProperties(List<String> cmdList) Adds all Fess configuration properties to the command list.protected voidaddFessCustomSystemProperties(List<String> cmdList, String regex) Adds custom system properties that match the given regex pattern to the command list.protected voidaddFessSystemProperties(List<String> cmdList) Adds all Fess system properties to the command list.protected voidAdds a system property to the command list.protected voidappendJarFile(String cpSeparator, StringBuilder buf, File libDir, String basePath) Appends JAR files from the specified directory to the classpath buffer.protected voidcreateSystemProperties(List<String> cmdList, File propFile) Creates and stores system properties to the specified file.protected org.codelibs.core.timer.TimeoutTaskCreates a timeout task for this job execution.protected voiddeleteTempDir(File ownTmpDir) Deletes the specified temporary directory.abstract Stringexecute()Executes the job and returns the result as a string.execute(JobExecutor jobExecutor) Executes the job with the specified job executor.Enables garbage collection logging for this job execution.protected abstract StringReturns the execution type identifier for this job.protected StringgetLogName(String logPrefix) Generates a log name using the specified prefix, execution type, and suffix.jobExecutor(JobExecutor jobExecutor) Sets the job executor for this job.jvmOptions(String... options) Adds JVM options for this job execution.Sets the Lasta environment configuration.logFilePath(String logFilePath) Sets the log file path for this job execution.Sets the log level for this job execution.Sets the log suffix for this job execution.Enables remote debugging for this job execution.Sets the session ID for this job execution.timeout(int timeout) Sets the timeout for this job execution.useLocalFesen(boolean useLocalFesen) Sets whether to use local Fesen instance.
-
Field Details
-
jobExecutor
The job executor responsible for running this job -
sessionId
Unique session identifier for this job execution -
useLocalFesen
protected boolean useLocalFesenFlag indicating whether to use local Fesen instance -
logFilePath
Path to the log file for this job execution -
logLevel
Log level for this job execution -
logSuffix
Suffix to append to log file names -
jvmOptions
List of JVM options to apply when executing the job -
lastaEnv
Lasta environment configuration -
timeout
protected int timeoutTimeout in seconds for job execution (-1 means no timeout) -
processTimeout
protected boolean processTimeoutFlag indicating whether the process has timed out
-
-
Constructor Details
-
ExecJob
protected ExecJob()Default constructor for ExecJob. Initializes default values for job configuration.
-
-
Method Details
-
execute
Executes the job and returns the result as a string. This method contains the main business logic for the specific job implementation.- Returns:
- the execution result message or summary
-
getExecuteType
Returns the execution type identifier for this job. This type is used for classpath construction, configuration, and logging purposes.- Returns:
- the execution type (e.g., "crawler", "suggest", etc.)
-
execute
Executes the job with the specified job executor. This method sets the job executor and then calls the abstract execute method.- Parameters:
jobExecutor- the job executor to use for execution- Returns:
- the execution result message or summary
-
jobExecutor
Sets the job executor for this job.- Parameters:
jobExecutor- the job executor to set- Returns:
- this ExecJob instance for method chaining
-
sessionId
Sets the session ID for this job execution.- Parameters:
sessionId- the unique session identifier- Returns:
- this ExecJob instance for method chaining
-
logFilePath
Sets the log file path for this job execution.- Parameters:
logFilePath- the path to the log file- Returns:
- this ExecJob instance for method chaining
-
logLevel
Sets the log level for this job execution.- Parameters:
logLevel- the log level (e.g., DEBUG, INFO, WARN, ERROR)- Returns:
- this ExecJob instance for method chaining
-
logSuffix
Sets the log suffix for this job execution. The suffix is trimmed and whitespace is replaced with underscores.- Parameters:
logSuffix- the suffix to append to log file names- Returns:
- this ExecJob instance for method chaining
-
timeout
Sets the timeout for this job execution.- Parameters:
timeout- the timeout in seconds (-1 for no timeout)- Returns:
- this ExecJob instance for method chaining
-
useLocalFesen
Sets whether to use local Fesen instance.- Parameters:
useLocalFesen- true to use local Fesen, false otherwise- Returns:
- this ExecJob instance for method chaining
-
remoteDebug
Enables remote debugging for this job execution. Adds JVM options for remote debugging on localhost:8000.- Returns:
- this ExecJob instance for method chaining
-
gcLogging
Enables garbage collection logging for this job execution. Configures JVM options for comprehensive GC logging with rotation.- Returns:
- this ExecJob instance for method chaining
-
jvmOptions
Adds JVM options for this job execution.- Parameters:
options- the JVM options to add- Returns:
- this ExecJob instance for method chaining
-
lastaEnv
Sets the Lasta environment configuration.- Parameters:
env- the Lasta environment string- Returns:
- this ExecJob instance for method chaining
-
addSystemProperty
protected void addSystemProperty(List<String> cmdList, String name, String defaultValue, String appendValue) Adds a system property to the command list. If the property exists in the system, it uses that value with optional append value. Otherwise, it uses the default value if provided.- Parameters:
cmdList- the command list to add the property toname- the property namedefaultValue- the default value to use if property doesn't existappendValue- the value to append to the property value
-
addFessConfigProperties
Adds all Fess configuration properties to the command list. Properties starting with the Fess config prefix are included.- Parameters:
cmdList- the command list to add properties to
-
addFessSystemProperties
Adds all Fess system properties to the command list. Properties starting with the Fess system property prefix are included.- Parameters:
cmdList- the command list to add properties to
-
addFessCustomSystemProperties
Adds custom system properties that match the given regex pattern to the command list.- Parameters:
cmdList- the command list to add properties toregex- the regular expression pattern to match property names
-
deleteTempDir
Deletes the specified temporary directory. Logs a warning if the directory cannot be deleted.- Parameters:
ownTmpDir- the temporary directory to delete
-
appendJarFile
Appends JAR files from the specified directory to the classpath buffer.- Parameters:
cpSeparator- the classpath separator to usebuf- the StringBuilder to append tolibDir- the directory containing JAR filesbasePath- the base path to prepend to JAR file names
-
createTimeoutTask
protected org.codelibs.core.timer.TimeoutTask createTimeoutTask()Creates a timeout task for this job execution. If timeout is not set or is <= 0, returns null.- Returns:
- the timeout task, or null if no timeout is configured
-
createSystemProperties
Creates and stores system properties to the specified file. Includes system properties and job runtime information if available.- Parameters:
cmdList- the command list (used as comment in properties file)propFile- the file to store properties to- Throws:
org.lastaflute.di.exception.IORuntimeException- if an I/O error occurs
-
getLogName
Generates a log name using the specified prefix, execution type, and suffix.- Parameters:
logPrefix- the prefix for the log name- Returns:
- the generated log name
-