org.apache.solr.core

## Class DirectoryFactory

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

- All Implemented Interfaces:
    Closeable, AutoCloseable, NamedListInitializedPlugin
  Direct Known Subclasses:
    CachingDirectoryFactory

      public abstract class DirectoryFactory
      extends Object
      implements NamedListInitializedPlugin, Closeable

  Provides access to a Directory implementation. You must release every Directory that you get.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DirectoryFactory.DirContext`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CoreContainer` | `coreContainer`
    `protected static String` | `INDEX_W_TIMESTAMP_REGEX`
    `static IOContext` | `IOCONTEXT_NO_CACHE`
    `static String` | `LOCK_TYPE_HDFS`
    `static String` | `LOCK_TYPE_NATIVE`
    `static String` | `LOCK_TYPE_NONE`
    `static String` | `LOCK_TYPE_SIMPLE`
    `static String` | `LOCK_TYPE_SINGLE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DirectoryFactory()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `addCloseListener(Directory dir, CachingDirectoryFactory.CloseListener closeListener)` Adds a close listener for a Directory.
    `void` | `cleanupOldIndexDirectories(String dataDirPath, String currentIndexDirPath)`
    `abstract void` | `close()` Close the this and all of the Directories it contains.
    `protected abstract Directory` | `create(String path, LockFactory lockFactory, DirectoryFactory.DirContext dirContext)` Creates a new Directory for a given path.
    `protected abstract LockFactory` | `createLockFactory(String rawLockType)` Creates a new LockFactory for a given path.
    `protected boolean` | `deleteOldIndexDirectory(String oldDirPath)`
    `abstract void` | `doneWithDirectory(Directory directory)` Indicates a Directory will no longer be used, and when its ref count hits 0, it can be closed.
    `static boolean` | `empty(Directory dir)` Delete the files in the Directory
    `abstract boolean` | `exists(String path)` Returns true if a Directory exists for a given path.
    `abstract Directory` | `get(String path, DirectoryFactory.DirContext dirContext, String rawLockType)` Returns the Directory for a given path, using the specified rawLockType.
    `String` | `getDataHome(CoreDescriptor cd)`
    `abstract void` | `incRef(Directory directory)` Increment the number of references to the given Directory.
    `void` | `initCoreContainer(CoreContainer cc)`
    `boolean` | `isAbsolute(String path)`
    `abstract boolean` | `isPersistent()`
    `boolean` | `isSharedStorage()`
    `void` | `move(Directory fromDir, Directory toDir, String fileName, IOContext ioContext)` Override for more efficient moves.
    `String` | `normalize(String path)` Normalize a given path.
    `Collection<SolrInfoMBean>` | `offerMBeans()` Optionally allow the DirectoryFactory to request registration of some MBeans.
    `abstract void` | `release(Directory directory)` Releases the Directory so that it may be closed when it is no longer referenced.
    `abstract void` | `remove(Directory dir)` Removes the Directory's persistent storage.
    `abstract void` | `remove(Directory dir, boolean afterCoreClose)` Removes the Directory's persistent storage.
    `abstract void` | `remove(String path)` This remove is special in that it may be called even after the factory has been closed.
    `abstract void` | `remove(String path, boolean afterCoreClose)` This remove is special in that it may be called even after the factory has been closed.
    `boolean` | `searchersReserveCommitPoints()` If your implementation can count on delete-on-last-close semantics or throws an exception when trying to remove a file in use, return false (eg NFS).
    `long` | `size(Directory directory)`
    `long` | `size(String path)`
    `static long` | `sizeOf(Directory directory, String file)`
    `static long` | `sizeOfDirectory(Directory directory)`

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

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

    - ### Methods inherited from interface org.apache.solr.util.plugin.NamedListInitializedPlugin

      `init`

- - ### Field Detail

    - #### IOCONTEXT_NO_CACHE

          public static final IOContext IOCONTEXT_NO_CACHE

    - #### INDEX_W_TIMESTAMP_REGEX

          protected static final String INDEX_W_TIMESTAMP_REGEX

      See Also:
        Constant Field Values

    - #### LOCK_TYPE_SIMPLE

          public static final String LOCK_TYPE_SIMPLE

      See Also:
        Constant Field Values

    - #### LOCK_TYPE_NATIVE

          public static final String LOCK_TYPE_NATIVE

      See Also:
        Constant Field Values

    - #### LOCK_TYPE_SINGLE

          public static final String LOCK_TYPE_SINGLE

      See Also:
        Constant Field Values

    - #### LOCK_TYPE_NONE

          public static final String LOCK_TYPE_NONE

      See Also:
        Constant Field Values

    - #### LOCK_TYPE_HDFS

          public static final String LOCK_TYPE_HDFS

      See Also:
        Constant Field Values

    - #### coreContainer

          protected volatile CoreContainer coreContainer

  - ### Constructor Detail

    - #### DirectoryFactory

          public DirectoryFactory()

  - ### Method Detail

    - #### doneWithDirectory

          public abstract void doneWithDirectory(Directory directory)
                                          throws IOException

      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.
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### addCloseListener

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

      Adds a close listener for a Directory.

    - #### close

          public abstract void close()
                              throws IOException

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

    - #### create

          protected abstract Directory create(String path,
                                              LockFactory lockFactory,
                                              DirectoryFactory.DirContext dirContext)
                                       throws IOException

      Creates a new Directory for a given path.
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### createLockFactory

          protected abstract LockFactory createLockFactory(String rawLockType)
                                                    throws IOException

      Creates a new LockFactory for a given path.
      Parameters:
        `rawLockType` - A string value as passed in config. Every factory should at least support 'none' to disable locking.
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### exists

          public abstract boolean exists(String path)
                                  throws IOException

      Returns true if a Directory exists for a given path.
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### remove

          public abstract void remove(Directory dir)
                               throws IOException

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

    - #### remove

          public abstract void remove(Directory dir,
                                      boolean afterCoreClose)
                               throws IOException

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

    - #### remove

          public abstract void remove(String path,
                                      boolean afterCoreClose)
                               throws IOException

      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.
      Parameters:
        `path` - to remove
        `afterCoreClose` - whether to wait until after the core is closed.
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### remove

          public abstract void remove(String path)
                               throws IOException

      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.
      Parameters:
        `path` - to remove
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### size

          public long size(Directory directory)
                    throws IOException

      Parameters:
        `directory` - to calculate size of
      Returns:
        size in bytes
      Throws:
        `IOException` - on low level IO error

    - #### size

          public long size(String path)
                    throws IOException

      Parameters:
        `path` - to calculate size of
      Returns:
        size in bytes
      Throws:
        `IOException` - on low level IO error

    - #### move

          public void move(Directory fromDir,
                           Directory toDir,
                           String fileName,
                           IOContext ioContext)
                    throws IOException

      Override for more efficient moves. Intended for use with replication - use carefully - some Directory wrappers will cache files for example.
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### get

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

      Returns the Directory for a given path, using the specified rawLockType. Will return the same Directory instance for the same path.
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### incRef

          public abstract void incRef(Directory directory)

      Increment the number of references to the given Directory. You must call release for every call to this method.

    - #### isPersistent

          public abstract boolean isPersistent()

      Returns:
        true if data is kept after close.

    - #### isSharedStorage

          public boolean isSharedStorage()

      Returns:
        true if storage is shared.

    - #### release

          public abstract void release(Directory directory)
                                throws IOException

      Releases the Directory so that it may be closed when it is no longer referenced.
      Throws:
        `IOException` - If there is a low-level I/O error.

    - #### normalize

          public String normalize(String path)
                           throws IOException

      Normalize a given path.
      Parameters:
        `path` - to normalize
      Returns:
        normalized path
      Throws:
        `IOException` - on io error

    - #### isAbsolute

          public boolean isAbsolute(String path)

      Parameters:
        `path` - the path to check
      Returns:
        true if absolute, as in not relative

    - #### sizeOfDirectory

          public static long sizeOfDirectory(Directory directory)
                                      throws IOException

      Throws:
        `IOException`

    - #### sizeOf

          public static long sizeOf(Directory directory,
                                    String file)
                             throws IOException

      Throws:
        `IOException`

    - #### empty

          public static boolean empty(Directory dir)

      Delete the files in the Directory

    - #### searchersReserveCommitPoints

          public boolean searchersReserveCommitPoints()

      If your implementation can count on delete-on-last-close semantics or throws an exception when trying to remove a file in use, return false (eg NFS). Otherwise, return true. Defaults to returning false.
      Returns:
        true if factory impl requires that Searcher's explicitly reserve commit points.

    - #### getDataHome

          public String getDataHome(CoreDescriptor cd)
                             throws IOException

      Throws:
        `IOException`

    - #### offerMBeans

          public Collection<SolrInfoMBean> offerMBeans()

      Optionally allow the DirectoryFactory to request registration of some MBeans.

    - #### cleanupOldIndexDirectories

          public void cleanupOldIndexDirectories(String dataDirPath,
                                                 String currentIndexDirPath)

    - #### deleteOldIndexDirectory

          protected boolean deleteOldIndexDirectory(String oldDirPath)
                                             throws IOException

      Throws:
        `IOException`

    - #### initCoreContainer

          public void initCoreContainer(CoreContainer cc)

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