Interface StorageManager
-
- All Superinterfaces:
AutoCloseable,DatabasePart,one.microstream.reference.ObjectSwizzling,one.microstream.persistence.types.PersistenceStoring,one.microstream.persistence.types.Persister,StorageActivePart,StorageConnection,StorageController
public interface StorageManager extends StorageController, StorageConnection, DatabasePart
Central managing type for a native Java database's storage layer.For all intents and purposes, a
StorageManagerinstance represents the storage of a database in the Java application that uses it. It is used for starting and stopping storage managements threads, call storage-level utility functionality like clearing the low-level data cache, cleaning up / condensing storage files or calling the storage-level garbage collector to remove data that has become unreachable in the entity graph. This type also allows querying the usedStorageConfigurationor theStorageTypeDictionarythat defines the persistent structure of all handled types.For the most cases, only the methods
root(),setRoot(Object),start()andshutdown()are important. Everything else is used for more or less advanced purposes and should only be used with good knowledge about the effects caused by it.A
StorageManagerinstance is also implicitly aStorageConnection, so that developers don't need to care about connections at all if a single connection suffices.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface one.microstream.storage.types.StorageConnection
StorageConnection.Default
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description StorageConfigurationconfiguration()Returns theStorageConfigurationused to initialize thisStorageManagerinstance.StorageConnectioncreateConnection()Creates a newStorageConnectioninstance.Databasedatabase()Returns theDatabaseinstance thisStorageManageris associated with.default StringdatabaseName()Alias forreturn this.database().databaseName();Objectroot()Return the persistent object graph's root object, without specific typing.ObjectsetRoot(Object newRoot)Sets the passed instance as the new root for the persistent object graph.
Note that this will replace the old root instance, potentially resulting in wiping the whole database.booleanshutdown()Issues a command to shut down all active threads managing the storage.StorageManagerstart()"Starts" the storage controlled by thisStorageControllerinstance, with "starting" meaning:
Reading, indexing and potentially caching all the persisted data in the storage. Starting storage managing threads to execute requests like storing, loading and issued utility functions.longstoreRoot()Stores the registered root instance (as returned byroot()) by using the default storing logic by callingStorageConnection.createStorer()to create theStorerto be used.
Depending on the storer logic, storing the root instance can cause many other object to be stored, as well.StorageTypeDictionarytypeDictionary()Returns theStorageTypeDictionarythat contains a complete list of types currently known to / handled by the storage represented by thisStorageManagerinstance.one.microstream.persistence.types.PersistenceRootsViewviewRoots()Returns a read-only view on all technical root instance registered in thisStorageManagerinstance.
See the description inPersistenceRootsViewfor details.-
Methods inherited from interface one.microstream.storage.types.StorageActivePart
isActive
-
Methods inherited from interface one.microstream.storage.types.StorageConnection
createEagerStorer, createLazyStorer, createStorageStatistics, createStorer, exportChannels, exportChannels, exportTypes, exportTypes, exportTypes, exportTypes, getObject, importData, importFiles, issueCacheCheck, issueCacheCheck, issueFileCheck, issueFullBackup, issueFullBackup, issueFullCacheCheck, issueFullCacheCheck, issueFullFileCheck, issueFullGarbageCollection, issueGarbageCollection, persistenceManager, store, storeAll, storeAll
-
Methods inherited from interface one.microstream.storage.types.StorageController
checkAcceptingTasks, close, initializationDuration, initializationTime, isAcceptingTasks, isRunning, isShutdown, isShuttingDown, isStartingUp, operationModeTime
-
-
-
-
Method Detail
-
configuration
StorageConfiguration configuration()
Returns theStorageConfigurationused to initialize thisStorageManagerinstance.- Returns:
- the used configuration.
-
typeDictionary
StorageTypeDictionary typeDictionary()
Returns theStorageTypeDictionarythat contains a complete list of types currently known to / handled by the storage represented by thisStorageManagerinstance. This list grows dynamically as so far unknown types are discovered, analyzed, mapped and added on the fly by a store.- Returns:
- thr current
StorageTypeDictionary.
-
start
StorageManager start()
"Starts" the storage controlled by thisStorageControllerinstance, with "starting" meaning:
- Reading, indexing and potentially caching all the persisted data in the storage.
- Starting storage managing threads to execute requests like storing, loading and issued utility functions.
- Specified by:
startin interfaceStorageController- Returns:
- this to allow writing of fluent code.
-
shutdown
boolean shutdown()
Issues a command to shut down all active threads managing the storage.- Specified by:
shutdownin interfaceStorageController- Returns:
trueafter a successful shutdown orfalseif an internalInterruptedExceptionhappened.
-
createConnection
StorageConnection createConnection()
Creates a newStorageConnectioninstance. See the type description for details.
Not that while it makes sense on an architectural level to have a connecting mechanism between application logic and storage level, there is currently no need to create additional connections beyond the intrinsic one held inside aStorageManagerinstance. Just use it instead.- Returns:
- a new
StorageConnectioninstance.
-
root
Object root()
Return the persistent object graph's root object, without specific typing.If a specifically typed root instance reference is desired, it is preferable to hold a properly typed constant reference to it and let the storage initialization use that instance as the root.
See the following code snippet on how to do that:static final MyAppRoot ROOT = new MyAppRoot(); static final StorageManager STORAGE = EmbeddedStorage.start(ROOT);- Returns:
- the persistent object graph's root object.
-
setRoot
Object setRoot(Object newRoot)
Sets the passed instance as the new root for the persistent object graph.
Note that this will replace the old root instance, potentially resulting in wiping the whole database.- Parameters:
newRoot- the new root instance to be set.- Returns:
- the passed newRoot to allow fluent usage of this method.
-
storeRoot
long storeRoot()
Stores the registered root instance (as returned byroot()) by using the default storing logic by callingStorageConnection.createStorer()to create theStorerto be used.
Depending on the storer logic, storing the root instance can cause many other object to be stored, as well. For example for the default behavior (as implemented inStorageConnection.createLazyStorer(), all recursively referenced instances that are not yet known to the persistent context (i.e. have an associated objectId registered in the context'sPersistenceObjectRegistry) are stored as well. If the default storing logic is "lazy" and the current root object has been persisted already, this call may not update the whole graph!- Returns:
- the root instance's objectId.
-
viewRoots
one.microstream.persistence.types.PersistenceRootsView viewRoots()
Returns a read-only view on all technical root instance registered in thisStorageManagerinstance.
See the description inPersistenceRootsViewfor details.- Returns:
- a new
PersistenceRootsViewinstance allowing to iterate all technical root instances.
-
database
Database database()
Returns theDatabaseinstance thisStorageManageris associated with. See its description for details.- Returns:
- the associated
Databaseinstance.
-
databaseName
default String databaseName()
Alias forreturn this.database().databaseName();- Specified by:
databaseNamein interfaceDatabasePart- Returns:
- the identifying name of the
Database.
-
-