Package 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,StandardDirectoryFactory
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).
This is an expert class and these API's are subject to change.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classstatic interfacestatic classDelegates to a filtered or unwrapped directory, and allows this caching factory to release correctly the corresponding cached directory.Nested classes/interfaces inherited from class org.apache.solr.core.DirectoryFactory
DirectoryFactory.DirContext -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IdentityHashMap<org.apache.lucene.store.Directory, CachingDirectoryFactory.CacheValue> protected Map<String, CachingDirectoryFactory.CacheValue> protected Map<org.apache.lucene.store.Directory, List<CachingDirectoryFactory.CloseListener>> protected Set<CachingDirectoryFactory.CacheValue> Fields inherited from class org.apache.solr.core.DirectoryFactory
coreContainer, dataHomePath, INDEX_W_TIMESTAMP_REGEX, IOCONTEXT_NO_CACHE, LOCK_TYPE_NATIVE, LOCK_TYPE_NONE, LOCK_TYPE_SIMPLE, LOCK_TYPE_SINGLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCloseListener(org.apache.lucene.store.Directory dir, CachingDirectoryFactory.CloseListener closeListener) Adds a close listener for a Directory.voidclose()Close this factory and all the Directories it contains.protected booleandeleteOldIndexDirectory(String oldDirPath) voiddoneWithDirectory(org.apache.lucene.store.Directory directory) Indicates a Directory will no longer be used, and when its ref count hits 0, it can be closed.booleanReturns true if a Directory exists for a given path in the underlying (stable) storage and contains at least one file.protected org.apache.lucene.store.DirectoryfilterDirectory(org.apache.lucene.store.Directory dir, DirectoryFactory.DirContext dirContext) Potentially filters or unwraps the cachedDirectorydepending on the intended use defined by theDirectoryFactory.DirContext.final org.apache.lucene.store.Directoryget(String path, DirectoryFactory.DirContext dirContext, String rawLockType) Returns the Directory for a given path, using the specified rawLockType.Method for inspecting the cacheprotected StringgetPath(org.apache.lucene.store.Directory directory) voidincRef(org.apache.lucene.store.Directory directory) Increment the number of references to the given Directory.voidinit(org.apache.solr.common.util.NamedList<?> args) initwill be called just once, immediately after creation.Normalize a given path.voidrelease(org.apache.lucene.store.Directory directory) Releases the Directory so that it may be closed when it is no longer referenced.voidThis remove is special in that it may be called even after the factory has been closed.voidThis remove is special in that it may be called even after the factory has been closed.voidremove(org.apache.lucene.store.Directory dir) Removes the Directory's persistent storage.voidremove(org.apache.lucene.store.Directory dir, boolean deleteAfterCoreClose) Removes the Directory's persistent storage.protected voidremoveDirectory(CachingDirectoryFactory.CacheValue cacheValue) protected StringstripTrailingSlash(String path) Methods inherited from class org.apache.solr.core.DirectoryFactory
cleanupOldIndexDirectories, create, createLockFactory, empty, getBaseDir, getDataHome, initCoreContainer, isAbsolute, isPersistent, isSharedStorage, move, newDefaultUpdateLog, renameWithOverwrite, searchersReserveCommitPoints, size, size, sizeOf, sizeOfDirectory
-
Field Details
-
byPathCache
-
byDirectoryCache
protected IdentityHashMap<org.apache.lucene.store.Directory,CachingDirectoryFactory.CacheValue> byDirectoryCache -
closeListeners
protected Map<org.apache.lucene.store.Directory,List<CachingDirectoryFactory.CloseListener>> closeListeners -
removeEntries
-
-
Constructor Details
-
CachingDirectoryFactory
public CachingDirectoryFactory()
-
-
Method Details
-
addCloseListener
public void addCloseListener(org.apache.lucene.store.Directory dir, CachingDirectoryFactory.CloseListener closeListener) Description copied from class:DirectoryFactoryAdds a close listener for a Directory.- Specified by:
addCloseListenerin classDirectoryFactory
-
doneWithDirectory
Description copied from class:DirectoryFactoryIndicates 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:
doneWithDirectoryin classDirectoryFactory- Throws:
IOException- If there is a low-level I/O error.
-
close
Description copied from class:DirectoryFactoryClose this factory and all the Directories it contains.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classDirectoryFactory- Throws:
IOException- If there is a low-level I/O error.
-
exists
Description copied from class:DirectoryFactoryReturns true if a Directory exists for a given path in the underlying (stable) storage and contains at least one file. Note that the existence of aDirectoryObject as returned by a previous call to theDirectoryFactory.get(java.lang.String, org.apache.solr.core.DirectoryFactory.DirContext, java.lang.String)method (on the specifiedpath) is not enough to cause this method to return true. Some prior user of that Directory must have written & synced at least one file to that Directory (and at least one file must still exist)- Specified by:
existsin classDirectoryFactory- Throws:
IOException- If there is a low-level I/O error.
-
get
public final org.apache.lucene.store.Directory get(String path, DirectoryFactory.DirContext dirContext, String rawLockType) throws IOException Description copied from class:DirectoryFactoryReturns the Directory for a given path, using the specified rawLockType. Will return the same Directory instance for the same path.- Specified by:
getin classDirectoryFactory- Throws:
IOException- If there is a low-level I/O error.
-
filterDirectory
protected org.apache.lucene.store.Directory filterDirectory(org.apache.lucene.store.Directory dir, DirectoryFactory.DirContext dirContext) Potentially filters or unwraps the cachedDirectorydepending on the intended use defined by theDirectoryFactory.DirContext.- Parameters:
dir- theDirectorycached by thisCachingDirectoryFactory.dirContext- the nature or the intended use of the directory.- Returns:
- a filtered or unwrapped version of the directory parameter, or directly the directory parameter if it does not need any filtering/unwrapping.
-
incRef
public void incRef(org.apache.lucene.store.Directory directory) Description copied from class:DirectoryFactoryIncrement the number of references to the given Directory. You must call release for every call to this method.- Specified by:
incRefin classDirectoryFactory
-
init
public void init(org.apache.solr.common.util.NamedList<?> args) Description copied from interface:NamedListInitializedPlugininitwill be called just once, immediately after creation.Source of the initialization arguments will typically be solrconfig.xml, but will ultimately depends on the plugin itself
- Parameters:
args- non-null list of initialization parameters (may be empty)
-
release
Description copied from class:DirectoryFactoryReleases the Directory so that it may be closed when it is no longer referenced.- Specified by:
releasein classDirectoryFactory- Throws:
IOException- If there is a low-level I/O error.
-
remove
Description copied from class:DirectoryFactoryThis 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:
removein classDirectoryFactory- Parameters:
path- to remove- Throws:
IOException- If there is a low-level I/O error.
-
remove
Description copied from class:DirectoryFactoryRemoves the Directory's persistent storage. For example: A file system impl may remove the on disk directory.- Specified by:
removein classDirectoryFactory- Throws:
IOException- If there is a low-level I/O error.
-
remove
Description copied from class:DirectoryFactoryThis 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:
removein classDirectoryFactory- Parameters:
path- to removedeleteAfterCoreClose- whether to wait until after the core is closed.- Throws:
IOException- If there is a low-level I/O error.
-
remove
public void remove(org.apache.lucene.store.Directory dir, boolean deleteAfterCoreClose) throws IOException Description copied from class:DirectoryFactoryRemoves the Directory's persistent storage. For example: A file system impl may remove the on disk directory.- Specified by:
removein classDirectoryFactory- Throws:
IOException- If there is a low-level I/O error.
-
removeDirectory
- Throws:
IOException
-
normalize
Description copied from class:DirectoryFactoryNormalize a given path.- Overrides:
normalizein classDirectoryFactory- Parameters:
path- to normalize- Returns:
- normalized path
- Throws:
IOException- on io error
-
stripTrailingSlash
-
getLivePaths
Method for inspecting the cache- Returns:
- paths in the cache which have not been marked "done"
- See Also:
-
deleteOldIndexDirectory
- Overrides:
deleteOldIndexDirectoryin classDirectoryFactory- Throws:
IOException
-
getPath
-