Class UpdateHandler

java.lang.Object
org.apache.solr.update.UpdateHandler
All Implemented Interfaces:
AutoCloseable, SolrInfoBean, SolrMetricProducer
Direct Known Subclasses:
DirectUpdateHandler2

public abstract class UpdateHandler extends Object implements SolrInfoBean
UpdateHandler handles requests to change the index (adds, deletes, commits, optimizes, etc).
Since:
solr 0.9
  • Field Details

  • Constructor Details

    • UpdateHandler

      public UpdateHandler(SolrCore core)
    • UpdateHandler

      public UpdateHandler(SolrCore core, UpdateLog updateLog)
    • UpdateHandler

      public 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, call initUlog(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:

      1. for backward compatibility with subclasses (plugins) that may have called UpdateHandler ctor with the assumption that ulog will be initialized
      2. to force subclass implementations to be aware that they must init ulog
      3. 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-class UpdateHandler ctor. If we were to follow this approach, this "extra-arg" ctor could be removed in favor of UpdateHandler(SolrCore, UpdateLog), initializing any non-null ulog (and removing the initUlog(boolean) helper method as well).

  • Method Details

    • informEventListeners

      public void informEventListeners(SolrCore core)
      Call the SolrCoreAware.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 init ulog. As discussed in the javadocs for UpdateHandler(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 creating ulog, then we should respond to an init failure by closing ulog, and this param should be set to true. If the calling context is not responsible for creating ulog, then references exist elsewhere and we should not close on init error (set this param to false).
    • newIndexWriter

      public abstract void newIndexWriter(boolean rollback) throws IOException
      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

      public abstract SolrCoreState getSolrCoreState()
    • addDoc

      public abstract int addDoc(AddUpdateCommand cmd) throws IOException
      Throws:
      IOException
    • delete

      public abstract void delete(DeleteUpdateCommand cmd) throws IOException
      Throws:
      IOException
    • deleteByQuery

      public abstract void deleteByQuery(DeleteUpdateCommand cmd) throws IOException
      Throws:
      IOException
    • mergeIndexes

      public abstract int mergeIndexes(MergeIndexesCommand cmd) throws IOException
      Throws:
      IOException
    • commit

      public abstract void commit(CommitUpdateCommand cmd) throws IOException
      Throws:
      IOException
    • rollback

      public abstract void rollback(RollbackUpdateCommand cmd) throws IOException
      Throws:
      IOException
    • getUpdateLog

      public abstract UpdateLog getUpdateLog()
    • registerCommitCallback

      public void registerCommitCallback(SolrEventListener listener)
      NOTE: this function is not thread safe. However, it is safe to call within the inform( SolrCore core ) function for SolrCoreAware classes. Outside inform, this could potentially throw a ConcurrentModificationException
      See Also:
    • registerSoftCommitCallback

      public void registerSoftCommitCallback(SolrEventListener listener)
      NOTE: this function is not thread safe. However, it is safe to call within the inform( SolrCore core ) function for SolrCoreAware classes. Outside inform, this could potentially throw a ConcurrentModificationException
      See Also:
    • registerOptimizeCallback

      public void registerOptimizeCallback(SolrEventListener listener)
      NOTE: this function is not thread safe. However, it is safe to call within the inform( SolrCore core ) function for SolrCoreAware classes. Outside inform, this could potentially throw a ConcurrentModificationException
      See Also:
    • split

      public abstract void split(SplitIndexCommand cmd) throws IOException
      Throws:
      IOException
    • getCategory

      public SolrInfoBean.Category getCategory()
      Description copied from interface: SolrInfoBean
      Category of this component
      Specified by:
      getCategory in interface SolrInfoBean
    • getSolrMetricsContext

      public SolrMetricsContext getSolrMetricsContext()
      Description copied from interface: SolrMetricProducer
      Implementations should return the context used in SolrMetricProducer.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:
      getSolrMetricsContext in interface SolrMetricProducer