public class DefaultBinaryManager extends Object implements BinaryManager
A garbage collection is needed to purge unused binaries.
The format of the binaries directory is:
| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultBinaryManager.DefaultBinaryGarbageCollector |
static class |
DefaultBinaryManager.NullBinaryScrambler
A
BinaryScrambler that does nothing. |
static class |
DefaultBinaryManager.ScrambledBinary
A
Binary that is unscrambled on read using a
BinaryScrambler. |
static class |
DefaultBinaryManager.ScrambledFileInputStream
A
FileInputStream that is unscrambled on read using a
BinaryScrambler. |
static class |
DefaultBinaryManager.ScrambledStreamSource
A
FileSource that is unscrambled on read using a
BinaryScrambler. |
| Modifier and Type | Field and Description |
|---|---|
static String |
CONFIG_FILE |
static String |
DATA |
static int |
DEFAULT_DEPTH |
static String |
DEFAULT_DIGEST |
static String |
DEFAULT_PATH |
static int |
MAX_BUF_SIZE |
static int |
MIN_BUF_SIZE |
static String |
TMP |
| Constructor and Description |
|---|
DefaultBinaryManager() |
| Modifier and Type | Method and Description |
|---|---|
Binary |
getBinary(InputStream in)
Saves the given input stream into a
Binary. |
Binary |
getBinary(String digest)
Returns a
Binary corresponding to the given digest. |
File |
getFileForDigest(String digest,
boolean createDir)
Gets a file representing the storage for a given digest.
|
BinaryGarbageCollector |
getGarbageCollector()
Returns the Binary Garbage Collector that can be used for this binary
manager.
|
File |
getStorageDir() |
void |
initialize(RepositoryDescriptor repositoryDescriptor)
Initializer.
|
static String |
toHexString(byte[] data) |
static void |
touch(File file)
Sets the last modification date to now on a file
|
public static final String DEFAULT_DIGEST
public static final int DEFAULT_DEPTH
public static final String DEFAULT_PATH
public static final String DATA
public static final String TMP
public static final String CONFIG_FILE
public static final int MIN_BUF_SIZE
public static final int MAX_BUF_SIZE
public void initialize(RepositoryDescriptor repositoryDescriptor) throws IOException
BinaryManagerinitialize in interface BinaryManagerIOExceptionpublic File getStorageDir()
public Binary getBinary(InputStream in) throws IOException
BinaryManagerBinary.
Returns a Binary representing the stream. The Binary
includes a digest that is a sufficient representation to persist it.
The stream is closed after use.
getBinary in interface BinaryManagerin - the input streamIOExceptionpublic Binary getBinary(String digest)
BinaryManagerBinary corresponding to the given digest.
A null is returned if the digest could not be found.
getBinary in interface BinaryManagerdigest - the digest, or nullpublic File getFileForDigest(String digest, boolean createDir)
digest - the digestcreateDir - true if the directory containing the file itself
must be createdpublic static String toHexString(byte[] data)
public BinaryGarbageCollector getGarbageCollector()
BinaryManager
Several calls to this method will return the same GC, so that its status
can be monitored using BinaryGarbageCollector.isInProgress().
getGarbageCollector in interface BinaryManagerpublic static void touch(File file)
file - the fileCopyright © 2011 Nuxeo SA. All Rights Reserved.