Class AbstractCommitter<T extends BaseCommitterConfig>
- Type Parameters:
T- The type of the committer configuration class
- All Implemented Interfaces:
Committer,Configurable<T>,AutoCloseable
- Direct Known Subclasses:
AbstractBatchCommitter,AbstractFsCommitter,LogCommitter,MemoryCommitter
A base implementation taking care of basic plumbing, such as
firing main Committer events (including exceptions),
storing the Committer context (available via getCommitterContext()),
and adding support for filtering unwanted requests.
Restricting committer to specific documents
Optionally apply a committer only to certain type of documents. Documents are restricted based on their metadata field names and values. This option can be used to perform document routing when you have multiple committers defined.
Field mappings
By default, this abstract class applies field mappings for metadata fields, but leaves the document reference and content (input stream) for concrete implementations to handle. In other words, they only apply to a committer request metadata. Field mappings are performed on committer requests before upserts and deletes are actually performed.
-
Field Summary
Fields inherited from interface com.norconex.commons.lang.config.Configurable
PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccept(CommitterRequest request) Gets whether this committer accepts to commit the supplied request.protected voidprotected booleanfinal voidclean()Cleans any persisted information (e.g. queue) to ensure next run will start fresh.final voidclose()Close or release any open resources used by this committer.final voiddelete(DeleteRequest deleteRequest) Deletes the entity represented by the supplied request from the target of this committer.protected abstract voiddoClean()protected abstract voiddoClose()Subclasses can perform additional closing logic by overriding this method.protected abstract voiddoDelete(DeleteRequest deleteRequest) protected abstract voiddoInit()Subclasses can perform additional initialization by overriding this method.protected abstract voiddoUpsert(UpsertRequest upsertRequest) booleanprotected final voidprotected final voidfireDebug(String name, CommitterRequest req) protected final voidfireError(String name, CommitterRequest req, Exception e) protected final voidprotected final voidprotected final voidfireInfo(String name, CommitterRequest req) inthashCode()final voidinit(@NonNull CommitterContext committerContext) Initializes this committer.toString()final voidupsert(UpsertRequest upsertRequest) Updates or inserts the entity represented by the supplied request into the target of this committer.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.norconex.commons.lang.config.Configurable
getConfiguration
-
Constructor Details
-
AbstractCommitter
public AbstractCommitter()
-
-
Method Details
-
init
public final void init(@NonNull @NonNull CommitterContext committerContext) throws CommitterException Description copied from interface:CommitterInitializes this committer. Invoked once per crawl session.- Specified by:
initin interfaceCommitter- Parameters:
committerContext- the committer context- Throws:
CommitterException- problem with initialization
-
accept
Description copied from interface:CommitterGets whether this committer accepts to commit the supplied request. Useful when routing between multiple committers. Invoked for everyCommitterRequest. A request needs to be accepted forCommitter.upsert(UpsertRequest)orCommitter.delete(DeleteRequest)to be invoked.- Specified by:
acceptin interfaceCommitter- Parameters:
request- committer request- Returns:
trueif accepted- Throws:
CommitterException- any error when accepting
-
upsert
Description copied from interface:CommitterUpdates or inserts the entity represented by the supplied request into the target of this committer.- Specified by:
upsertin interfaceCommitter- Parameters:
upsertRequest- request to update or insert- Throws:
CommitterException- could not process upsert request
-
delete
Description copied from interface:CommitterDeletes the entity represented by the supplied request from the target of this committer.- Specified by:
deletein interfaceCommitter- Parameters:
deleteRequest- request to delete- Throws:
CommitterException- could not process delete request
-
applyFieldMappings
-
close
Description copied from interface:CommitterClose or release any open resources used by this committer.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCommitter- Throws:
CommitterException
-
clean
Description copied from interface:CommitterCleans any persisted information (e.g. queue) to ensure next run will start fresh. Calling this method on Committers not persisting anything between each execution will have no effect. This method does NOT delete anything previously committed on the target repository.- Specified by:
cleanin interfaceCommitter- Throws:
CommitterException- something went wrong cleaning the committer.
-
getCommitterContext
-
doInit
Subclasses can perform additional initialization by overriding this method. Default implementation does nothing. TheCommitterContextwill be initialized when invokinggetCommitterContext()- Throws:
CommitterException- error initializing
-
doUpsert
- Throws:
CommitterException
-
doDelete
- Throws:
CommitterException
-
doClose
Subclasses can perform additional closing logic by overriding this method. Default implementation does nothing.- Throws:
CommitterException- error closing committer
-
doClean
- Throws:
CommitterException
-
fireDebug
-
fireDebug
-
fireInfo
-
fireInfo
-
fireError
-
fireError
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-