public abstract class CachingDataStore extends AbstractDataStore implements MultiDataStoreAware, AsyncUploadCallback, AsyncTouchCallback
LocalCache and Backend.
Backend is single source of truth. All methods first try to fetch
information from LocalCache. If record is not available in
LocalCache, then it is fetched from Backend and saved to
LocalCache for further access. This class is designed to work without
LocalCache and then all information is fetched from Backend.
To disable LocalCache set setCacheSize(long) to 0. *
Configuration:
<DataStore class="org.apache.jackrabbit.aws.ext.ds.CachingDataStore">
<param name="path" value="/data/datastore"/>
<param name="config" value="${rep.home}/backend.properties"/>
<param name="cacheSize" value="68719476736"/>
<param name="secret" value="123456"/>
<param name="setCachePurgeTrigFactor(double)" value="0.95d"/>
<param name="cacheSize" value="0.85d"/>
<param name="minRecordLength" value="1024"/>
<param name="continueOnAsyncUploadFailure" value="false"/>
<param name="concurrentUploadsThreads" value="10"/>
<param name="asyncUploadLimit" value="100"/>
<param name="uploadRetries" value="3"/>
<param name="touchAsync" value="false"/>
<param name="proactiveCaching" value="true"/>
<param name="recLengthCacheSize" value="200"/>
</DataStore>
| Constructor and Description |
|---|
CachingDataStore() |
| Modifier and Type | Method and Description |
|---|---|
DataRecord |
addRecord(java.io.InputStream input)
Creates a new data record in
Backend. |
void |
clearInUse()
Clear the in-use list.
|
void |
close()
Close the data store
|
boolean |
confirmDelete(DataIdentifier identifier)
Method to confirm that identifier can be deleted from
Backend |
int |
deleteAllOlderThan(long min)
Delete objects that have a modified date older than the specified date.
|
void |
deleteFromCache(DataIdentifier identifier) |
void |
deleteRecord(DataIdentifier identifier)
This method deletes record from
Backend and then from
LocalCache |
java.util.Iterator<DataIdentifier> |
getAllIdentifiers()
Retrieves all identifiers from
Backend. |
int |
getAsyncUploadLimit() |
Backend |
getBackend() |
double |
getCachePurgeResizeFactor() |
double |
getCachePurgeTrigFactor() |
long |
getCacheSize() |
int |
getConcurrentUploadsThreads() |
java.lang.String |
getConfig()
Return path of configuration properties.
|
long |
getLastModified(DataIdentifier identifier)
|
long |
getLength(DataIdentifier identifier)
Return the length of record from
LocalCache if available,
otherwise retrieve it from Backend. |
int |
getMinRecordLength()
Return mininum object length.
|
java.lang.String |
getPath() |
java.util.Set<java.lang.String> |
getPendingUploads() |
DataRecord |
getRecord(DataIdentifier identifier)
Returns the identified data record.
|
DataRecord |
getRecordIfStored(DataIdentifier identifier)
Get a data record for the given identifier or null it data record doesn't
exist in
Backend |
int |
getUploadRetries() |
void |
init(java.lang.String homeDir)
Initialized the data store.
|
boolean |
isContinueOnAsyncUploadFailure() |
boolean |
isInUse(DataIdentifier identifier) |
void |
onAbort(AsyncTouchResult result)
Callback method for aborted asynchronous touch.
|
void |
onAbort(AsyncUploadResult result)
Callback method for aborted asynchronous upload.
|
void |
onFailure(AsyncTouchResult result)
Callback method for failed asynchronous touch.
|
void |
onFailure(AsyncUploadResult result)
Callback method for failed asynchronous upload.
|
void |
onSuccess(AsyncTouchResult result)
Callback method for successful asynchronous touch.
|
void |
onSuccess(AsyncUploadResult result)
Callback method for successful asynchronous upload.
|
void |
setAsyncUploadLimit(int asyncUploadLimit) |
void |
setCachePurgeResizeFactor(double cachePurgeResizeFactor)
Set purge resize factor of
LocalCache. |
void |
setCachePurgeTrigFactor(double cachePurgeTrigFactor)
Set purge trigger factor of
LocalCache. |
void |
setCacheSize(long cacheSize)
Set size of
LocalCache. |
void |
setConcurrentUploadsThreads(int concurrentUploadsThreads) |
void |
setConfig(java.lang.String config)
Set the configuration properties path.
|
void |
setContinueOnAsyncUploadFailure(boolean continueOnAsyncUploadFailure) |
void |
setMinRecordLength(int minRecordLength)
Set the minimum object length.
|
void |
setPath(java.lang.String path)
Set path of
LocalCache. |
void |
setProactiveCaching(boolean proactiveCaching) |
void |
setRecLengthCacheSize(int recLengthCacheSize) |
void |
setSecret(java.lang.String secret)
Setter for configuration based secret
|
void |
setTouchAsync(boolean touchAsync) |
void |
setUploadRetries(int uploadRetries) |
void |
updateModifiedDateOnAccess(long before)
From now on, update the modified date of an object even when accessing it.
|
getRecordFromReferencepublic void init(java.lang.String homeDir)
throws RepositoryException
init in interface DataStorehomeDir - the home directory of the repositoryRepositoryExceptionpublic DataRecord addRecord(java.io.InputStream input) throws DataStoreException
Backend. The stream is first
consumed and the contents are saved in a temporary file and the AbstractDataStore.DIGEST
message digest of the stream is calculated. If a record with the same
AbstractDataStore.DIGEST digest (and length) is found then it is returned. Otherwise new
record is created in Backend and the temporary file is moved in
place to LocalCache.addRecord in interface DataStoreinput - binary streamCachingDataRecordDataStoreException - if the record could not be created.public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException
DataStoregetRecord in interface DataStoregetRecord in class AbstractDataStoreidentifier - data identifierDataStoreException - if the data store could not be accessed,
or if the given identifier is invalidpublic DataRecord getRecordIfStored(DataIdentifier identifier) throws DataStoreException
BackendgetRecordIfStored in interface DataStoreidentifier - identifier of record.CachingDataRecord or null.DataStoreException - if the data store could not be accessedpublic void updateModifiedDateOnAccess(long before)
DataStoreupdateModifiedDateOnAccess in interface DataStorebefore - - update the modified date to the current time if it is older than this valuepublic java.util.Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException
Backend.getAllIdentifiers in interface DataStoreDataStoreException - if the list could not be readpublic void deleteRecord(DataIdentifier identifier) throws DataStoreException
Backend and then from
LocalCachedeleteRecord in interface MultiDataStoreAwareidentifier - data identifierDataStoreException - if the data store could not be accessed, or if the given
identifier is invalidpublic int deleteAllOlderThan(long min)
throws DataStoreException
DataStoredeleteAllOlderThan in interface DataStoremin - the minimum timeDataStoreExceptionpublic long getLastModified(DataIdentifier identifier) throws DataStoreException
DataStoreExceptionpublic long getLength(DataIdentifier identifier) throws DataStoreException
LocalCache if available,
otherwise retrieve it from Backend.DataStoreExceptionpublic java.util.Set<java.lang.String> getPendingUploads()
public void deleteFromCache(DataIdentifier identifier) throws DataStoreException
DataStoreExceptionpublic void onSuccess(AsyncUploadResult result)
AsyncUploadCallbackonSuccess in interface AsyncUploadCallbackpublic void onFailure(AsyncUploadResult result)
AsyncUploadCallbackonFailure in interface AsyncUploadCallbackpublic void onAbort(AsyncUploadResult result)
AsyncUploadCallbackonAbort in interface AsyncUploadCallbackpublic void onSuccess(AsyncTouchResult result)
AsyncTouchCallbackonSuccess in interface AsyncTouchCallbackpublic void onFailure(AsyncTouchResult result)
AsyncTouchCallbackonFailure in interface AsyncTouchCallbackpublic void onAbort(AsyncTouchResult result)
AsyncTouchCallbackonAbort in interface AsyncTouchCallbackpublic boolean confirmDelete(DataIdentifier identifier)
Backendidentifier - public void clearInUse()
DataStoreclearInUse in interface DataStorepublic boolean isInUse(DataIdentifier identifier)
public void close()
throws DataStoreException
DataStoreclose in interface DataStoreDataStoreException - if a problem occurredpublic void setSecret(java.lang.String secret)
secret - the secret used to sign reference binariespublic void setMinRecordLength(int minRecordLength)
minRecordLength - the lengthpublic int getMinRecordLength()
getMinRecordLength in interface DataStorepublic java.lang.String getConfig()
public void setConfig(java.lang.String config)
config - path of configuration properties.public long getCacheSize()
LocalCache.public void setCacheSize(long cacheSize)
LocalCache.cacheSize - size of LocalCache.public java.lang.String getPath()
LocalCache.public void setPath(java.lang.String path)
LocalCache.path - of LocalCache.public double getCachePurgeTrigFactor()
LocalCache.public void setCachePurgeTrigFactor(double cachePurgeTrigFactor)
LocalCache.cachePurgeTrigFactor - purge trigger factor.public double getCachePurgeResizeFactor()
LocalCache.public void setCachePurgeResizeFactor(double cachePurgeResizeFactor)
LocalCache.cachePurgeResizeFactor - purge resize factor.public int getConcurrentUploadsThreads()
public void setConcurrentUploadsThreads(int concurrentUploadsThreads)
public int getAsyncUploadLimit()
public void setAsyncUploadLimit(int asyncUploadLimit)
public boolean isContinueOnAsyncUploadFailure()
public void setContinueOnAsyncUploadFailure(boolean continueOnAsyncUploadFailure)
public int getUploadRetries()
public void setUploadRetries(int uploadRetries)
public void setTouchAsync(boolean touchAsync)
public void setProactiveCaching(boolean proactiveCaching)
public void setRecLengthCacheSize(int recLengthCacheSize)
public Backend getBackend()
Copyright © 2010 - 2023 Adobe. All Rights Reserved