public abstract class BaseTxDrivenModuleManager<T extends TxDrivenModule> extends BaseModuleManager<TxDrivenModuleMetadata,T> implements TxDrivenModuleManager<T>
metadataRepository, modules| Modifier | Constructor and Description |
|---|---|
protected |
BaseTxDrivenModuleManager(ModuleMetadataRepository metadataRepository,
StatsCollector statsCollector,
InstanceRoleUtils instanceRoleUtils)
Construct a new manager.
|
| Modifier and Type | Method and Description |
|---|---|
protected TxDrivenModuleMetadata |
acknowledgeMetadata(T module,
TxDrivenModuleMetadata metadata)
Acknowledge module metadata after it has been created afresh or successfully loaded from a
ModuleMetadataRepository. |
void |
afterCommit(Map<String,Object> states)
Delegate work to modules after a transaction is committed.
|
void |
afterRollback(Map<String,Object> states)
Delegate work to modules after a transaction is rolled back.
|
Map<String,Object> |
beforeCommit(TransactionDataContainer transactionData)
Delegate work to modules before a transaction is committed.
|
protected TxDrivenModuleMetadata |
createFreshMetadata(T module)
Create new metadata for a module.
|
protected void |
handleCorruptMetadata(T module)
Handle the fact that metadata for a module has been corrupted.
|
protected void |
handleNoMetadata(T module)
Handle the fact that there was no metadata for a module.
|
protected abstract void |
initialize(T module)
Initialize module.
|
protected abstract void |
reinitialize(T module,
TxDrivenModuleMetadata oldMetadata)
Re-initialize module.
|
protected abstract void |
start(T module)
Start module.
|
void |
startModules()
Perform work needed to make modules start doing their job.
|
checkNotAlreadyRegistered, cleanupMetadata, getModule, getModule, loadMetadata, registerModule, shutdownModulesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcheckNotAlreadyRegistered, cleanupMetadata, getModule, getModule, loadMetadata, registerModule, shutdownModulesprotected BaseTxDrivenModuleManager(ModuleMetadataRepository metadataRepository, StatsCollector statsCollector, InstanceRoleUtils instanceRoleUtils)
metadataRepository - repository for storing module metadata.statsCollector - stats collector.instanceRoleUtils - instance role utils.protected void handleCorruptMetadata(T module)
BaseModuleManager.createFreshMetadata(com.graphaware.runtime.module.RuntimeModule)
will be called. This means that if the module doesn't heavily rely on its metadata, there is no need to override
this method.handleCorruptMetadata in class BaseModuleManager<TxDrivenModuleMetadata,T extends TxDrivenModule>module - that had corrupted metadata.protected void handleNoMetadata(T module)
ModuleMetadataRepository
stores them.
After this method has returned, it is guaranteed that BaseModuleManager.createFreshMetadata(com.graphaware.runtime.module.RuntimeModule)
will be called. This means that there is no need to override this method unless there is some work that needs to
be done in addition to creating new metadata.handleNoMetadata in class BaseModuleManager<TxDrivenModuleMetadata,T extends TxDrivenModule>module - that had no metadata.protected TxDrivenModuleMetadata createFreshMetadata(T module)
createFreshMetadata in class BaseModuleManager<TxDrivenModuleMetadata,T extends TxDrivenModule>module - for which to create metadata.protected TxDrivenModuleMetadata acknowledgeMetadata(T module, TxDrivenModuleMetadata metadata)
ModuleMetadataRepository.
The implementation can, for example, choose to let the module know about its own metadata. This method also gives
the subclasses the opportunity to modify the metadata before it is persisted to the database.acknowledgeMetadata in class BaseModuleManager<TxDrivenModuleMetadata,T extends TxDrivenModule>module - for which to acknowledge metadata.metadata - to acknowledge.public void startModules()
startModules in interface ModuleManager<T extends TxDrivenModule>startModules in class BaseModuleManager<TxDrivenModuleMetadata,T extends TxDrivenModule>protected abstract void start(T module)
module - to be started.protected abstract void initialize(T module)
For example, a module that performs some in-graph caching needs to write information into the graph so that when the method returns, the graph is in the same state as it would be if the module has been running all the time since the graph was empty.
Note that for many modules, it might not be necessary to do anything.
module - to initialize.protected abstract void reinitialize(T module, TxDrivenModuleMetadata oldMetadata)
For example, a module that performs some in-graph caching needs to write information into the graph so that when the method returns, the graph is in the same state as it would be if the module has been running all the time since the graph was empty.
Note that for many modules, it might not be necessary to do anything.
module - to initialize.oldMetadata - metadata stored for this module from its previous run. Can be null in case metadata
was corrupt or there was no metadata.public Map<String,Object> beforeCommit(TransactionDataContainer transactionData)
beforeCommit in interface TxDrivenModuleManager<T extends TxDrivenModule>transactionData - about-to-be-committed transaction data.RuntimeModule.getId().public void afterCommit(Map<String,Object> states)
afterCommit in interface TxDrivenModuleManager<T extends TxDrivenModule>states - returned by TxDrivenModuleManager.beforeCommit(com.graphaware.tx.event.improved.data.TransactionDataContainer).public void afterRollback(Map<String,Object> states)
afterRollback in interface TxDrivenModuleManager<T extends TxDrivenModule>states - returned by TxDrivenModuleManager.beforeCommit(com.graphaware.tx.event.improved.data.TransactionDataContainer).Copyright © 2013-2016–2018 Graph Aware Limited. All rights reserved.