org.hibernate.search.indexes.impl

## Class PeriodicRefreshingReaderProvider

- java.lang.Object
- - org.hibernate.search.indexes.impl.PeriodicRefreshingReaderProvider

- All Implemented Interfaces:
    DirectoryBasedReaderProvider, ReaderProvider

      public class PeriodicRefreshingReaderProvider
      extends Object
      implements DirectoryBasedReaderProvider

  This `ReaderProvider` shares IndexReader buffers among threads and will return "recently" refreshed `ReaderProvider`, which implies query results might represent the state of a slightly out of date index. The definition of "recently" refreshed is defined by configuration properties, so the user can choose how much the index being out of date is acceptable. In exchange of allowing slightly out of date query results, the fact that we can cap the frequency of index reopening events can provide significant performance improvements in some architectures.
  Author:
    Sanne Grinovero (C) 2016 Red Hat Inc.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `PeriodicRefreshingReaderProvider.PerDirectoryLatestReader` An instance for each DirectoryProvider, pointing to the "current" ReaderUsagePair for each DirectoryProvider.
    `protected class` | `PeriodicRefreshingReaderProvider.ReaderUsagePair` Container for the couple IndexReader,UsageCounter.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<IndexReader,PeriodicRefreshingReaderProvider.ReaderUsagePair>` | `allReaders` contains all Readers (most current per Directory and all unclosed old readers)
    `protected Map<Directory,PeriodicRefreshingReaderProvider.PerDirectoryLatestReader>` | `currentReaders` contains last updated Reader; protected by lockOnOpenLatest (in the values)
    `static int` | `DEFAULT_ACCEPTABLE_MAX_AGE_MS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PeriodicRefreshingReaderProvider()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `closeIndexReader(IndexReader reader)`
    `void` | `initialize(DirectoryBasedIndexManager indexManager, Properties props)`
    `IndexReader` | `openIndexReader()`
    `protected DirectoryReader` | `readerFactory(Directory directory)`
    `void` | `stop()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_ACCEPTABLE_MAX_AGE_MS

          public static final int DEFAULT_ACCEPTABLE_MAX_AGE_MS

      See Also:
        Constant Field Values

    - #### allReaders

          protected final Map<IndexReader,PeriodicRefreshingReaderProvider.ReaderUsagePair> allReaders

      contains all Readers (most current per Directory and all unclosed old readers)

    - #### currentReaders

          protected final Map<Directory,PeriodicRefreshingReaderProvider.PerDirectoryLatestReader> currentReaders

      contains last updated Reader; protected by lockOnOpenLatest (in the values)

  - ### Constructor Detail

    - #### PeriodicRefreshingReaderProvider

          public PeriodicRefreshingReaderProvider()

  - ### Method Detail

    - #### openIndexReader

          public IndexReader openIndexReader()

      Specified by:
        `openIndexReader` in interface `ReaderProvider`

    - #### closeIndexReader

          public void closeIndexReader(IndexReader reader)

      Specified by:
        `closeIndexReader` in interface `ReaderProvider`

    - #### readerFactory

          protected DirectoryReader readerFactory(Directory directory)
                                           throws IOException

      Throws:
        `IOException`

    - #### initialize

          public void initialize(DirectoryBasedIndexManager indexManager,
                                 Properties props)

      Specified by:
        `initialize` in interface `DirectoryBasedReaderProvider`

    - #### stop

          public void stop()

      Specified by:
        `stop` in interface `DirectoryBasedReaderProvider`

Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved