Class VersionAgnosticMigrationEmbeddedStorageManager<T,E>
- java.lang.Object
-
- software.xdev.micromigration.microstream.versionagnostic.VersionAgnosticMigrationEmbeddedStorageManager<T,E>
-
- Type Parameters:
T
- class of itself to be able to return the actual class and not just a generic classE
- 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 MicroStreamone.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 theVersionAgnosticMigrationManager
to do the actual migration.VersionAgnostic
because it should be independent from the actual MicroStream implementation used.- Author:
- Johannes Rabauer
-
-
Constructor Summary
Constructors Constructor Description VersionAgnosticMigrationEmbeddedStorageManager(VersionAgnosticTunnelingEmbeddedStorageManager<E> tunnelingManager, MicroMigrater migrater)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the datastore.MigrationVersion
getCurrentVersion()
java.util.List<ScriptExecutionNotificationWithoutScriptReference>
getMigrationHistory()
E
getNativeStorageManager()
protected VersionAgnosticTunnelingEmbeddedStorageManager<E>
getTunnelingManager()
java.lang.Object
root()
java.lang.Object
setRoot(java.lang.Object newRoot)
Sets the actual root element (not the versioned root)boolean
shutdown()
Shuts down the datastore.T
start()
Checks if the root object is of the instance ofVersioned
.long
store(java.lang.Object objectToStore)
Stores the objectToStorelong
storeRoot()
Stores theVersionedRoot
and the actual root object.
-
-
-
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. Onlystart()
,root()
andsetRoot(Object)
are intercepted and aVersioned
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
-
getTunnelingManager
protected VersionAgnosticTunnelingEmbeddedStorageManager<E> getTunnelingManager()
- Returns:
- the used
VersionAgnosticTunnelingEmbeddedStorageManager
-
start
public T start()
Checks if the root object is of the instance ofVersioned
. 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
-
getMigrationHistory
public java.util.List<ScriptExecutionNotificationWithoutScriptReference> getMigrationHistory()
- 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 theVersionedRoot
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 interfacejava.lang.AutoCloseable
-
-