Class VersionAgnosticMigrationEmbeddedStorageManager<T,​E>

  • Type Parameters:
    T - class of itself to be able to return the actual class and not just a generic class
    E - The actually used MicroStream EmbeddedStorageManager
    All Implemented Interfaces:
    java.lang.AutoCloseable

    public abstract class VersionAgnosticMigrationEmbeddedStorageManager<T,​E>
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Wrapper class for the MicroStream one.microstream.storage.embedded.types.EmbeddedStorageManager interface.

    Basically it intercepts storing the root object and places a Versioned in front of it. This means the root object of the datastore is then versioned.
    Internally uses the VersionAgnosticMigrationManager to do the actual migration.

    VersionAgnostic because it should be independent from the actual MicroStream implementation used.

    Author:
    Johannes Rabauer
    • Constructor Detail

      • VersionAgnosticMigrationEmbeddedStorageManager

        public VersionAgnosticMigrationEmbeddedStorageManager​(VersionAgnosticTunnelingEmbeddedStorageManager<E> tunnelingManager,
                                                              MicroMigrater migrater)
        Parameters:
        tunnelingManager - which will be used as the underlying storage manager. Almost all methods are only rerouted to this native manager. Only start(), root() and setRoot(Object) are intercepted and a Versioned is placed between the requests.
        migrater - which is used as source for the migration scripts
    • Method Detail

      • getNativeStorageManager

        public E getNativeStorageManager()
        Returns:
        the native MicroStream EmbeddedStorageManager
      • start

        public T start()
        Checks if the root object is of the instance of Versioned. If it is not, the root will be replaced with the versioned root and the actual root object will be put inside the versioned root.

        After starting the storage manager, all the available update scripts are executed in order until the newest version of the datastore is reached.

        Returns:
        itself
      • getCurrentVersion

        public MigrationVersion getCurrentVersion()
        Returns:
        current version that's managed
      • root

        public java.lang.Object root()
        Returns:
        the actual root object
      • setRoot

        public java.lang.Object setRoot​(java.lang.Object newRoot)
        Sets the actual root element (not the versioned root)
        Parameters:
        newRoot - to set
        Returns:
        the set object
      • storeRoot

        public long storeRoot()
        Stores the VersionedRoot and the actual root object.
        Returns:
        what EmbeddedStorageManager#storeRoot returns
      • store

        public long store​(java.lang.Object objectToStore)
        Stores the objectToStore
        Parameters:
        objectToStore - which is stored
        Returns:
        what EmbeddedStorageManager#store returns
      • shutdown

        public boolean shutdown()
        Shuts down the datastore.
        Returns:
        what EmbeddedStorageManager#storeRoot shutdown
      • close

        public void close()
        Closes the datastore.
        Specified by:
        close in interface java.lang.AutoCloseable