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 final AclFormatThe format documents' ACLs are sent in: the configured one, or this committer's default when none is.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.protected AclFormatThe ACL format used when none is configured, for a committer whose destination has no access control of its own.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.protected StringnativeAclProblem(Acl acl) In theAclFormat.NATIVEformat, why the destination cannot express a document's ACL (for example several levels, or a principal it has no equivalent for), so the document is withheld rather than sent with access it did not have.protected booleanWhether this committer's destination has access control of its own, that this committer writes from a document's ACL (theAclFormat.NATIVEformat).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
-
aclFormat
The format documents' ACLs are sent in: the configured one, or this committer's default when none is.- Returns:
- the ACL format
-
supportsNativeAcl
protected boolean supportsNativeAcl()Whether this committer's destination has access control of its own, that this committer writes from a document's ACL (theAclFormat.NATIVEformat). A committer that returnstruereads the ACL withAclCodec.read(Properties), writes it its own way, and removes the "crawler.acl" field from what it sends. Default isfalse.- Returns:
trueif the destination has its own access control
-
defaultAclFormat
The ACL format used when none is configured, for a committer whose destination has no access control of its own. Default isAclFormat.JSON; a committer whose destination is searched by field values (rather than holding documents as JSON) overrides it withAclFormat.FLAT.- Returns:
- the default ACL format
-
nativeAclProblem
In theAclFormat.NATIVEformat, why the destination cannot express a document's ACL (for example several levels, or a principal it has no equivalent for), so the document is withheld rather than sent with access it did not have. Default isnull.- Parameters:
acl- the document's ACL- Returns:
- the reason, or
nullif the destination can express it
-
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
-