Package org.apache.jackrabbit.core.data
Interface DataStore
- All Known Implementing Classes:
AbstractDataStore,AbstractSharedCachingDataStore,CachingDataStore,CachingFDS,CachingFileDataStore,DataStoreBlobStore,DbDataStore,DerbyDataStore,FileDataStore,MultiDataStore,OakFileDataStore
public interface DataStore
Append-only store for binary streams. A data store consists of a number
of identifiable data records that each contain a distinct binary stream.
New binary streams can be added to the data store, but existing streams
are never removed or modified.
A data store should be fully thread-safe, i.e. it should be possible to add and access data records concurrently. Optimally even separate processes should be able to concurrently access the data store with zero interprocess synchronization.
-
Method Summary
Modifier and TypeMethodDescriptionaddRecord(InputStream stream) Creates a new data record.voidClear the in-use list.voidclose()Close the data storeintdeleteAllOlderThan(long min) Delete objects that have a modified date older than the specified date.Get all identifiers.intGet the minimum size of an object that should be stored in this data store.getRecord(DataIdentifier identifier) Returns the identified data record.getRecordFromReference(String reference) Returns the record that matches the given binary reference.getRecordIfStored(DataIdentifier identifier) Check if a record for the given identifier exists, and return it if yes.voidInitialized the data storevoidupdateModifiedDateOnAccess(long before) From now on, update the modified date of an object even when accessing it.
-
Method Details
-
getRecordIfStored
Check if a record for the given identifier exists, and return it if yes. If no record exists, this method returns null.- Parameters:
identifier- data identifier- Returns:
- the record if found, and null if not
- Throws:
DataStoreException- if the data store could not be accessed
-
getRecord
Returns 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.- 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
-
getRecordFromReference
Returns the record that matches the given binary reference. Returnsnullif the reference is invalid, for example if it points to a record that does not exist.- Parameters:
reference- binary reference- Returns:
- matching record, or
null - Throws:
DataStoreException- if the data store could not be accessed
-
addRecord
Creates 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(); }- Parameters:
stream- binary stream- Returns:
- data record that contains the given stream
- Throws:
DataStoreException- if the data store could not be accessed
-
updateModifiedDateOnAccess
void updateModifiedDateOnAccess(long before) From 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.- Parameters:
before- - update the modified date to the current time if it is older than this value
-
deleteAllOlderThan
Delete objects that have a modified date older than the specified date.- Parameters:
min- the minimum time- Returns:
- the number of data records deleted
- Throws:
DataStoreException
-
getAllIdentifiers
Get all identifiers.- Returns:
- an iterator over all DataIdentifier objects
- Throws:
DataStoreException- if the list could not be read
-
init
Initialized the data store- Parameters:
homeDir- the home directory of the repository- Throws:
RepositoryException
-
getMinRecordLength
int getMinRecordLength()Get the minimum size of an object that should be stored in this data store. Depending on the overhead and configuration, each store may return a different value.- Returns:
- the minimum size in bytes
-
close
Close the data store- Throws:
DataStoreException- if a problem occurred
-
clearInUse
void clearInUse()Clear the in-use list. This is only used for testing to make the the garbage collection think that objects are no longer in use.
-