org.apache.solr.core

## Class CachingDirectoryFactory

- java.lang.Object
- - org.apache.solr.core.DirectoryFactory
  - - org.apache.solr.core.CachingDirectoryFactory

- All Implemented Interfaces:
    Closeable, AutoCloseable, NamedListInitializedPlugin
  Direct Known Subclasses:
    EphemeralDirectoryFactory, HdfsDirectoryFactory, StandardDirectoryFactory

      public abstract class CachingDirectoryFactory
      extends DirectoryFactory

  A `DirectoryFactory` impl base class for caching Directory instances per path. Most DirectoryFactory implementations will want to extend this class and simply implement `DirectoryFactory.create(String, LockFactory, DirContext)`. This is an expert class and these API's are subject to change.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `CachingDirectoryFactory.CacheValue`
    `static interface` | `CachingDirectoryFactory.CloseListener`

    - ### Nested classes/interfaces inherited from class org.apache.solr.core.DirectoryFactory

      `DirectoryFactory.DirContext`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<Directory,CachingDirectoryFactory.CacheValue>` | `byDirectoryCache`
    `protected Map<String,CachingDirectoryFactory.CacheValue>` | `byPathCache`
    `protected Map<Directory,List<CachingDirectoryFactory.CloseListener>>` | `closeListeners`
    `protected Set<CachingDirectoryFactory.CacheValue>` | `removeEntries`

    - ### Fields inherited from class org.apache.solr.core.DirectoryFactory

      `coreContainer, INDEX_W_TIMESTAMP_REGEX, IOCONTEXT_NO_CACHE, LOCK_TYPE_HDFS, LOCK_TYPE_NATIVE, LOCK_TYPE_NONE, LOCK_TYPE_SIMPLE, LOCK_TYPE_SINGLE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CachingDirectoryFactory()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addCloseListener(Directory dir, CachingDirectoryFactory.CloseListener closeListener)` Adds a close listener for a Directory.
    `void` | `close()` Close the this and all of the Directories it contains.
    `protected boolean` | `deleteOldIndexDirectory(String oldDirPath)`
    `void` | `doneWithDirectory(Directory directory)` Indicates a Directory will no longer be used, and when its ref count hits 0, it can be closed.
    `boolean` | `exists(String path)` Returns true if a Directory exists for a given path.
    `Directory` | `get(String path, DirectoryFactory.DirContext dirContext, String rawLockType)` Returns the Directory for a given path, using the specified rawLockType.
    `Set<String>` | `getLivePaths()` Method for inspecting the cache
    `protected String` | `getPath(Directory directory)`
    `void` | `incRef(Directory directory)` Increment the number of references to the given Directory.
    `void` | `init(NamedList args)`
    `String` | `normalize(String path)` Normalize a given path.
    `void` | `release(Directory directory)` Releases the Directory so that it may be closed when it is no longer referenced.
    `void` | `remove(Directory dir)` Removes the Directory's persistent storage.
    `void` | `remove(Directory dir, boolean deleteAfterCoreClose)` Removes the Directory's persistent storage.
    `void` | `remove(String path)` This remove is special in that it may be called even after the factory has been closed.
    `void` | `remove(String path, boolean deleteAfterCoreClose)` This remove is special in that it may be called even after the factory has been closed.
    `protected void` | `removeDirectory(CachingDirectoryFactory.CacheValue cacheValue)`
    `protected String` | `stripTrailingSlash(String path)`

    - ### Methods inherited from class org.apache.solr.core.DirectoryFactory

      `cleanupOldIndexDirectories, create, createLockFactory, empty, getDataHome, initCoreContainer, isAbsolute, isPersistent, isSharedStorage, move, offerMBeans, searchersReserveCommitPoints, size, size, sizeOf, sizeOfDirectory`

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

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

- - ### Field Detail

    - #### byPathCache

          protected Map<String,CachingDirectoryFactory.CacheValue> byPathCache

    - #### byDirectoryCache

          protected Map<Directory,CachingDirectoryFactory.CacheValue> byDirectoryCache

    - #### closeListeners

          protected Map<Directory,List<CachingDirectoryFactory.CloseListener>> closeListeners

    - #### removeEntries

          protected Set<CachingDirectoryFactory.CacheValue> removeEntries

  - ### Constructor Detail

    - #### CachingDirectoryFactory

          public CachingDirectoryFactory()

  - ### Method Detail

    - #### addCloseListener

          public void addCloseListener(Directory dir,
                                       CachingDirectoryFactory.CloseListener closeListener)

      Description copied from class: `DirectoryFactory`
      Adds a close listener for a Directory.
      Specified by:
        `addCloseListener` in class `DirectoryFactory`

    - #### doneWithDirectory

          public void doneWithDirectory(Directory directory)
                                 throws IOException

      Description copied from class: `DirectoryFactory`
      Indicates a Directory will no longer be used, and when its ref count hits 0, it can be closed. On close all directories will be closed whether this has been called or not. This is simply to allow early cleanup.
      Specified by:
        `doneWithDirectory` in class `DirectoryFactory`
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### close

          public void close()
                     throws IOException

      Description copied from class: `DirectoryFactory`
      Close the this and all of the Directories it contains.
      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in class `DirectoryFactory`
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### exists

          public boolean exists(String path)
                         throws IOException

      Description copied from class: `DirectoryFactory`
      Returns true if a Directory exists for a given path.
      Specified by:
        `exists` in class `DirectoryFactory`
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### get

          public final Directory get(String path,
                                     DirectoryFactory.DirContext dirContext,
                                     String rawLockType)
                              throws IOException

      Description copied from class: `DirectoryFactory`
      Returns the Directory for a given path, using the specified rawLockType. Will return the same Directory instance for the same path.
      Specified by:
        `get` in class `DirectoryFactory`
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### incRef

          public void incRef(Directory directory)

      Description copied from class: `DirectoryFactory`
      Increment the number of references to the given Directory. You must call release for every call to this method.
      Specified by:
        `incRef` in class `DirectoryFactory`

    - #### init

          public void init(NamedList args)

    - #### release

          public void release(Directory directory)
                       throws IOException

      Description copied from class: `DirectoryFactory`
      Releases the Directory so that it may be closed when it is no longer referenced.
      Specified by:
        `release` in class `DirectoryFactory`
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### remove

          public void remove(String path)
                      throws IOException

      Description copied from class: `DirectoryFactory`
      This remove is special in that it may be called even after the factory has been closed. Remove only makes sense for persistent directory factories.
      Specified by:
        `remove` in class `DirectoryFactory`
      Parameters:
        `path` - to remove
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### remove

          public void remove(Directory dir)
                      throws IOException

      Description copied from class: `DirectoryFactory`
      Removes the Directory's persistent storage. For example: A file system impl may remove the on disk directory.
      Specified by:
        `remove` in class `DirectoryFactory`
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### remove

          public void remove(String path,
                             boolean deleteAfterCoreClose)
                      throws IOException

      Description copied from class: `DirectoryFactory`
      This remove is special in that it may be called even after the factory has been closed. Remove only makes sense for persistent directory factories.
      Specified by:
        `remove` in class `DirectoryFactory`
      Parameters:
        `path` - to remove
        `deleteAfterCoreClose` - whether to wait until after the core is closed.
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### remove

          public void remove(Directory dir,
                             boolean deleteAfterCoreClose)
                      throws IOException

      Description copied from class: `DirectoryFactory`
      Removes the Directory's persistent storage. For example: A file system impl may remove the on disk directory.
      Specified by:
        `remove` in class `DirectoryFactory`
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### removeDirectory

          protected void removeDirectory(CachingDirectoryFactory.CacheValue cacheValue)
                                  throws IOException

      Throws:
        `IOException`

    - #### normalize

          public String normalize(String path)
                           throws IOException

      Description copied from class: `DirectoryFactory`
      Normalize a given path.
      Overrides:
        `normalize` in class `DirectoryFactory`
      Parameters:
        `path` - to normalize
      Returns:
        normalized path
      Throws:
        `IOException` - on io error

    - #### stripTrailingSlash

          protected String stripTrailingSlash(String path)

    - #### getLivePaths

          public Set<String> getLivePaths()

      Method for inspecting the cache
      Returns:
        paths in the cache which have not been marked "done"
      See Also:
        `doneWithDirectory(org.apache.lucene.store.Directory)`

    - #### deleteOldIndexDirectory

          protected boolean deleteOldIndexDirectory(String oldDirPath)
                                             throws IOException

      Overrides:
        `deleteOldIndexDirectory` in class `DirectoryFactory`
      Throws:
        `IOException`

    - #### getPath

          protected String getPath(Directory directory)

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.