public final class DiskStorePathManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
DiskStorePathManager.DiskstoreNotExclusiveException
Exception class thrown when a diskstore path collides with an existing one
|
private static class |
DiskStorePathManager.DiskStorePath
Resolved path and lock details
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
AUTO_DISK_PATH_DIRECTORY_PREFIX
If the CacheManager needs to resolve a conflict with the disk path, it will create a
subdirectory in the given disk path with this prefix followed by a number.
|
private boolean |
defaultPath |
private static int |
DEL |
private static char |
ESCAPE |
private static java.util.Set<java.lang.Character> |
ILLEGALS |
private java.io.File |
initialPath |
private static java.lang.String |
LOCK_FILE_NAME |
private static org.slf4j.Logger |
LOG |
private DiskStorePathManager.DiskStorePath |
path |
Constructor and Description |
---|
DiskStorePathManager()
Create a diskstore path manager using the default path.
|
DiskStorePathManager(java.lang.String initialPath)
Create a diskstore path manager with provided initial path.
|
Modifier and Type | Method and Description |
---|---|
private static void |
deleteFile(java.io.File f) |
java.io.File |
getFile(java.lang.String name)
Get a file object for the given name
|
java.io.File |
getFile(java.lang.String cacheName,
java.lang.String suffix)
Get a file object for the given cache-name and suffix
|
boolean |
isAutoCreated()
Was this path auto-created (ie.
|
boolean |
isDefault()
Was this path sourced from the default value.
|
void |
releaseLock()
release the lock file used for collision detection
should be called when cache manager shutdowns
|
boolean |
resolveAndLockIfExists(java.lang.String file)
Resolve and lock this disk store path if the resultant path contains the supplied file.
|
private void |
resolveAndLockIfNeeded(boolean allowAutoCreate) |
private static java.lang.String |
safeName(java.lang.String name)
sanitize a name for valid file or directory name
|
private static final java.lang.String AUTO_DISK_PATH_DIRECTORY_PREFIX
private static final org.slf4j.Logger LOG
private static final java.lang.String LOCK_FILE_NAME
private static final int DEL
private static final char ESCAPE
private static final java.util.Set<java.lang.Character> ILLEGALS
private final java.io.File initialPath
private final boolean defaultPath
private volatile DiskStorePathManager.DiskStorePath path
public DiskStorePathManager(java.lang.String initialPath)
path
- public DiskStorePathManager()
public boolean resolveAndLockIfExists(java.lang.String file)
file
- file to check fortrue
if the file existed and the path was successfully lockedprivate void resolveAndLockIfNeeded(boolean allowAutoCreate) throws DiskStorePathManager.DiskstoreNotExclusiveException
private static java.lang.String safeName(java.lang.String name)
name
- private static void deleteFile(java.io.File f)
public boolean isAutoCreated()
public boolean isDefault()
public void releaseLock()
public java.io.File getFile(java.lang.String cacheName, java.lang.String suffix)
cacheName
- the cache namesuffix
- a file suffixpublic java.io.File getFile(java.lang.String name)
name
- the file name