public class LocalBinaryManager extends AbstractBinaryManager
A garbage collection is needed to purge unused binaries.
The format of the binaries directory is:
Modifier and Type | Class and Description |
---|---|
static class |
LocalBinaryManager.DefaultBinaryGarbageCollector |
Modifier and Type | Field and Description |
---|---|
static String |
CONFIG_FILE |
static String |
DATA |
static String |
DEFAULT_PATH |
protected File |
storageDir |
static String |
TMP |
protected File |
tmpDir |
static Pattern |
WINDOWS_ABSOLUTE_PATH |
blobProviderId, DEFAULT_DEPTH, DEFAULT_DIGEST, descriptor, DIGESTS_BY_LENGTH, garbageCollector, MAX_BUF_SIZE, MD5_DIGEST, MD5_DIGEST_LENGTH, MIN_BUF_SIZE, SHA1_DIGEST, SHA1_DIGEST_LENGTH, SHA256_DIGEST, SHA256_DIGEST_LENGTH
PROP_KEY, PROP_PATH
Constructor and Description |
---|
LocalBinaryManager() |
Modifier and Type | Method and Description |
---|---|
protected void |
atomicMove(File source,
File dest)
Does an atomic move of the tmp (or source) file to the final file.
|
void |
close()
Closes the binary manager and releases all resources and temporary objects held by it.
|
protected void |
createGarbageCollector() |
protected Binary |
getBinary(InputStream in)
Creates a binary value from the given input stream.
|
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.
|
File |
getStorageDir() |
void |
initialize(String blobProviderId,
Map<String,String> properties)
Initializes the binary manager.
|
protected String |
storeAndDigest(InputStream in) |
static void |
touch(File file)
Sets the last modification date to now on a file
|
getBinary, getDefaultDigestAlgorithm, getDescriptor, getDigestAlgorithm, getGarbageCollector, removeBinaries, storeAndDigest, toHexString
public static final Pattern WINDOWS_ABSOLUTE_PATH
public static final String DEFAULT_PATH
public static final String DATA
public static final String TMP
public static final String CONFIG_FILE
protected File storageDir
public LocalBinaryManager()
public void initialize(String blobProviderId, Map<String,String> properties) throws IOException
BinaryManager
initialize
in interface BinaryManager
initialize
in class AbstractBinaryManager
blobProviderId
- the blob provider id for this binary managerproperties
- initialization propertiesIOException
public void close()
BinaryManager
public File getStorageDir()
protected Binary getBinary(InputStream in) throws IOException
AbstractBinaryManager
getBinary
in class AbstractBinaryManager
IOException
public Binary getBinary(String digest)
BinaryManager
Binary
corresponding to the given digest.
A null
is returned if the digest could not be found.
getBinary
in interface BinaryManager
getBinary
in class AbstractBinaryManager
digest
- the digest, or null
public File getFileForDigest(String digest, boolean createDir)
digest
- the digestcreateDir
- true
if the directory containing the file itself must be createdprotected String storeAndDigest(InputStream in) throws IOException
IOException
protected void atomicMove(File source, File dest) throws IOException
Tries to work well with NFS mounts and different filesystems.
IOException
protected void createGarbageCollector()
Copyright © 2015 Nuxeo SA. All rights reserved.