Package org.nuxeo.ecm.core.blob.binary
Class LocalBinaryManager
- java.lang.Object
-
- org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
-
- org.nuxeo.ecm.core.blob.binary.LocalBinaryManager
-
- All Implemented Interfaces:
BinaryManager
- Direct Known Subclasses:
AESBinaryManager,DefaultBinaryManager
public class LocalBinaryManager extends AbstractBinaryManager
A simple filesystem-based binary manager. It stores the binaries according to their digest (hash), which means that no transactional behavior needs to be implemented.A garbage collection is needed to purge unused binaries.
The format of the binaries directory is:
- data/ hierarchy with the actual binaries in subdirectories,
- tmp/ temporary storage during creation,
- config.xml a file containing the configuration used.
- Since:
- 5.6
- Author:
- Florent Guillaume
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLocalBinaryManager.DefaultBinaryGarbageCollector
-
Field Summary
Fields Modifier and Type Field Description static StringCONFIG_FILEDeprecated.since 11.1, useLocalBlobStoreConfigurationinsteadstatic StringDATADeprecated.since 11.1, useLocalBlobStoreConfigurationinsteadstatic StringDEFAULT_PATHDeprecated.since 11.1, useLocalBlobStoreConfigurationinsteadprotected FilestorageDirstatic StringTMPDeprecated.since 11.1, useLocalBlobStoreConfigurationinsteadprotected FiletmpDirstatic PatternWINDOWS_ABSOLUTE_PATHDeprecated.since 11.1, useLocalBlobStoreConfigurationinstead-
Fields inherited from class org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
blobProviderId, DEFAULT_DEPTH, DEFAULT_DIGEST, descriptor, digestPattern, DIGESTS_BY_LENGTH, garbageCollector, MAX_BUF_SIZE, MD5_DIGEST, MD5_DIGEST_LENGTH, MIN_BUF_SIZE, properties, SHA1_DIGEST, SHA1_DIGEST_LENGTH, SHA256_DIGEST, SHA256_DIGEST_LENGTH
-
Fields inherited from interface org.nuxeo.ecm.core.blob.binary.BinaryManager
PROP_KEY, PROP_PATH
-
-
Constructor Summary
Constructors Constructor Description LocalBinaryManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidatomicMove(File source, File dest)Does an atomic move of the tmp (or source) file to the final file.voidclose()Closes the binary manager and releases all resources and temporary objects held by it.protected voidcreateGarbageCollector()protected BinarygetBinary(InputStream in)Creates a binary value from the given input stream.BinarygetBinary(String digest)Returns aBinarycorresponding to the given digest.FilegetFileForDigest(String digest, boolean createDir)Gets a file representing the storage for a given digest.FilegetStorageDir()voidinitialize(String blobProviderId, Map<String,String> properties)Initializes the binary manager.protected StringstoreAndDigest(InputStream in)static voidtouch(File file)Sets the last modification date to now on a file-
Methods inherited from class org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
computeDigestPattern, getBinary, getDefaultDigestAlgorithm, getDescriptor, getDigestAlgorithm, getGarbageCollector, isValidDigest, removeBinaries, setDescriptor, storeAndDigest, toHexString
-
-
-
-
Field Detail
-
WINDOWS_ABSOLUTE_PATH
@Deprecated public static final Pattern WINDOWS_ABSOLUTE_PATH
Deprecated.since 11.1, useLocalBlobStoreConfigurationinstead
-
DEFAULT_PATH
@Deprecated public static final String DEFAULT_PATH
Deprecated.since 11.1, useLocalBlobStoreConfigurationinstead- See Also:
- Constant Field Values
-
DATA
@Deprecated public static final String DATA
Deprecated.since 11.1, useLocalBlobStoreConfigurationinstead- See Also:
- Constant Field Values
-
TMP
@Deprecated public static final String TMP
Deprecated.since 11.1, useLocalBlobStoreConfigurationinstead- See Also:
- Constant Field Values
-
CONFIG_FILE
@Deprecated public static final String CONFIG_FILE
Deprecated.since 11.1, useLocalBlobStoreConfigurationinstead- See Also:
- Constant Field Values
-
storageDir
protected File storageDir
-
tmpDir
protected File tmpDir
-
-
Method Detail
-
initialize
public void initialize(String blobProviderId, Map<String,String> properties) throws IOException
Description copied from interface:BinaryManagerInitializes the binary manager.- Specified by:
initializein interfaceBinaryManager- Overrides:
initializein classAbstractBinaryManager- Parameters:
blobProviderId- the blob provider id for this binary managerproperties- initialization properties- Throws:
IOException
-
close
public void close()
Description copied from interface:BinaryManagerCloses the binary manager and releases all resources and temporary objects held by it.
-
getStorageDir
public File getStorageDir()
-
getBinary
protected Binary getBinary(InputStream in) throws IOException
Description copied from class:AbstractBinaryManagerCreates a binary value from the given input stream.- Specified by:
getBinaryin classAbstractBinaryManager- Throws:
IOException
-
getBinary
public Binary getBinary(String digest)
Description copied from interface:BinaryManagerReturns aBinarycorresponding to the given digest.A
nullis returned if the digest could not be found.- Specified by:
getBinaryin interfaceBinaryManager- Specified by:
getBinaryin classAbstractBinaryManager- Parameters:
digest- the digest, ornull- Returns:
- the corresponding binary
-
getFileForDigest
public File getFileForDigest(String digest, boolean createDir)
Gets a file representing the storage for a given digest.- Parameters:
digest- the digestcreateDir-trueif the directory containing the file itself must be created- Returns:
- the file for this digest
-
storeAndDigest
protected String storeAndDigest(InputStream in) throws IOException
- Throws:
IOException
-
atomicMove
protected void atomicMove(File source, File dest) throws IOException
Does an atomic move of the tmp (or source) file to the final file.Tries to work well with NFS mounts and different filesystems.
- Throws:
IOException
-
createGarbageCollector
protected void createGarbageCollector()
-
touch
public static void touch(File file)
Sets the last modification date to now on a file- Parameters:
file- the file
-
-