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:
 CachingFileDataStore
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 
 - 
 
- 
Constructor Summary
Constructors Constructor Description AbstractSharedCachingDataStore() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMetadataRecord(java.io.File f, java.lang.String name)Adds the root record.voidaddMetadataRecord(java.io.InputStream stream, java.lang.String name)------------------------ SharedDataStore methods -----------------------------------------DataRecordaddRecord(java.io.InputStream inputStream)Creates a new data record.DataRecordaddRecord(java.io.InputStream inputStream, BlobOptions blobOptions)Add a record with specified options.voidclearInUse()------------------------ unimplemented methods -------------------------------------------voidclose()Close the data storevoiddeleteAllMetadataRecords(java.lang.String prefix)Deletes all records matching the given prefix.intdeleteAllOlderThan(long l)Delete objects that have a modified date older than the specified date.booleandeleteMetadataRecord(java.lang.String name)Deletes the root record represented by the given parameters.voiddeleteRecord(DataIdentifier dataIdentifier)Deletes a single DataRecord based on the given identifier.booleanexists(DataIdentifier identifier)Look in the backend for a record matching the given identifier.java.util.Iterator<DataIdentifier>getAllIdentifiers()In rare cases may include some duplicates in cases where async staged uploads complete during iteration.java.util.List<DataRecord>getAllMetadataRecords(java.lang.String prefix)Gets the all root records.java.util.Iterator<DataRecord>getAllRecords()Retrieved an iterator over all DataRecords.DataRecordgetMetadataRecord(java.lang.String name)Retrieves the metadata record with the given nameDataRecordgetRecord(DataIdentifier identifier)Returns the identified data record.DataRecordgetRecordForId(DataIdentifier identifier)Retrieves the record for the given identifier@Nullable DataRecordgetRecordIfStored(DataIdentifier dataIdentifier)Check if a record for the given identifier exists, and return it if yes.java.util.List<DataStoreCacheStatsMBean>getStats()SharedDataStore.TypegetType()Gets the type.voidinit(java.lang.String homeDir)Initialized the data storebooleanmetadataRecordExists(java.lang.String name)Checks if the metadata record with the name existsvoidsetCacheSize(long cacheSize)voidsetPath(java.lang.String path)------------------------- setters ----------------------------------------------voidsetStagingPurgeInterval(int stagingPurgeInterval)voidsetStagingRetryInterval(int stagingRetryInterval)voidsetStagingSplitPercentage(int stagingSplitPercentage)voidsetStatisticsProvider(StatisticsProvider statisticsProvider)voidsetUploadThreads(int uploadThreads)voidupdateModifiedDateOnAccess(long l)From now on, update the modified date of an object even when accessing it.- 
Methods inherited from class org.apache.jackrabbit.core.data.AbstractDataStore
getRecordFromReference 
- 
Methods inherited from class java.lang.Object
equals, 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 
 - 
 
 - 
 
- 
- 
Method Detail
- 
init
public void init(java.lang.String homeDir) throws DataStoreExceptionDescription copied from interface:DataStoreInitialized the data store- Specified by:
 initin interfaceDataStore- Parameters:
 homeDir- the home directory of the repository- Throws:
 DataStoreException
 
- 
getRecord
public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException
Description copied from interface:DataStoreReturns the identified data record. The given identifier should be the identifier of a previously saved data record. Since records are never removed, there should never be cases where the identified record is not found. Abnormal cases like that are treated as errors and handled by throwing an exception.- Specified by:
 getRecordin interfaceDataStore- Overrides:
 getRecordin classAbstractDataStore- Parameters:
 identifier- data identifier- Returns:
 - identified data record
 - Throws:
 DataStoreException- if the data store could not be accessed, or if the given identifier is invalid
 
- 
getRecordIfStored
@Nullable public @Nullable DataRecord getRecordIfStored(DataIdentifier dataIdentifier) throws DataStoreException
Description copied from interface:DataStoreCheck if a record for the given identifier exists, and return it if yes. If no record exists, this method returns null.- Specified by:
 getRecordIfStoredin interfaceDataStore- Parameters:
 dataIdentifier- data identifier- Returns:
 - the record if found, and null if not
 - Throws:
 DataStoreException- if the data store could not be accessed
 
- 
addRecord
public DataRecord addRecord(java.io.InputStream inputStream) throws DataStoreException
Description copied from interface:DataStoreCreates a new data record. The given binary stream is consumed and a binary record containing the consumed stream is created and returned. If the same stream already exists in another record, then that record is returned instead of creating a new one.The given stream is consumed and not closed by this method. It is the responsibility of the caller to close the stream. A typical call pattern would be:
InputStream stream = ...; try { record = store.addRecord(stream); } finally { stream.close(); }- Specified by:
 addRecordin interfaceDataStore- Parameters:
 inputStream- binary stream- Returns:
 - data record that contains the given stream
 - Throws:
 DataStoreException- if the data store could not be accessed
 
- 
addRecord
public DataRecord addRecord(java.io.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 java.util.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
Description copied from interface:MultiDataStoreAwareDeletes a single DataRecord based on the given identifier. Delete will only be used by theMultiDataStore.MoveDataTask.- Specified by:
 deleteRecordin interfaceMultiDataStoreAware- Parameters:
 dataIdentifier- data identifier- Throws:
 DataStoreException- if the data store could not be accessed, or if the given identifier is invalid
 
- 
close
public void close() throws DataStoreExceptionDescription copied from interface:DataStoreClose the data store- Specified by:
 closein interfaceDataStore- Throws:
 DataStoreException- if a problem occurred
 
- 
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 java.util.List<DataStoreCacheStatsMBean> getStats()
 
- 
setPath
public void setPath(java.lang.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(java.io.InputStream stream, java.lang.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(java.io.File f, java.lang.String name) throws DataStoreExceptionDescription 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(java.lang.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(java.lang.String name)
Description copied from interface:SharedDataStoreChecks if the metadata record with the name exists- Specified by:
 metadataRecordExistsin interfaceSharedDataStore- Returns:
 
 
- 
getAllMetadataRecords
public java.util.List<DataRecord> getAllMetadataRecords(java.lang.String prefix)
Description copied from interface:SharedDataStoreGets the all root records.- Specified by:
 getAllMetadataRecordsin interfaceSharedDataStore- Returns:
 - the all root records
 
 
- 
deleteMetadataRecord
public boolean deleteMetadataRecord(java.lang.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(java.lang.String prefix)
Description copied from interface:SharedDataStoreDeletes all records matching the given prefix.- Specified by:
 deleteAllMetadataRecordsin interfaceSharedDataStore- Parameters:
 prefix- metadata type identifier
 
- 
getAllRecords
public java.util.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
 
 
- 
clearInUse
public void clearInUse()
------------------------ unimplemented methods -------------------------------------------- Specified by:
 clearInUsein interfaceDataStore
 
- 
updateModifiedDateOnAccess
public void updateModifiedDateOnAccess(long l)
Description copied from interface:DataStoreFrom now on, update the modified date of an object even when accessing it. Usually, the modified date is only updated when creating a new object, or when a new link is added to an existing object. When this setting is enabled, even getLength() will update the modified date.- Specified by:
 updateModifiedDateOnAccessin interfaceDataStore- Parameters:
 l- - update the modified date to the current time if it is older than this value
 
- 
deleteAllOlderThan
public int deleteAllOlderThan(long l) throws DataStoreExceptionDescription copied from interface:DataStoreDelete objects that have a modified date older than the specified date.- Specified by:
 deleteAllOlderThanin interfaceDataStore- Parameters:
 l- the minimum time- Returns:
 - the number of data records deleted
 - Throws:
 DataStoreException
 
 - 
 
 -