Class SearchIndexerImpl

  • All Implemented Interfaces:
    Application.Component, Application.Module, SearchIndexer

    public class SearchIndexerImpl
    extends Object
    implements SearchIndexer
    An implementation of the SearchIndexer interface. This implementation uses a single-threaded task queue to permit indexing to run one at a time in a "background" thread. The task queue is controlled by a scheduler that allows us to suspend incoming tasks (pause). A thread pool is available so the tasks can create small units of work to be run in parallel. Each task should block until all of its work units are complete, to preserve the pattern of running one task at a time. The number of threads in the thread pool is specified in the application setup file.
    • Constructor Detail

      • SearchIndexerImpl

        public SearchIndexerImpl()
    • Method Detail

      • setThreadPoolSize

        public void setThreadPoolSize​(String size)
      • pause

        public void pause()
        Description copied from interface: SearchIndexer
        Stop processing new tasks. Requests will be queued until a call to unpause(). Fires a PAUSED event to listeners. This call has no effect if already paused, or if called after shutdown.
        Specified by:
        pause in interface SearchIndexer
      • unpause

        public void unpause()
        Description copied from interface: SearchIndexer
        Resume processing new tasks. Any requests that were received since the call to pause() will now be scheduled for processing. Fires an UNPAUSED event to listeners. If startup has not been called, the unpaused state will be recorded, but tasks will still await the call to startup. This call has no effect if not paused, or if called after shutdown.
        Specified by:
        unpause in interface SearchIndexer
      • scheduleUpdatesForStatements

        public void scheduleUpdatesForStatements​(List<org.apache.jena.rdf.model.Statement> changes)
        Description copied from interface: SearchIndexer
        Update any search documents that are affected by these statements. These statements are a mixture of additions and deletions. In either case, we feed them to the URI finders to see what individuals might have been affected by the change. We accumulate a batch of affected URIs, removing duplicates if they occur, and then submit them for updates. If called before startup or while paused, the task will be queued. If called after shutdown, this has no effect.
        Specified by:
        scheduleUpdatesForStatements in interface SearchIndexer
        Parameters:
        changes - if null or empty, this call has no effect.
      • scheduleUpdatesForUris

        public void scheduleUpdatesForUris​(Collection<String> uris)
        Description copied from interface: SearchIndexer
        Update the search documents for these URIs. For each URI that belongs in the index, a new search document is built, replacing any document that may already exist for that URI. For each URI that does not belong in the index, any existing document is removed. A URI belongs in the index if it refers to an existing individual in the model, and is not excluded. If called before startup or while paused, the task will be queued. If called after shutdown, this has no effect.
        Specified by:
        scheduleUpdatesForUris in interface SearchIndexer
        Parameters:
        uris - if null or empty, this call has no effect.
      • rebuildIndex

        public void rebuildIndex()
        Description copied from interface: SearchIndexer
        Remove all of the existing documents in the index, and schedule updates for all of the individuals in the model. If a rebuild is already pending or in progress, this method has no effect. If called before startup or while paused, the task will be queued. If called after shutdown, this has no effect.
        Specified by:
        rebuildIndex in interface SearchIndexer
      • addListener

        public void addListener​(SearchIndexer.Listener listener)
        Description copied from interface: SearchIndexer
        Add this listener, allowing it to receive events from the indexer. The listener can safely assume that the SearchIndexer is not paused. If the SearchIndexer is indeed paused when the listener is added, then a PAUSE event will immediately be passed to the listener. If this listener has already been added, or if called after shutdown, this method has no effect.
        Specified by:
        addListener in interface SearchIndexer
        Parameters:
        listener - if null, this method has no effect.
      • removeListener

        public void removeListener​(SearchIndexer.Listener listener)
        Description copied from interface: SearchIndexer
        Remove this listener, meaning that it will no longer receive events from the indexer. If this listener is not active, or if called after shutdown, this method has no effect.
        Specified by:
        removeListener in interface SearchIndexer
        Parameters:
        listener - if null, this method has no effect.