public class BatchContainerDirectory extends Object
Constructor and Description |
---|
BatchContainerDirectory(String batchContainerPath)
Creates a reference for the path to the batch container.
|
Modifier and Type | Method and Description |
---|---|
void |
addShutdownHook()
Creates a shutdown hook and adds it to the local Runtime so that if the container's VM is shut down,
the semaphore files will be removed
|
String |
getExceptionFromFile(BatchStepFileDescriptor errorResultFile)
Returns the Exception contained in an error result file
|
BatchStepFileDescriptor |
getResultFile(BatchStepFileDescriptor batchStepFile)
Returns the result file (either a success file or an error file) if one exists for the specified step.
|
int |
getStepIndexFromFile(BatchStepFileDescriptor batchStepFile)
Returns the index of the step contained in the file
|
File[] |
getStepRunFiles()
Returns a list of files in the batch container with the run extension
|
boolean |
isBatchContainerRunning()
Checks whether the batch container is currently running (by checking for the presence of the batch container semaphore file)
|
boolean |
isFileEmpty(BatchStepFileDescriptor batchStepFile)
Checks whether the step's semaphore file in the descriptor is null and if not whether the step's semaphore file in the directory is empty
|
void |
logFileContents(BatchStepFileDescriptor batchStepFile,
org.apache.log4j.Logger log)
Reads the contents of the semaphore file (normally the error file), and writes the contents to the requested Logger.
|
void |
removeBatchContainerSemaphore()
Removes the semaphore file which indicates that the batch container is running
|
void |
removeBatchStepFileFromSystem(BatchStepFileDescriptor batchStepFile)
Removes the semaphore file for the specified step
|
void |
writeBatchContainerSemaphore(String jobName,
String stepName)
Writes the semaphore file which indicates that the batch container is running
|
void |
writeBatchStepErrorResultFile(BatchStepFileDescriptor batchStepFile)
Writes the error file for the Step specified in the descriptor
|
void |
writeBatchStepErrorResultFile(BatchStepFileDescriptor batchStepFile,
Throwable error)
Writes the error file for the Step specified in the descriptor.
|
void |
writeBatchStepRunFile(BatchStepFileDescriptor batchStepFile,
int stepIndex)
Writes the run file for the Step specified in the descriptor
|
void |
writeBatchStepSuccessfulResultFile(BatchStepFileDescriptor batchStepFile)
Writes the success file for the Step specified in the descriptor
|
public BatchContainerDirectory(String batchContainerPath)
batchContainerPath
- the path to the directory that contains the semaphore filespublic void writeBatchContainerSemaphore(String jobName, String stepName)
jobName
- the name of the job that is starting the batch containerstepName
- the name of the step which starts the batch containerpublic void removeBatchContainerSemaphore()
public boolean isBatchContainerRunning()
public File[] getStepRunFiles()
public void writeBatchStepRunFile(BatchStepFileDescriptor batchStepFile, int stepIndex)
batchStepFile
- the step for which a .run file will be writtenstepIndex
- the index of the step in the jobpublic void writeBatchStepSuccessfulResultFile(BatchStepFileDescriptor batchStepFile)
batchStepFile
- the step for which a .success file will be writtenpublic void writeBatchStepErrorResultFile(BatchStepFileDescriptor batchStepFile)
batchStepFile
- the step for which a .error file will be writtenpublic void writeBatchStepErrorResultFile(BatchStepFileDescriptor batchStepFile, Throwable error)
batchStepFile
- the step for which a .error file will be writtenerror
- the error to write in the error filepublic void removeBatchStepFileFromSystem(BatchStepFileDescriptor batchStepFile)
batchStepFile
- the step for which the semaphore file should be removedpublic BatchStepFileDescriptor getResultFile(BatchStepFileDescriptor batchStepFile)
batchStepFile
- the step for which a result file is requestedpublic boolean isFileEmpty(BatchStepFileDescriptor batchStepFile)
batchStepFile
- the descriptor for which a semaphore file existence check is requestedpublic int getStepIndexFromFile(BatchStepFileDescriptor batchStepFile)
batchStepFile
- the file from which to retrieve the step indexpublic void logFileContents(BatchStepFileDescriptor batchStepFile, org.apache.log4j.Logger log)
batchStepFile
- the descriptor whose semaphore file's contents should be written to the Loggerlog
- the log to write the file contents topublic String getExceptionFromFile(BatchStepFileDescriptor errorResultFile)
errorResultFile
- public void addShutdownHook()
Copyright © 2004–2015 The Kuali Foundation. All rights reserved.