Class ArchiveBatchJobBase
- java.lang.Object
-
- dk.netarkivet.common.utils.batch.FileBatchJob
-
- dk.netarkivet.common.utils.archive.ArchiveBatchJobBase
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ArchiveBatchJob
public abstract class ArchiveBatchJobBase extends FileBatchJob
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class dk.netarkivet.common.utils.batch.FileBatchJob
FileBatchJob.ExceptionOccurrence
-
-
Field Summary
Fields Modifier and Type Field Description protected int
noOfRecordsProcessed
The total number of records processed.-
Fields inherited from class dk.netarkivet.common.utils.batch.FileBatchJob
batchJobTimeout, exceptions, filesFailed, noOfFilesProcessed
-
-
Constructor Summary
Constructors Constructor Description ArchiveBatchJobBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
finish(OutputStream os)
Finish up the job.Exception[]
getExceptionArray()
Returns a representation of the list of Exceptions recorded for this archive batch job.void
handleException(Exception e, File archiveFile, long index)
When the org.archive.io.arc classes throw IOExceptions while reading, this is where they go.protected void
handleOurException(NetarkivetException e, File archiveFile, long index)
Private method that handles our exception.abstract void
initialize(OutputStream os)
Initialize the job before running.int
noOfRecordsProcessed()
Returns the number of records processed.-
Methods inherited from class dk.netarkivet.common.utils.batch.FileBatchJob
addException, addFinishException, addInitializeException, getBatchJobTimeout, getExceptions, getFilenamePattern, getFilesFailed, getNoOfFilesProcessed, maxExceptionsReached, postProcess, processFile, processOnlyFileNamed, processOnlyFilesMatching, processOnlyFilesMatching, processOnlyFilesNamed, setBatchJobTimeout
-
-
-
-
Method Detail
-
initialize
public abstract void initialize(OutputStream os)
Initialize the job before running. This is called before the processRecord() calls start coming.- Specified by:
initialize
in classFileBatchJob
- Parameters:
os
- The OutputStream to which output data is written
-
finish
public abstract void finish(OutputStream os)
Finish up the job. This is called after the last processRecord() call.- Specified by:
finish
in classFileBatchJob
- Parameters:
os
- The OutputStream to which output data is written
-
handleOurException
protected void handleOurException(NetarkivetException e, File archiveFile, long index)
Private method that handles our exception.- Parameters:
e
- the given exceptionarchiveFile
- The archive file where the exception occurred.index
- The offset in the archive file where the exception occurred.
-
handleException
public void handleException(Exception e, File archiveFile, long index) throws ArgumentNotValid
When the org.archive.io.arc classes throw IOExceptions while reading, this is where they go. Subclasses are welcome to override the default functionality which simply logs and records them in a list. TODO: Actually use the archive file/index entries in the exception list- Parameters:
e
- An Exception thrown by the org.archive.io.arc classes.archiveFile
- The archive file that was processed while the Exception was thrownindex
- The index (in the archive file) at which the Exception was thrown- Throws:
ArgumentNotValid
- if e is null
-
getExceptionArray
public Exception[] getExceptionArray()
Returns a representation of the list of Exceptions recorded for this archive batch job. If called by a subclass, a method overriding handleException() should always call super.handleException().- Returns:
- All Exceptions passed to handleException so far.
-
noOfRecordsProcessed
public int noOfRecordsProcessed()
Returns the number of records processed.- Returns:
- the number of records processed.
-
-