org.apache.solr.core
Class DirectoryFactory

java.lang.Object
  extended by org.apache.solr.core.DirectoryFactory
All Implemented Interfaces:
Closeable, 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.


Constructor Summary
DirectoryFactory()
           
 
Method Summary
abstract  void addCloseListener(Directory dir, CachingDirectoryFactory.CloseListener closeListener)
          Adds a close listener for a Directory.
abstract  void close()
          Close the this and all of the Directories it contains.
protected abstract  Directory create(String path)
          Creates a new Directory for a given path.
abstract  void doneWithDirectory(Directory directory)
          Indicates a Directory will no longer be used, and when it's ref count hits 0, it can be closed.
abstract  boolean exists(String path)
          Returns true if a Directory exists for a given path.
abstract  Directory get(String path, String rawLockType)
          Returns the Directory for a given path, using the specified rawLockType.
abstract  Directory get(String path, String rawLockType, boolean forceNew)
          Returns the Directory for a given path, using the specified rawLockType.
abstract  void incRef(Directory directory)
          Increment the number of references to the given Directory.
abstract  void release(Directory directory)
          Releases the Directory so that it may be closed when it is no longer referenced.
 
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
 

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 it's ref count hits 0, it can be closed. On shutdown all directories will be closed with this has been called or not. This is simply to allow early cleanup.

Parameters:
directory -
Throws:
IOException

addCloseListener

public abstract void addCloseListener(Directory dir,
                                      CachingDirectoryFactory.CloseListener closeListener)
Adds a close listener for a Directory.

Parameters:
dir -
closeListener -

close

public abstract void close()
                    throws IOException
Close the this and all of the Directories it contains.

Specified by:
close in interface Closeable
Throws:
IOException

create

protected abstract Directory create(String path)
                             throws IOException
Creates a new Directory for a given path.

Throws:
IOException

exists

public abstract boolean exists(String path)
Returns true if a Directory exists for a given path.


get

public abstract Directory get(String path,
                              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

get

public abstract Directory get(String path,
                              String rawLockType,
                              boolean forceNew)
                       throws IOException
Returns the Directory for a given path, using the specified rawLockType. Will return the same Directory instance for the same path unless forceNew, in which case a new Directory is returned. There is no need to call doneWithDirectory(Directory) in this case - the old Directory will be closed when it's ref count hits 0.

Throws:
IOException

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.


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


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