Package org.apache.solr.update
Class UpdateHandler
java.lang.Object
org.apache.solr.update.UpdateHandler
- All Implemented Interfaces:
AutoCloseable,SolrInfoBean,SolrMetricProducer
- Direct Known Subclasses:
DirectUpdateHandler2
UpdateHandler handles requests to change the index (adds, deletes, commits,
optimizes, etc).- Since:
- solr 0.9
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoBean
SolrInfoBean.Category, SolrInfoBean.Group -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<SolrEventListener> protected final SolrCoreprotected final SchemaFieldprotected final FieldTypeprotected List<SolrEventListener> protected List<SolrEventListener> protected SolrMetricsContextprotected final UpdateLogFields inherited from interface org.apache.solr.metrics.SolrMetricProducer
CATEGORY_ATTR, HANDLER_ATTR, NAME_ATTR, OPERATION_ATTR, PLUGIN_NAME_ATTR, RESULT_ATTR, TYPE_ATTR -
Constructor Summary
ConstructorsConstructorDescriptionUpdateHandler(SolrCore core) UpdateHandler(SolrCore core, UpdateLog updateLog) UpdateHandler(SolrCore core, UpdateLog updateLog, boolean initUlog) Subclasses should call this ctor, with `initUlog=false` and should then, as the last action in the subclass ctor, callinitUlog(boolean). -
Method Summary
Modifier and TypeMethodDescriptionabstract intaddDoc(AddUpdateCommand cmd) protected voidprotected voidprotected voidabstract voidabstract voidabstract voidCategory of this componentabstract SolrCoreStateImplementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, Attributes)to ensure proper cleanup of metrics at the end of the life-cycle of this component.abstract UpdateLogvoidinformEventListeners(SolrCore core) Call theSolrCoreAware.inform(SolrCore)on all the applicable registered listeners.protected final voidinitUlog(boolean closeOnError) Helper method to initulog.abstract intabstract voidnewIndexWriter(boolean rollback) Called when the Writer should be opened again - eg when replication replaces all of the index files.voidregisterCommitCallback(SolrEventListener listener) NOTE: this function is not thread safe.voidregisterOptimizeCallback(SolrEventListener listener) NOTE: this function is not thread safe.voidregisterSoftCommitCallback(SolrEventListener listener) NOTE: this function is not thread safe.abstract voidabstract voidsplit(SplitIndexCommand cmd) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.solr.core.SolrInfoBean
getDescription, getNameMethods inherited from interface org.apache.solr.metrics.SolrMetricProducer
close, initializeMetrics
-
Field Details
-
core
-
idField
-
idFieldType
-
commitCallbacks
-
softCommitCallbacks
-
optimizeCallbacks
-
ulog
-
solrMetricsContext
-
-
Constructor Details
-
UpdateHandler
-
UpdateHandler
-
UpdateHandler
Subclasses should call this ctor, with `initUlog=false` and should then, as the last action in the subclass ctor, callinitUlog(boolean).NOTE: as an abstract class, if subclasses are supposed to always call this with `initUlog=false`, we could simply never init ulog in this method, and avoid the extra arg. But the arg is present for 3 reasons:
- for backward compatibility with subclasses (plugins) that may have called
UpdateHandlerctor with the assumption thatulogwill be initialized - to force subclass implementations to be aware that they must init
ulog - because it's likely that deferring ulog init until the last action of the top-level ctor is actually unnecessary (see below)
As noted in a comment in
DirectUpdateHandler2(SolrCore, UpdateHandler), it's unclear why we are advised to defer ulog init until the last action of the top-level ctor, as opposed to simply delegating init to the base-classUpdateHandlerctor. If we were to follow this approach, this "extra-arg" ctor could be removed in favor ofUpdateHandler(SolrCore, UpdateLog), initializing any non-nullulog(and removing theinitUlog(boolean)helper method as well). - for backward compatibility with subclasses (plugins) that may have called
-
-
Method Details
-
informEventListeners
Call theSolrCoreAware.inform(SolrCore)on all the applicable registered listeners. -
callPostCommitCallbacks
protected void callPostCommitCallbacks() -
callPostSoftCommitCallbacks
protected void callPostSoftCommitCallbacks() -
callPostOptimizeCallbacks
protected void callPostOptimizeCallbacks() -
initUlog
protected final void initUlog(boolean closeOnError) Helper method to initulog. As discussed in the javadocs forUpdateHandler(SolrCore, UpdateLog, boolean), this should be called as the last action of each top-level ctor.- Parameters:
closeOnError- if the calling context is responsible for creatingulog, then we should respond to an init failure by closingulog, and this param should be set totrue. If the calling context is not responsible for creatingulog, then references exist elsewhere and we should not close on init error (set this param tofalse).
-
newIndexWriter
Called when the Writer should be opened again - eg when replication replaces all of the index files.- Parameters:
rollback- IndexWriter if true else close- Throws:
IOException- If there is a low-level I/O error.
-
getSolrCoreState
-
addDoc
- Throws:
IOException
-
delete
- Throws:
IOException
-
deleteByQuery
- Throws:
IOException
-
mergeIndexes
- Throws:
IOException
-
commit
- Throws:
IOException
-
rollback
- Throws:
IOException
-
getUpdateLog
-
registerCommitCallback
NOTE: this function is not thread safe. However, it is safe to call within theinform( SolrCore core )function forSolrCoreAwareclasses. Outsideinform, this could potentially throw a ConcurrentModificationException- See Also:
-
registerSoftCommitCallback
NOTE: this function is not thread safe. However, it is safe to call within theinform( SolrCore core )function forSolrCoreAwareclasses. Outsideinform, this could potentially throw a ConcurrentModificationException- See Also:
-
registerOptimizeCallback
NOTE: this function is not thread safe. However, it is safe to call within theinform( SolrCore core )function forSolrCoreAwareclasses. Outsideinform, this could potentially throw a ConcurrentModificationException- See Also:
-
split
- Throws:
IOException
-
getCategory
Description copied from interface:SolrInfoBeanCategory of this component- Specified by:
getCategoryin interfaceSolrInfoBean
-
getSolrMetricsContext
Description copied from interface:SolrMetricProducerImplementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, Attributes)to ensure proper cleanup of metrics at the end of the life-cycle of this component. This should be the child context if one was created, or null if the parent context was used.- Specified by:
getSolrMetricsContextin interfaceSolrMetricProducer
-