public class MultiDataStore extends java.lang.Object implements DataStore
Attention: You will lost the global single instance mechanism !
It can be used if you have two storage systems. One for fast access and a other one like a archive DataStore on a slower storage system. All Files will be added to the primary DataStore. On read operations first the primary dataStore will be used and if no Record is found the archive DataStore will be used. The GarabageCollector will only remove files from the archive DataStore.The internal MoveDataTask will be started automatically and could be configured with the following properties.
The Configuration:
<DataStore class="org.apache.jackrabbit.core.data.MultiDataStore">
<param name="maxAge" value="60"/>
<param name="moveDataTaskSleep" value="604800"/>
<param name="moveDataTaskFirstRunHourOfDay" value="1"/>
<param name="sleepBetweenRecords" value="100"/>
<param name="delayedDelete" value="false"/>
<param name="delayedDeleteSleep" value="86400"/>
<param name="primary" value="org.apache.jackrabbit.core.data.db.DbDataStore">
<param .../>
</param>
<param name="archive" value="org.apache.jackrabbit.core.data.FileDataStore">
<param .../>
</param>
</DataStore>
maxAge: defines how many days the content will reside in the
primary data store. DataRecords that have been added before this time span
will be moved to the archive data store. (default = 60)moveDataTaskSleep: specifies the sleep time of the
moveDataTaskThread in seconds. (default = 60 * 60 * 24 * 7, which equals 7
days)moveDataTaskNextRunHourOfDay: specifies the hour at which
the moveDataTaskThread initiates its first run (default = 1
which means 01:00 at night)sleepBetweenRecords: specifies the delay in milliseconds
between scanning data records (default = 100)delayedDelete: its possible to delay the delete operation on
the primary data store. The DataIdentifiers will be written to a temporary
file. The file will be processed after a defined sleep (see
delayedDeleteSleep) It's useful if you like to create a snapshot
of the primary data store backend in the meantime before the data will be
deleted. (default = false)delayedDeleteSleep: specifies the sleep time of the
delayedDeleteTaskThread in seconds. (default = 60 * 60 * 24, which equals 1
day). This means the delayed delete from the primary data store will be
processed after one day.| Modifier and Type | Class and Description |
|---|---|
class |
MultiDataStore.DeleteDelayedIdentifiersTask
Class to clean up the delayed DataRecords from the primary data store.
|
class |
MultiDataStore.MoveDataTask
Class for maintaining the MultiDataStore.
|
| Constructor and Description |
|---|
MultiDataStore() |
| Modifier and Type | Method and Description |
|---|---|
DataRecord |
addRecord(java.io.InputStream stream)
Creates a new data record in the primary data store.
|
void |
clearInUse()
Clear the in-use list.
|
void |
close()
Close the data store
|
int |
deleteAllOlderThan(long min)
Delete objects that have a modified date older than the specified date
from the archive data store.
|
java.util.Iterator<DataIdentifier> |
getAllIdentifiers()
Get all identifiers from the archive data store.
|
long |
getDelayedDeleteSleep() |
int |
getMaxAge() |
int |
getMinRecordLength()
Get the minimum size of an object that should be stored in the primary
data store.
|
int |
getMoveDataTaskFirstRunHourOfDay() |
int |
getMoveDataTaskSleep() |
DataRecord |
getRecord(DataIdentifier identifier)
Returns the identified data record from the primary data store.
|
DataRecord |
getRecordFromReference(java.lang.String reference)
Returns the record that matches the given binary reference.
|
DataRecord |
getRecordIfStored(DataIdentifier identifier)
Check if a record for the given identifier exists in the primary data
store.
|
long |
getSleepBetweenRecords() |
void |
init(java.lang.String homeDir)
Initialized the data store
|
boolean |
isDelayedDelete() |
void |
setArchiveDataStore(DataStore dataStore)
Setter for the archive dataStore
|
void |
setDelayedDelete(boolean delayedDelete) |
void |
setDelayedDeleteSleep(long delayedDeleteSleep) |
void |
setMaxAge(int maxAge) |
void |
setMoveDataTaskFirstRunHourOfDay(int hourOfDay) |
void |
setMoveDataTaskSleep(int sleep) |
void |
setPrimaryDataStore(DataStore dataStore)
Setter for the primary dataStore
|
void |
setSleepBetweenRecords(long millis) |
void |
updateModifiedDateOnAccess(long before)
From now on, update the modified date of an object even when accessing it
in the archive data store.
|
public void setPrimaryDataStore(DataStore dataStore)
dataStore - public void setArchiveDataStore(DataStore dataStore)
dataStore - public DataRecord getRecordIfStored(DataIdentifier identifier) throws DataStoreException
getRecordIfStored in interface DataStoreidentifier - data identifierDataStoreException - if the data store could not be accessedpublic DataRecord getRecord(DataIdentifier identifier) throws DataStoreException
getRecord in interface DataStoreidentifier - data identifierDataStoreException - if the data store could not be accessed, or if the given
identifier is invalidpublic DataRecord addRecord(java.io.InputStream stream) throws DataStoreException
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();
}
addRecord in interface DataStorestream - binary streamDataStoreException - if the data store could not be accessedpublic void updateModifiedDateOnAccess(long before)
updateModifiedDateOnAccess in interface DataStorebefore - - update the modified date to the current time if it is older
than this valuepublic int deleteAllOlderThan(long min)
throws DataStoreException
deleteAllOlderThan in interface DataStoremin - the minimum timeDataStoreExceptionpublic java.util.Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException
getAllIdentifiers in interface DataStoreDataStoreException - if the list could not be readpublic DataRecord getRecordFromReference(java.lang.String reference) throws DataStoreException
DataStorenull if the reference is invalid, for example if it
points to a record that does not exist.getRecordFromReference in interface DataStorereference - binary referencenullDataStoreException - if the data store could not be accessedpublic void init(java.lang.String homeDir)
throws RepositoryException
init in interface DataStorehomeDir - the home directory of the repositoryRepositoryExceptionpublic int getMinRecordLength()
getMinRecordLength in interface DataStorepublic void close()
throws DataStoreException
close in interface DataStoreDataStoreException - if a problem occurredpublic void clearInUse()
clearInUse in interface DataStorepublic int getMaxAge()
public void setMaxAge(int maxAge)
public int getMoveDataTaskSleep()
public int getMoveDataTaskFirstRunHourOfDay()
public void setMoveDataTaskSleep(int sleep)
public void setMoveDataTaskFirstRunHourOfDay(int hourOfDay)
public void setSleepBetweenRecords(long millis)
public long getSleepBetweenRecords()
public boolean isDelayedDelete()
public void setDelayedDelete(boolean delayedDelete)
public long getDelayedDeleteSleep()
public void setDelayedDeleteSleep(long delayedDeleteSleep)
Copyright © 2010 - 2023 Adobe. All Rights Reserved