Interface StorageConnection
-
- All Superinterfaces:
one.microstream.reference.ObjectSwizzling,one.microstream.persistence.types.PersistenceStoring,one.microstream.persistence.types.Persister
- All Known Subinterfaces:
StorageManager
- All Known Implementing Classes:
StorageConnection.Default
public interface StorageConnection extends one.microstream.persistence.types.PersisterUltra-thin delegating type that connects the application context to a storage instance via a Persistence layer (aPersistenceManagerinstance, potentially exclusively created).Note that this is a rather "internal" type that users usually do not have to use or care about. Since
StorageManagerimplements this interface, is normally sufficient to use just that.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classStorageConnection.Default
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default one.microstream.persistence.types.StorercreateEagerStorer()default one.microstream.persistence.types.StorercreateLazyStorer()StorageRawFileStatisticscreateStorageStatistics()Creates aStorageRawFileStatisticsinstance, (obviously) containing raw file statistics about every channel in the storage.default one.microstream.persistence.types.StorercreateStorer()default voidexportChannels(StorageLiveFileProvider fileProvider)Alias forthis.exportChannels(fileHandler, true);.voidexportChannels(StorageLiveFileProvider fileProvider, boolean performGarbageCollection)Exports the data of all channels in the storage by using the passedStorageLiveFileProviderinstance.
This is basically a simple file copy applied to all files in the storage, however with the guaranteed safety of no other task / access to the storage's files intervening with the ongoing process.default StorageEntityTypeExportStatisticsexportTypes(one.microstream.afs.types.ADirectory targetDirectory)Alias forthis.exportTypes(StorageEntityTypeExportFileProvider.New(targetDirectory));, meaning all types are exported.default StorageEntityTypeExportStatisticsexportTypes(one.microstream.afs.types.ADirectory targetDirectory, Predicate<? super StorageEntityTypeHandler> isExportType)Alias forthis.exportTypes(StorageEntityTypeExportFileProvider.New(targetDirectory), isExportType);.default StorageEntityTypeExportStatisticsexportTypes(StorageEntityTypeExportFileProvider exportFileProvider)Alias forthis.exportTypes(exportFileProvider, null);, meaning all types are exported.StorageEntityTypeExportStatisticsexportTypes(StorageEntityTypeExportFileProvider exportFileProvider, Predicate<? super StorageEntityTypeHandler> isExportType)Exports the entity data of all selected types of all channels into one file per type.
The data will be in the native binary format used internally by the storage.default ObjectgetObject(long objectId)voidimportData(one.microstream.collections.types.XGettingEnum<ByteBuffer> importData)Imports all data specified by the passed Enum (ordered set) ofByteBufferin order.
The buffers are assumed to be in the native binary format used internally by the storage.
All entities contained in the specified buffers will be imported.voidimportFiles(one.microstream.collections.types.XGettingEnum<one.microstream.afs.types.AFile> importFiles)Imports all files specified by the passed Enum (ordered set) ofAFilein order.
The files are assumed to be in the native binary format used internally by the storage.
All entities contained in the specified files will be imported.default booleanissueCacheCheck(long nanoTimeBudget)Issues a storage cache check to be executed, limited to the time budget in nanoseconds specified by the passednanoTimeBudget.
When the time budget is used up, the checking logic will keep the current progress and continue there at the next opportunity.booleanissueCacheCheck(long nanoTimeBudget, StorageEntityCacheEvaluator entityEvaluator)Same asissueCacheCheck(long), but with using the passedStorageEntityCacheEvaluatorlogic instead of the configured one.booleanissueFileCheck(long nanoTimeBudget)Issues a storage file check to be executed, limited to the time budget in nanoseconds specified by the passednanoTimeBudget.
When the time budget is used up, the checking logic will keep the current progress and continue there at the next opportunity.default voidissueFullBackup(one.microstream.afs.types.ADirectory targetDirectory)Issues a full backup of the whole storage to be executed.voidissueFullBackup(StorageLiveFileProvider targetFileProvider, one.microstream.persistence.types.PersistenceTypeDictionaryExporter typeDictionaryExporter)Issues a full backup of the whole storage to be executed.default voidissueFullCacheCheck()Issues a full storage cache check to be executed.default voidissueFullCacheCheck(StorageEntityCacheEvaluator entityEvaluator)Same asissueFullCacheCheck(), but with using the passedStorageEntityCacheEvaluatorlogic instead of the configured one.default voidissueFullFileCheck()Issues a full storage file check to be executed.default voidissueFullGarbageCollection()Issues a full garbage collection to be executed.booleanissueGarbageCollection(long nanoTimeBudget)Issues garbage collection to be executed, limited to the time budget in nanoseconds specified by the passednanoTimeBudget.
When the time budget is used up, the garbage collector will keep the current progress and continue there at the next opportunity.static StorageConnectionNew(one.microstream.persistence.types.PersistenceManager<Binary> persistenceManager, StorageRequestAcceptor connectionRequestAcceptor)one.microstream.persistence.types.PersistenceManager<Binary>persistenceManager()default longstore(Object instance)default voidstoreAll(Iterable<?> instances)default long[]storeAll(Object... instances)
-
-
-
Method Detail
-
issueFullGarbageCollection
default void issueFullGarbageCollection()
Issues a full garbage collection to be executed. Depending on the size of the database, the available cache, used hardware, etc., this can take any amount of time.Garbage collection marks all persisted objects/records that are reachable from the root (mark phase) and once that is completed, all non-marked records are determined to be effectively unreachable and are thus deleted. This common mechanism in graph-organised data completely removes the need for any explicit deleting.
Note that the garbage collection on the storage level has nothing to do with the JVM's Garbage Collector on the heap level. While the technical principle is the same, both GCs are separate from each other and do not have anything to do with each other.
- See Also:
issueGarbageCollection(long)
-
issueGarbageCollection
boolean issueGarbageCollection(long nanoTimeBudget)
Issues garbage collection to be executed, limited to the time budget in nanoseconds specified by the passednanoTimeBudget.
When the time budget is used up, the garbage collector will keep the current progress and continue there at the next opportunity. The same progress marker is used by the implicit housekeeping, so both mechanisms will continue on the same progress.
If no store has occurred since the last completed garbage sweep, this method will have no effect and return immediately.- Parameters:
nanoTimeBudget- the time budget in nanoseconds to be used to perform garbage collection.- Returns:
- whether the returned call has completed garbage collection.
- See Also:
issueFullGarbageCollection()
-
issueFullFileCheck
default void issueFullFileCheck()
Issues a full storage file check to be executed. Depending on the size of the database, the available cache, used hardware, etc., this can take any amount of time.File checking evaluates every storage data file about being either too small, too big or having too many logical "gaps" in it (created by storing newer versions of an object or by garbage collection). If one of those checks applies, the remaining live data in the file is moved to the current head file and once that is done, the source file (now consisting of 100% logical "gaps", making it effectively superfluous) is then deleted.
The exact logic is defined by
StorageConfiguration.dataFileEvaluator()- See Also:
issueFileCheck(long)
-
issueFileCheck
boolean issueFileCheck(long nanoTimeBudget)
Issues a storage file check to be executed, limited to the time budget in nanoseconds specified by the passednanoTimeBudget.
When the time budget is used up, the checking logic will keep the current progress and continue there at the next opportunity. The same progress marker is used by the implicit housekeeping, so both mechanisms will continue on the same progress.
If no store has occurred since the last completed check, this method will have no effect and return immediately.- Parameters:
nanoTimeBudget- the time budget in nanoseconds to be used to perform file checking.- Returns:
- whether the returned call has completed file checking.
-
issueFullCacheCheck
default void issueFullCacheCheck()
Issues a full storage cache check to be executed. Depending on the size of the database, the available cache, used hardware, etc., this can take any amount of time.Cache checking evaluates every cache entity data about being worth to be kept in cache according to the configured
StorageEntityCacheEvaluatorlogic. If deemed unworthy, its data will be cleared from the cache and has to be loaded from the persistent form on the next reading access.
The check will run until the used cache size is 0 or every entity is checked at least once.
-
issueFullCacheCheck
default void issueFullCacheCheck(StorageEntityCacheEvaluator entityEvaluator)
Same asissueFullCacheCheck(), but with using the passedStorageEntityCacheEvaluatorlogic instead of the configured one.- Parameters:
entityEvaluator- the entity cache evaluation logic to be used for the call.- See Also:
issueFullCacheCheck(),issueCacheCheck(long),issueCacheCheck(long, StorageEntityCacheEvaluator)
-
issueCacheCheck
default boolean issueCacheCheck(long nanoTimeBudget)
Issues a storage cache check to be executed, limited to the time budget in nanoseconds specified by the passednanoTimeBudget.
When the time budget is used up, the checking logic will keep the current progress and continue there at the next opportunity. The same progress marker is used by the implicit housekeeping, so both mechanisms will continue on the same progress.
If the used cache size is 0, this method will have no effect and return immediately.- Parameters:
nanoTimeBudget- the time budget in nanoseconds to be used to perform cache checking.- Returns:
- whether the used cache size is 0 or became 0 via the performed check.
- See Also:
issueFullCacheCheck(),issueFullCacheCheck(StorageEntityCacheEvaluator),issueCacheCheck(long, StorageEntityCacheEvaluator)
-
issueCacheCheck
boolean issueCacheCheck(long nanoTimeBudget, StorageEntityCacheEvaluator entityEvaluator)Same asissueCacheCheck(long), but with using the passedStorageEntityCacheEvaluatorlogic instead of the configured one.- Parameters:
nanoTimeBudget- the time budget in nanoseconds to be used to perform cache checking.entityEvaluator- the entity cache evaluation logic to be used for the call.- Returns:
- whether the used cache size is 0 or became 0 via the performed check.
- See Also:
issueFullCacheCheck(),issueFullCacheCheck(StorageEntityCacheEvaluator),issueCacheCheck(long)
-
issueFullBackup
default void issueFullBackup(one.microstream.afs.types.ADirectory targetDirectory)
Issues a full backup of the whole storage to be executed. Keep in mind that this could result in a very long running operation, depending on the storage size.
Although the full backup may be a valid solution in some circumstances, the incremental backup should be preferred, since it is by far more efficient.if the target is existing and not empty an
StorageExceptionBackupFullBackupTargetNotEmptyexception will be thrown- Parameters:
targetDirectory- the directory to write the backup data into- Since:
- 04.01.00
-
issueFullBackup
void issueFullBackup(StorageLiveFileProvider targetFileProvider, one.microstream.persistence.types.PersistenceTypeDictionaryExporter typeDictionaryExporter)
Issues a full backup of the whole storage to be executed. Keep in mind that this could result in a very long running operation, depending on the storage size.
Although the full backup may be a valid solution in some circumstances, the incremental backup should be preferred, since it is by far more efficient.- Parameters:
targetFileProvider- file provider for backup filestypeDictionaryExporter- custom type dictionary exporter- Since:
- 04.01.00
-
createStorageStatistics
StorageRawFileStatistics createStorageStatistics()
Creates aStorageRawFileStatisticsinstance, (obviously) containing raw file statistics about every channel in the storage.- Returns:
- a
StorageRawFileStatisticsinstance based on the current state.
-
exportChannels
void exportChannels(StorageLiveFileProvider fileProvider, boolean performGarbageCollection)
Exports the data of all channels in the storage by using the passedStorageLiveFileProviderinstance.
This is basically a simple file copy applied to all files in the storage, however with the guaranteed safety of no other task / access to the storage's files intervening with the ongoing process. This is useful to safely create a complete copy of the storage, e.g. a full backup.- Parameters:
fileProvider- theStorageLiveFileProviderlogic to be used for the export.performGarbageCollection- whether aissueFullGarbageCollection()shall be issued before performing the export.
-
exportChannels
default void exportChannels(StorageLiveFileProvider fileProvider)
Alias forthis.exportChannels(fileHandler, true);.- Parameters:
fileProvider- theStorageLiveFileProviderlogic to be used for the export.- See Also:
exportChannels(StorageLiveFileProvider, boolean)
-
exportTypes
StorageEntityTypeExportStatistics exportTypes(StorageEntityTypeExportFileProvider exportFileProvider, Predicate<? super StorageEntityTypeHandler> isExportType)
Exports the entity data of all selected types of all channels into one file per type.
The data will be in the native binary format used internally by the storage. Converters can be used to transform the data into a different, for example human readable, form like CSV.This is useful to extract the data contained in the storage in a structured way, for example to migrate it into another storage system or to analyze it, like converting it into human readable form.
- Parameters:
exportFileProvider- theStorageEntityTypeExportFileProviderlogic to be used.isExportType- aPredicateselecting which type's entity data to be exported.- Returns:
- a
StorageEntityTypeExportStatisticsinformation instance about the completed export. - See Also:
exportTypes(StorageEntityTypeExportFileProvider)
-
exportTypes
default StorageEntityTypeExportStatistics exportTypes(StorageEntityTypeExportFileProvider exportFileProvider)
Alias forthis.exportTypes(exportFileProvider, null);, meaning all types are exported.- Parameters:
exportFileProvider- theStorageEntityTypeExportFileProviderlogic to be used.- Returns:
- a
StorageEntityTypeExportStatisticsinformation instance about the completed export. - See Also:
exportTypes(StorageEntityTypeExportFileProvider, Predicate)
-
exportTypes
default StorageEntityTypeExportStatistics exportTypes(one.microstream.afs.types.ADirectory targetDirectory)
Alias forthis.exportTypes(StorageEntityTypeExportFileProvider.New(targetDirectory));, meaning all types are exported.- Parameters:
targetDirectory- the target directory for the export files- Returns:
- a
StorageEntityTypeExportStatisticsinformation instance about the completed export. - Since:
- 08.00.00
- See Also:
exportTypes(StorageEntityTypeExportFileProvider, Predicate)
-
exportTypes
default StorageEntityTypeExportStatistics exportTypes(one.microstream.afs.types.ADirectory targetDirectory, Predicate<? super StorageEntityTypeHandler> isExportType)
Alias forthis.exportTypes(StorageEntityTypeExportFileProvider.New(targetDirectory), isExportType);.- Parameters:
targetDirectory- the target directory for the export filesisExportType- aPredicateselecting which type's entity data to be exported.- Returns:
- a
StorageEntityTypeExportStatisticsinformation instance about the completed export. - Since:
- 08.00.00
- See Also:
exportTypes(StorageEntityTypeExportFileProvider, Predicate)
-
importFiles
void importFiles(one.microstream.collections.types.XGettingEnum<one.microstream.afs.types.AFile> importFiles)
Imports all files specified by the passed Enum (ordered set) ofAFilein order.
The files are assumed to be in the native binary format used internally by the storage.
All entities contained in the specified files will be imported. If they already exist in the storage (identified by their ObjectId), their current data will be replaced by the imported data.
Note that importing data that is not reachable from any root entity will have no effect and will eventually be deleted by the garbage collector.- Parameters:
importFiles- the files whose native binary content shall be imported.
-
importData
void importData(one.microstream.collections.types.XGettingEnum<ByteBuffer> importData)
Imports all data specified by the passed Enum (ordered set) ofByteBufferin order.
The buffers are assumed to be in the native binary format used internally by the storage.
All entities contained in the specified buffers will be imported. If they already exist in the storage (identified by their ObjectId), their current data will be replaced by the imported data.
Note that importing data that is not reachable from any root entity will have no effect and will eventually be deleted by the garbage collector.- Parameters:
importData- the files whose native binary content shall be imported.
-
persistenceManager
one.microstream.persistence.types.PersistenceManager<Binary> persistenceManager()
- Returns:
- the
PersistenceManagerused by thisStorageConnection.
-
store
default long store(Object instance)
- Specified by:
storein interfaceone.microstream.persistence.types.PersistenceStoring- Specified by:
storein interfaceone.microstream.persistence.types.Persister
-
storeAll
default long[] storeAll(Object... instances)
- Specified by:
storeAllin interfaceone.microstream.persistence.types.PersistenceStoring- Specified by:
storeAllin interfaceone.microstream.persistence.types.Persister
-
storeAll
default void storeAll(Iterable<?> instances)
- Specified by:
storeAllin interfaceone.microstream.persistence.types.PersistenceStoring- Specified by:
storeAllin interfaceone.microstream.persistence.types.Persister
-
createLazyStorer
default one.microstream.persistence.types.Storer createLazyStorer()
- Specified by:
createLazyStorerin interfaceone.microstream.persistence.types.Persister
-
createStorer
default one.microstream.persistence.types.Storer createStorer()
- Specified by:
createStorerin interfaceone.microstream.persistence.types.Persister
-
createEagerStorer
default one.microstream.persistence.types.Storer createEagerStorer()
- Specified by:
createEagerStorerin interfaceone.microstream.persistence.types.Persister
-
getObject
default Object getObject(long objectId)
- Specified by:
getObjectin interfaceone.microstream.reference.ObjectSwizzling- Specified by:
getObjectin interfaceone.microstream.persistence.types.Persister
-
New
static StorageConnection New(one.microstream.persistence.types.PersistenceManager<Binary> persistenceManager, StorageRequestAcceptor connectionRequestAcceptor)
-
-