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 AbstractSharedBackendbackendThe delegate backendprotected CompositeDataStoreCachecacheDataStore cacheprotected ExecutorServiceexecutorprotected org.apache.jackrabbit.guava.common.util.concurrent.ListeningExecutorServicelisteningExecutorprotected ScheduledExecutorServiceschedulerExecutor-
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 voidaddMetadataRecord(File f, String name)Adds the root record.voidaddMetadataRecord(InputStream stream, String name)------------------------ SharedDataStore methods -----------------------------------------DataRecordaddRecord(InputStream inputStream)DataRecordaddRecord(InputStream inputStream, BlobOptions blobOptions)Add a record with specified options.voidclearInUse()------------------------ unimplemented methods -------------------------------------------voidclose()protected abstract AbstractSharedBackendcreateBackend()voiddeleteAllMetadataRecords(String prefix)Deletes all records matching the given prefix.intdeleteAllOlderThan(long l)booleandeleteMetadataRecord(String name)Deletes the root record represented by the given parameters.voiddeleteRecord(DataIdentifier dataIdentifier)booleanexists(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 CompositeDataStoreCachegetCache()DataRecordgetMetadataRecord(String name)Retrieves the metadata record with the given nameprotected byte[]getOrCreateReferenceKey()DataRecordgetRecord(DataIdentifier identifier)DataRecordgetRecordForId(DataIdentifier identifier)Retrieves the record for the given identifier@Nullable DataRecordgetRecordIfStored(DataIdentifier dataIdentifier)List<DataStoreCacheStatsMBean>getStats()SharedDataStore.TypegetType()Gets the type.voidinit(String homeDir)booleanmetadataRecordExists(String name)Checks if the metadata record with the name existsvoidsetCacheSize(long cacheSize)voidsetPath(String path)------------------------- setters ----------------------------------------------voidsetStagingPurgeInterval(int stagingPurgeInterval)voidsetStagingRetryInterval(int stagingRetryInterval)voidsetStagingSplitPercentage(int stagingSplitPercentage)voidsetStatisticsProvider(StatisticsProvider statisticsProvider)voidsetUploadThreads(int uploadThreads)voidupdateModifiedDateOnAccess(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:
initin interfaceDataStore- Throws:
DataStoreException
-
createBackend
protected abstract AbstractSharedBackend createBackend()
-
getRecord
public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException
- Specified by:
getRecordin interfaceDataStore- Overrides:
getRecordin classAbstractDataStore- Throws:
DataStoreException
-
getRecordIfStored
@Nullable public @Nullable DataRecord getRecordIfStored(DataIdentifier dataIdentifier) throws DataStoreException
- Specified by:
getRecordIfStoredin interfaceDataStore- Throws:
DataStoreException
-
addRecord
public DataRecord addRecord(InputStream inputStream) throws DataStoreException
- Specified by:
addRecordin interfaceDataStore- Throws:
DataStoreException
-
addRecord
public DataRecord addRecord(InputStream inputStream, BlobOptions blobOptions) throws DataStoreException
Description copied from interface:TypedDataStoreAdd a record with specified options.- Specified by:
addRecordin 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:
getAllIdentifiersin interfaceDataStore- Returns:
- Iterator over all ids available
- Throws:
DataStoreException
-
deleteRecord
public void deleteRecord(DataIdentifier dataIdentifier) throws DataStoreException
- Specified by:
deleteRecordin interfaceMultiDataStoreAware- Throws:
DataStoreException
-
close
public void close() throws DataStoreException- Specified by:
closein 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:
addMetadataRecordin 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:SharedDataStoreAdds the root record.- Specified by:
addMetadataRecordin 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:SharedDataStoreRetrieves the metadata record with the given name- Specified by:
getMetadataRecordin interfaceSharedDataStore- Parameters:
name- the name of the record- Returns:
-
metadataRecordExists
public boolean metadataRecordExists(String name)
Description copied from interface:SharedDataStoreChecks if the metadata record with the name exists- Specified by:
metadataRecordExistsin interfaceSharedDataStore- Returns:
-
getAllMetadataRecords
public List<DataRecord> getAllMetadataRecords(String prefix)
Description copied from interface:SharedDataStoreGets the all root records.- Specified by:
getAllMetadataRecordsin interfaceSharedDataStore- Returns:
- the all root records
-
deleteMetadataRecord
public boolean deleteMetadataRecord(String name)
Description copied from interface:SharedDataStoreDeletes the root record represented by the given parameters.- Specified by:
deleteMetadataRecordin interfaceSharedDataStore- Parameters:
name- the name of the root record- Returns:
- success/failure
-
deleteAllMetadataRecords
public void deleteAllMetadataRecords(String prefix)
Description copied from interface:SharedDataStoreDeletes all records matching the given prefix.- Specified by:
deleteAllMetadataRecordsin interfaceSharedDataStore- Parameters:
prefix- metadata type identifier
-
getAllRecords
public Iterator<DataRecord> getAllRecords() throws DataStoreException
Description copied from interface:SharedDataStoreRetrieved an iterator over all DataRecords.- Specified by:
getAllRecordsin interfaceSharedDataStore- Returns:
- iterator over DataRecords
- Throws:
DataStoreException
-
getRecordForId
public DataRecord getRecordForId(DataIdentifier identifier) throws DataStoreException
Description copied from interface:SharedDataStoreRetrieves the record for the given identifier- Specified by:
getRecordForIdin interfaceSharedDataStore- Parameters:
identifier- the if of the record- Returns:
- data record
- Throws:
DataStoreException
-
getType
public SharedDataStore.Type getType()
Description copied from interface:SharedDataStoreGets the type.- Specified by:
getTypein interfaceSharedDataStore- Returns:
- the type
-
getOrCreateReferenceKey
protected byte[] getOrCreateReferenceKey() throws DataStoreException- Overrides:
getOrCreateReferenceKeyin classAbstractDataStore- Throws:
DataStoreException
-
clearInUse
public void clearInUse()
------------------------ unimplemented methods -------------------------------------------- Specified by:
clearInUsein interfaceDataStore
-
updateModifiedDateOnAccess
public void updateModifiedDateOnAccess(long l)
- Specified by:
updateModifiedDateOnAccessin interfaceDataStore
-
deleteAllOlderThan
public int deleteAllOlderThan(long l) throws DataStoreException- Specified by:
deleteAllOlderThanin interfaceDataStore- Throws:
DataStoreException
-
-