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.Persister
    Ultra-thin delegating type that connects the application context to a storage instance via a Persistence layer (a PersistenceManager instance, potentially exclusively created).

    Note that this is a rather "internal" type that users usually do not have to use or care about. Since StorageManager implements this interface, is normally sufficient to use just that.

    • 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 passed nanoTimeBudget.
        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 passed nanoTimeBudget.
        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 StorageEntityCacheEvaluator logic. 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.

        See Also:
        issueFullCacheCheck(StorageEntityCacheEvaluator), 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 passed nanoTimeBudget.
        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)
      • 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 StorageExceptionBackupFullBackupTargetNotEmpty exception 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 files
        typeDictionaryExporter - custom type dictionary exporter
        Since:
        04.01.00
      • exportChannels

        void exportChannels​(StorageLiveFileProvider fileProvider,
                            boolean performGarbageCollection)
        Exports the data of all channels in the storage by using the passed StorageLiveFileProvider instance.
        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 - the StorageLiveFileProvider logic to be used for the export.
        performGarbageCollection - whether a issueFullGarbageCollection() shall be issued before performing the export.
      • importFiles

        void importFiles​(one.microstream.collections.types.XGettingEnum<one.microstream.afs.types.AFile> importFiles)
        Imports all files specified by the passed Enum (ordered set) of AFile in 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) of ByteBuffer in 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 PersistenceManager used by this StorageConnection.
      • store

        default long store​(Object instance)
        Specified by:
        store in interface one.microstream.persistence.types.PersistenceStoring
        Specified by:
        store in interface one.microstream.persistence.types.Persister
      • storeAll

        default long[] storeAll​(Object... instances)
        Specified by:
        storeAll in interface one.microstream.persistence.types.PersistenceStoring
        Specified by:
        storeAll in interface one.microstream.persistence.types.Persister
      • storeAll

        default void storeAll​(Iterable<?> instances)
        Specified by:
        storeAll in interface one.microstream.persistence.types.PersistenceStoring
        Specified by:
        storeAll in interface one.microstream.persistence.types.Persister
      • createLazyStorer

        default one.microstream.persistence.types.Storer createLazyStorer()
        Specified by:
        createLazyStorer in interface one.microstream.persistence.types.Persister
      • createStorer

        default one.microstream.persistence.types.Storer createStorer()
        Specified by:
        createStorer in interface one.microstream.persistence.types.Persister
      • createEagerStorer

        default one.microstream.persistence.types.Storer createEagerStorer()
        Specified by:
        createEagerStorer in interface one.microstream.persistence.types.Persister
      • getObject

        default Object getObject​(long objectId)
        Specified by:
        getObject in interface one.microstream.reference.ObjectSwizzling
        Specified by:
        getObject in interface one.microstream.persistence.types.Persister