public abstract class AbstractBlobStore extends Object implements GarbageCollectableBlobStore, Cache.Backend<AbstractBlobStore.BlockId,AbstractBlobStore.Data>
Each data store id is a list of zero or more entries. Each entry is either
The format of a 'data' entry is: type (one byte; 0 for data), length (variable size int), data (bytes).
The format of a 'hash of content' entry is: type (one byte; 1 for hash), level (variable size int, 0 meaning not nested), size (variable size long), hash code length (variable size int), hash code.
The format of a 'hash of data store id' entry is: type (one byte; 1 for hash), level (variable size int, nesting level), total size (variable size long), size of data store id (variable size long), hash code length (variable size int), hash code.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractBlobStore.BlockId
A block id.
|
static class |
AbstractBlobStore.Data
The data for a block.
|
Constructor and Description |
---|
AbstractBlobStore() |
Modifier and Type | Method and Description |
---|---|
void |
clearInUse()
Clear all objects marked as "transiently in use".
|
String |
getBlobId(String reference)
Returns the blobId that referred by the given binary reference.
|
long |
getBlobLength(String blobId)
Get the length of the blob.
|
int |
getBlockSize() |
long |
getBlockSizeMin()
Get the minimum block size (if there is any).
|
InputStream |
getInputStream(String blobId)
Returns a new stream for given blobId.
|
String |
getReference(String blobId)
Returns a secure reference to blob referred by blobid, or
null if no such
reference is available. |
AbstractBlobStore.Data |
load(AbstractBlobStore.BlockId id)
Load the object.
|
int |
readBlob(String blobId,
long pos,
byte[] buff,
int off,
int length)
Read a number of bytes from a blob.
|
Iterator<String> |
resolveChunks(String blobId)
Resolve chunks from the given Id.
|
void |
setBlockSize(int x)
Set the block size used by this blob store, if the blob store splits
binaries into blocks.
|
void |
setBlockSizeMin(int x) |
void |
setReferenceKey(byte[] referenceKey) |
void |
setReferenceKeyEncoded(String encodedKey)
Set the referenceKey from Base64 encoded byte array
|
void |
setReferenceKeyPlainText(String textKey)
Set the referenceKey from plain text.
|
abstract void |
startMark()
Start the mark phase.
|
abstract int |
sweep()
Remove all unused blocks.
|
String |
writeBlob(InputStream in)
Write a blob from an input stream.
|
String |
writeBlob(String tempFilePath)
Write a blob from a temporary file.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clearCache, deleteChunks, getAllChunkIds
public void setBlockSizeMin(int x)
public long getBlockSizeMin()
GarbageCollectableBlobStore
getBlockSizeMin
in interface GarbageCollectableBlobStore
public void setBlockSize(int x)
GarbageCollectableBlobStore
setBlockSize
in interface GarbageCollectableBlobStore
x
- the block size in bytes.public int getBlockSize()
public String writeBlob(String tempFilePath) throws IOException
GarbageCollectableBlobStore
writeBlob
in interface GarbageCollectableBlobStore
tempFilePath
- the temporary file nameIOException
public String writeBlob(InputStream in) throws IOException
BlobStore
writeBlob
in interface BlobStore
in
- the input streamIOException
public InputStream getInputStream(String blobId) throws IOException
BlobStore
read
return the same sequence of bytes as long as neither call throws
an exception.getInputStream
in interface BlobStore
blobId
- the blob idIOException
public String getReference(String blobId)
BlobStore
null
if no such
reference is available.getReference
in interface BlobStore
blobId
- blobId referring the blob for which reference is requirednull
public String getBlobId(String reference)
BlobStore
null
if the reference is invalid, for example if it
points to a blob that does not exist.public void setReferenceKey(byte[] referenceKey)
public void setReferenceKeyEncoded(String encodedKey)
encodedKey
- base64 encoded keypublic void setReferenceKeyPlainText(String textKey)
This is useful when setting key via generic
bean property manipulation from string properties. User can specify the
key in plain text and that would be passed on this object via
PropertiesUtil.populate(Object, java.util.Map, boolean)
textKey
- base64 encoded keyPropertiesUtil.populate(Object, java.util.Map, boolean)
public void clearInUse()
GarbageCollectableBlobStore
clearInUse
in interface GarbageCollectableBlobStore
public abstract void startMark() throws IOException
GarbageCollectableBlobStore
startMark
in interface GarbageCollectableBlobStore
IOException
public abstract int sweep() throws IOException
GarbageCollectableBlobStore
sweep
in interface GarbageCollectableBlobStore
IOException
public int readBlob(String blobId, long pos, byte[] buff, int off, int length) throws IOException
BlobStore
readBlob
in interface BlobStore
blobId
- the blob idpos
- the position within the blobbuff
- the target byte arrayoff
- the offset within the target arraylength
- the number of bytes to readIOException
public AbstractBlobStore.Data load(AbstractBlobStore.BlockId id)
Cache.Backend
load
in interface Cache.Backend<AbstractBlobStore.BlockId,AbstractBlobStore.Data>
id
- the keypublic long getBlobLength(String blobId) throws IOException
BlobStore
getBlobLength
in interface BlobStore
blobId
- the blob idIOException
public Iterator<String> resolveChunks(String blobId) throws IOException
GarbageCollectableBlobStore
resolveChunks
in interface GarbageCollectableBlobStore
blobId
- the blob idIOException
- Signals that an I/O exception has occurred."Copyright © 2006 - 2015 Adobe Systems Incorporated. All Rights Reserved"