Class AbstractSharedCachingDataStore
- java.lang.Object
-
- org.apache.jackrabbit.core.data.AbstractDataStore
-
- org.apache.jackrabbit.oak.plugins.blob.AbstractSharedCachingDataStore
-
- All Implemented Interfaces:
DataStore
,MultiDataStoreAware
,TypedDataStore
,SharedDataStore
- Direct Known Subclasses:
AzureDataStore
,CachingFileDataStore
,S3DataStore
public abstract class AbstractSharedCachingDataStore extends AbstractDataStore implements MultiDataStoreAware, SharedDataStore, TypedDataStore
Cache files locally and stage files locally for async uploads. Configuration:<DataStore class="org.apache.jackrabbit.oak.plugins.blob.AbstractCachingDataStore"> <param name="
path
"/> <param name="cacheSize
" value="68719476736"/> <param name="stagingSplitPercentage
" value="10"/> <param name="uploadThreads
" value="10"/> <param name="stagingPurgeInterval
" value="300"/> <param name="stagingRetryInterval
" value="600"/> </DataStore>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.jackrabbit.oak.plugins.blob.SharedDataStore
SharedDataStore.Type
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractSharedBackend
backend
The delegate backendprotected CompositeDataStoreCache
cache
DataStore cacheprotected ExecutorService
executor
protected org.apache.jackrabbit.guava.common.util.concurrent.ListeningExecutorService
listeningExecutor
protected ScheduledExecutorService
schedulerExecutor
-
Fields inherited from class org.apache.jackrabbit.core.data.AbstractDataStore
DIGEST
-
-
Constructor Summary
Constructors Constructor Description AbstractSharedCachingDataStore()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addMetadataRecord(File f, String name)
Adds the root record.void
addMetadataRecord(InputStream stream, String name)
------------------------ SharedDataStore methods -----------------------------------------DataRecord
addRecord(InputStream inputStream)
DataRecord
addRecord(InputStream inputStream, BlobOptions blobOptions)
Add a record with specified options.void
clearInUse()
------------------------ unimplemented methods -------------------------------------------void
close()
protected abstract AbstractSharedBackend
createBackend()
void
deleteAllMetadataRecords(String prefix)
Deletes all records matching the given prefix.int
deleteAllOlderThan(long l)
boolean
deleteMetadataRecord(String name)
Deletes the root record represented by the given parameters.void
deleteRecord(DataIdentifier dataIdentifier)
boolean
exists(DataIdentifier identifier)
Look in the backend for a record matching the given identifier.Iterator<DataIdentifier>
getAllIdentifiers()
In rare cases may include some duplicates in cases where async staged uploads complete during iteration.List<DataRecord>
getAllMetadataRecords(String prefix)
Gets the all root records.Iterator<DataRecord>
getAllRecords()
Retrieved an iterator over all DataRecords.protected CompositeDataStoreCache
getCache()
DataRecord
getMetadataRecord(String name)
Retrieves the metadata record with the given nameprotected byte[]
getOrCreateReferenceKey()
DataRecord
getRecord(DataIdentifier identifier)
DataRecord
getRecordForId(DataIdentifier identifier)
Retrieves the record for the given identifier@Nullable DataRecord
getRecordIfStored(DataIdentifier dataIdentifier)
List<DataStoreCacheStatsMBean>
getStats()
SharedDataStore.Type
getType()
Gets the type.void
init(String homeDir)
boolean
metadataRecordExists(String name)
Checks if the metadata record with the name existsvoid
setCacheSize(long cacheSize)
void
setPath(String path)
------------------------- setters ----------------------------------------------void
setStagingPurgeInterval(int stagingPurgeInterval)
void
setStagingRetryInterval(int stagingRetryInterval)
void
setStagingSplitPercentage(int stagingSplitPercentage)
void
setStatisticsProvider(StatisticsProvider statisticsProvider)
void
setUploadThreads(int uploadThreads)
void
updateModifiedDateOnAccess(long l)
-
Methods inherited from class org.apache.jackrabbit.core.data.AbstractDataStore
encodeHexString, getRecordFromReference, getReferenceFromIdentifier
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.jackrabbit.core.data.DataStore
getMinRecordLength
-
Methods inherited from interface org.apache.jackrabbit.oak.plugins.blob.SharedDataStore
getRepositoryId, setRepositoryId
-
-
-
-
Field Detail
-
cache
protected CompositeDataStoreCache cache
DataStore cache
-
backend
protected AbstractSharedBackend backend
The delegate backend
-
listeningExecutor
protected org.apache.jackrabbit.guava.common.util.concurrent.ListeningExecutorService listeningExecutor
-
schedulerExecutor
protected ScheduledExecutorService schedulerExecutor
-
executor
protected ExecutorService executor
-
-
Method Detail
-
init
public void init(String homeDir) throws DataStoreException
- Specified by:
init
in interfaceDataStore
- Throws:
DataStoreException
-
createBackend
protected abstract AbstractSharedBackend createBackend()
-
getRecord
public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException
- Specified by:
getRecord
in interfaceDataStore
- Overrides:
getRecord
in classAbstractDataStore
- Throws:
DataStoreException
-
getRecordIfStored
@Nullable public @Nullable DataRecord getRecordIfStored(DataIdentifier dataIdentifier) throws DataStoreException
- Specified by:
getRecordIfStored
in interfaceDataStore
- Throws:
DataStoreException
-
addRecord
public DataRecord addRecord(InputStream inputStream) throws DataStoreException
- Specified by:
addRecord
in interfaceDataStore
- Throws:
DataStoreException
-
addRecord
public DataRecord addRecord(InputStream inputStream, BlobOptions blobOptions) throws DataStoreException
Description copied from interface:TypedDataStore
Add a record with specified options.- Specified by:
addRecord
in interfaceTypedDataStore
- Returns:
- Throws:
DataStoreException
-
getAllIdentifiers
public Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException
In rare cases may include some duplicates in cases where async staged uploads complete during iteration.- Specified by:
getAllIdentifiers
in interfaceDataStore
- Returns:
- Iterator over all ids available
- Throws:
DataStoreException
-
deleteRecord
public void deleteRecord(DataIdentifier dataIdentifier) throws DataStoreException
- Specified by:
deleteRecord
in interfaceMultiDataStoreAware
- Throws:
DataStoreException
-
close
public void close() throws DataStoreException
- Specified by:
close
in interfaceDataStore
- Throws:
DataStoreException
-
exists
public boolean exists(DataIdentifier identifier)
Look in the backend for a record matching the given identifier. Returns true if such a record exists.- Parameters:
identifier
- - An identifier for the record.- Returns:
- true if a record for the provided identifier can be found.
-
getStats
public List<DataStoreCacheStatsMBean> getStats()
-
getCache
protected CompositeDataStoreCache getCache()
-
setPath
public void setPath(String path)
------------------------- setters ----------------------------------------------
-
setCacheSize
public void setCacheSize(long cacheSize)
-
setStagingSplitPercentage
public void setStagingSplitPercentage(int stagingSplitPercentage)
-
setUploadThreads
public void setUploadThreads(int uploadThreads)
-
setStagingPurgeInterval
public void setStagingPurgeInterval(int stagingPurgeInterval)
-
setStagingRetryInterval
public void setStagingRetryInterval(int stagingRetryInterval)
-
setStatisticsProvider
public void setStatisticsProvider(StatisticsProvider statisticsProvider)
-
addMetadataRecord
public void addMetadataRecord(InputStream stream, String name) throws DataStoreException
------------------------ SharedDataStore methods ------------------------------------------ Specified by:
addMetadataRecord
in interfaceSharedDataStore
- Parameters:
stream
- the streamname
- the name of the root record- Throws:
DataStoreException
- the data store exception
-
addMetadataRecord
public void addMetadataRecord(File f, String name) throws DataStoreException
Description copied from interface:SharedDataStore
Adds the root record.- Specified by:
addMetadataRecord
in interfaceSharedDataStore
- Parameters:
f
- the filename
- the name of the root record- Throws:
DataStoreException
- the data store exception
-
getMetadataRecord
public DataRecord getMetadataRecord(String name)
Description copied from interface:SharedDataStore
Retrieves the metadata record with the given name- Specified by:
getMetadataRecord
in interfaceSharedDataStore
- Parameters:
name
- the name of the record- Returns:
-
metadataRecordExists
public boolean metadataRecordExists(String name)
Description copied from interface:SharedDataStore
Checks if the metadata record with the name exists- Specified by:
metadataRecordExists
in interfaceSharedDataStore
- Returns:
-
getAllMetadataRecords
public List<DataRecord> getAllMetadataRecords(String prefix)
Description copied from interface:SharedDataStore
Gets the all root records.- Specified by:
getAllMetadataRecords
in interfaceSharedDataStore
- Returns:
- the all root records
-
deleteMetadataRecord
public boolean deleteMetadataRecord(String name)
Description copied from interface:SharedDataStore
Deletes the root record represented by the given parameters.- Specified by:
deleteMetadataRecord
in interfaceSharedDataStore
- Parameters:
name
- the name of the root record- Returns:
- success/failure
-
deleteAllMetadataRecords
public void deleteAllMetadataRecords(String prefix)
Description copied from interface:SharedDataStore
Deletes all records matching the given prefix.- Specified by:
deleteAllMetadataRecords
in interfaceSharedDataStore
- Parameters:
prefix
- metadata type identifier
-
getAllRecords
public Iterator<DataRecord> getAllRecords() throws DataStoreException
Description copied from interface:SharedDataStore
Retrieved an iterator over all DataRecords.- Specified by:
getAllRecords
in interfaceSharedDataStore
- Returns:
- iterator over DataRecords
- Throws:
DataStoreException
-
getRecordForId
public DataRecord getRecordForId(DataIdentifier identifier) throws DataStoreException
Description copied from interface:SharedDataStore
Retrieves the record for the given identifier- Specified by:
getRecordForId
in interfaceSharedDataStore
- Parameters:
identifier
- the if of the record- Returns:
- data record
- Throws:
DataStoreException
-
getType
public SharedDataStore.Type getType()
Description copied from interface:SharedDataStore
Gets the type.- Specified by:
getType
in interfaceSharedDataStore
- Returns:
- the type
-
getOrCreateReferenceKey
protected byte[] getOrCreateReferenceKey() throws DataStoreException
- Overrides:
getOrCreateReferenceKey
in classAbstractDataStore
- Throws:
DataStoreException
-
clearInUse
public void clearInUse()
------------------------ unimplemented methods -------------------------------------------- Specified by:
clearInUse
in interfaceDataStore
-
updateModifiedDateOnAccess
public void updateModifiedDateOnAccess(long l)
- Specified by:
updateModifiedDateOnAccess
in interfaceDataStore
-
deleteAllOlderThan
public int deleteAllOlderThan(long l) throws DataStoreException
- Specified by:
deleteAllOlderThan
in interfaceDataStore
- Throws:
DataStoreException
-
-