public abstract class AbstractBlobStore extends java.lang.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".
|
void |
close() |
boolean |
deleteChunks(java.util.List<java.lang.String> chunkIds,
long maxLastModifiedTime)
Deletes the blobs with the given ids.
|
java.lang.String |
getBlobId(@NotNull java.lang.String reference)
Returns the blobId that referred by the given binary reference.
|
long |
getBlobLength(java.lang.String blobId)
Get the length of the blob.
|
int |
getBlockSize() |
long |
getBlockSizeMin()
Get the minimum block size (if there is any).
|
java.io.InputStream |
getInputStream(java.lang.String blobId)
Returns a new stream for given blobId.
|
java.lang.String |
getReference(@NotNull java.lang.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(java.lang.String blobId,
long pos,
byte[] buff,
int off,
int length)
Read a number of bytes from a blob.
|
java.util.Iterator<java.lang.String> |
resolveChunks(java.lang.String blobId)
Resolve chunks stored in the blob store 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(java.lang.String encodedKey)
Set the referenceKey from Base64 encoded byte array
|
void |
setReferenceKeyPlainText(java.lang.String textKey)
Set the referenceKey from plain text.
|
void |
setStatsCollector(BlobStatsCollector stats) |
abstract void |
startMark()
Start the mark phase.
|
abstract int |
sweep()
Remove all unused blocks.
|
java.lang.String |
writeBlob(java.io.InputStream in)
Write a blob from an input stream.
|
java.lang.String |
writeBlob(java.io.InputStream in,
BlobOptions options)
Default implementation ignores options and delegates to the
writeBlob(InputStream)
method. |
java.lang.String |
writeBlob(java.lang.String tempFilePath)
Write a blob from a temporary file.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clearCache, countDeleteChunks, 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 void setStatsCollector(BlobStatsCollector stats)
public int getBlockSize()
public java.lang.String writeBlob(java.lang.String tempFilePath) throws java.io.IOException
GarbageCollectableBlobStore
writeBlob
in interface GarbageCollectableBlobStore
tempFilePath
- the temporary file namejava.io.IOException
public java.lang.String writeBlob(java.io.InputStream in) throws java.io.IOException
BlobStore
public java.lang.String writeBlob(java.io.InputStream in, BlobOptions options) throws java.io.IOException
writeBlob(InputStream)
method.public java.io.InputStream getInputStream(java.lang.String blobId) throws java.io.IOException
BlobStore
read
return the same sequence of bytes as long as neither call throws
an exception.getInputStream
in interface BlobStore
blobId
- the blob idjava.io.IOException
public java.lang.String getReference(@NotNull @NotNull java.lang.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 java.lang.String getBlobId(@NotNull @NotNull java.lang.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(java.lang.String encodedKey)
encodedKey
- base64 encoded keypublic void setReferenceKeyPlainText(java.lang.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 java.io.IOException
GarbageCollectableBlobStore
startMark
in interface GarbageCollectableBlobStore
java.io.IOException
public abstract int sweep() throws java.io.IOException
GarbageCollectableBlobStore
sweep
in interface GarbageCollectableBlobStore
java.io.IOException
public int readBlob(java.lang.String blobId, long pos, byte[] buff, int off, int length) throws java.io.IOException
BlobStore
public AbstractBlobStore.Data load(AbstractBlobStore.BlockId id)
Cache.Backend
load
in interface Cache.Backend<AbstractBlobStore.BlockId,AbstractBlobStore.Data>
id
- the keypublic long getBlobLength(java.lang.String blobId) throws java.io.IOException
BlobStore
getBlobLength
in interface BlobStore
blobId
- the blob idjava.io.IOException
public java.util.Iterator<java.lang.String> resolveChunks(java.lang.String blobId) throws java.io.IOException
GarbageCollectableBlobStore
resolveChunks
in interface GarbageCollectableBlobStore
blobId
- the blob idjava.io.IOException
- Signals that an I/O exception has occurred.public boolean deleteChunks(java.util.List<java.lang.String> chunkIds, long maxLastModifiedTime) throws java.lang.Exception
GarbageCollectableBlobStore
deleteChunks
in interface GarbageCollectableBlobStore
chunkIds
- the chunk idsmaxLastModifiedTime
- the max last modified time to consider for retrieval,
with the special value '0' meaning no filtering by timejava.lang.Exception
- the exceptionpublic void close() throws java.lang.Exception
close
in interface java.lang.AutoCloseable
java.lang.Exception
Copyright © 2010 - 2020 Adobe. All Rights Reserved