|
ozone core API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ozoneDB.core.storage.gammaStore.FileStorageFactory
Abstract base class for storage factories that use files.
Field Summary | |
private java.io.File |
directory
|
static PropertyInfo |
DIRECTORY
|
private static java.util.logging.Logger |
log
|
private static int |
NAMECONVERTRADIX
Used to name directories. |
private java.lang.String |
prefix
|
private int |
subdirectoryCount
|
static PropertyInfo |
SUBDIRECTORYCOUNT
|
private static java.lang.String |
SUBDIRECTORYCOUNT_KEY
|
private int |
subdirectoryDepth
|
static PropertyInfo |
SUBDIRECTORYDEPTH
|
private static java.lang.String |
SUBDIRECTORYDEPTH_KEY
|
Constructor Summary | |
protected |
FileStorageFactory(java.util.Properties properties,
java.lang.String prefix)
As prescribed by the PropertyConfigurable interface. |
Method Summary | |
void |
delete(java.lang.String name)
Deletes the data in the namespace of this instance specified by name. |
void |
deleteAll()
Deletes all data that are in the namespace of this instance. |
private void |
deleteDirectory(java.io.File directory)
deletes all files and subdirectories in the specified directory, but does _not_ delete the specified directory |
protected void |
ensureParentsExist(java.io.File file)
|
private int |
findDepth(java.io.File directory,
int startDepth)
|
protected java.io.File |
getDirectory()
|
java.lang.String |
getPrefix()
|
java.util.Collection |
getPropertyInfos()
Implementing classes should override this method, call super and add their own specific properties. |
private int |
getSubdirectoryCount()
|
private int |
getSubdirectoryDepth()
|
private void |
moveFiles(java.io.File directory,
int relDepth,
int targetDepth,
int targetCount)
|
protected java.io.File |
nameToFile(java.lang.String name)
|
protected java.io.File |
nameToFile(java.lang.String name,
int depth,
int count)
Returns the File that corresponds to the given name and
depth. |
private void |
recursiveDeleteIfEmpty(java.io.File directory)
|
private void |
setDirectory(java.io.File directory)
|
private void |
setPrefix(java.lang.String prefix)
|
private void |
setSubdirectoryCount(int subdirectoryCount)
|
private void |
setSubdirectoryDepth(int depth)
Sets the depth of subdirectories to use. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.ozoneDB.core.storage.gammaStore.StorageFactory |
createStorage |
Field Detail |
private static java.util.logging.Logger log
public static final PropertyInfo DIRECTORY
private static final java.lang.String SUBDIRECTORYDEPTH_KEY
private static final java.lang.String SUBDIRECTORYCOUNT_KEY
public static final PropertyInfo SUBDIRECTORYDEPTH
public static final PropertyInfo SUBDIRECTORYCOUNT
private static final int NAMECONVERTRADIX
Used to name directories. We could take any value from 2 to
Character.MAX_RADIX
(36) here, but we settle for 16 because
it looks nice and nerdy. 36 would look less nice because that could
lead to directories with very nasty words in them when SUBDIRECTORYCOUNT
is large enough.
private java.io.File directory
private java.lang.String prefix
private int subdirectoryDepth
private int subdirectoryCount
Constructor Detail |
protected FileStorageFactory(java.util.Properties properties, java.lang.String prefix)
PropertyConfigurable
interface.
Method Detail |
private int findDepth(java.io.File directory, int startDepth)
public void delete(java.lang.String name) throws java.io.IOException
StorageFactory
Deletes the data in the namespace of this instance specified by name. Typical file-based implementations would delete the file specified by name from the directory this instance uses.
Should not throw any exception if the specified file does not exist.
delete
in interface StorageFactory
name
- name of the data to delete
java.io.IOException
public void deleteAll() throws java.io.IOException
StorageFactory
Deletes all data that are in the namespace of this instance. Typical file-based implementations would delete all files in the directory this instance uses.
deleteAll
in interface StorageFactory
true
if data was deleted, false
if
otherwise.
java.io.IOException
private void deleteDirectory(java.io.File directory) throws java.io.IOException
java.io.IOException
private void setSubdirectoryDepth(int depth) throws java.io.IOException
Sets the depth of subdirectories to use. You must make sure that no
reading or writing is taking place in the directory specified by
getDirectory()
, either by this class, or outside this class
(for instance with 'cat' or 'type' in a shell / cmd window)
The whole directory structure is changed when this method is called, so it may take some time to complete.
java.io.IOException
private void moveFiles(java.io.File directory, int relDepth, int targetDepth, int targetCount) throws java.io.IOException
java.io.IOException
private void recursiveDeleteIfEmpty(java.io.File directory) throws java.io.IOException
java.io.IOException
private int getSubdirectoryDepth()
public java.lang.String getPrefix()
getPrefix
in interface PropertyConfigurable
protected java.io.File nameToFile(java.lang.String name, int depth, int count)
File
that corresponds to the given name and
depth.
protected java.io.File nameToFile(java.lang.String name)
protected void ensureParentsExist(java.io.File file) throws java.io.IOException
java.io.IOException
private void setPrefix(java.lang.String prefix)
protected java.io.File getDirectory()
private void setDirectory(java.io.File directory)
public java.util.Collection getPropertyInfos()
getPropertyInfos
in interface PropertyConfigurable
PropertyInfo
elementsprivate int getSubdirectoryCount()
private void setSubdirectoryCount(int subdirectoryCount)
|
ozone core API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |