public class MultiDataStore extends 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(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.
|
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(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(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 DataStore
identifier
- data identifierDataStoreException
- if the data store could not be accessedpublic DataRecord getRecord(DataIdentifier identifier) throws DataStoreException
getRecord
in interface DataStore
identifier
- data identifierDataStoreException
- if the data store could not be accessed, or if the given
identifier is invalidpublic DataRecord addRecord(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 DataStore
stream
- binary streamDataStoreException
- if the data store could not be accessedpublic void updateModifiedDateOnAccess(long before)
updateModifiedDateOnAccess
in interface DataStore
before
- - update the modified date to the current time if it is older
than this valuepublic int deleteAllOlderThan(long min) throws DataStoreException
deleteAllOlderThan
in interface DataStore
min
- the minimum timeDataStoreException
public Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException
getAllIdentifiers
in interface DataStore
DataStoreException
- if the list could not be readpublic DataRecord getRecordFromReference(String reference) throws DataStoreException
DataStore
null
if the reference is invalid, for example if it
points to a record that does not exist.getRecordFromReference
in interface DataStore
reference
- binary referencenull
DataStoreException
- if the data store could not be accessedpublic void init(String homeDir) throws RepositoryException
init
in interface DataStore
homeDir
- the home directory of the repositoryRepositoryException
public int getMinRecordLength()
getMinRecordLength
in interface DataStore
public void close() throws DataStoreException
close
in interface DataStore
DataStoreException
- if a problem occurredpublic void clearInUse()
clearInUse
in interface DataStore
public 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 © 2004–2024 The Apache Software Foundation. All rights reserved.