@NotThreadSafe public abstract class MigrationExecutorBase<CONFIG extends ChangeExecutorConfiguration> extends Object implements Executor
| Modifier and Type | Field and Description |
|---|---|
protected Set<ChangeLogItem<ChangeSetItem>> |
changeLogs |
protected Deque<Triple<Object,ChangeSetItem,Exception>> |
changeSetsToRollBack |
protected ConnectionDriver |
driver |
protected List<ChangeEntryExecuted> |
executedChangeEntries |
protected String |
executionId |
protected boolean |
executionInProgress |
protected Boolean |
globalTransactionEnabled |
protected Map<String,Object> |
metadata |
protected String |
serviceIdentifier |
protected boolean |
trackIgnored |
| Constructor and Description |
|---|
MigrationExecutorBase(String executionId,
Set<ChangeLogItem<ChangeSetItem>> changeLogs,
ConnectionDriver driver,
ChangeLogRuntime changeLogRuntime,
CONFIG config) |
| Modifier and Type | Method and Description |
|---|---|
protected ChangeEntry |
buildChangeEntry(String executionId,
String executionHostname,
ChangeSetItem changeSetItem,
long executionTimeMillis,
ChangeState state,
ChangeType type) |
protected ChangeEntry |
buildChangeEntry(String executionId,
String executionHostname,
ChangeSetItem changeSetItem,
long executionTimeMillis,
ChangeState state,
ChangeType type,
Exception executionException,
Exception rollbackException) |
protected void |
clearChangeSetsToRollbackIfApply(boolean applyPreparation) |
protected void |
executeAndLogChangeSet(String executionId,
String executionHostname,
Object changelogInstance,
ChangeSetItem changeSetItem) |
protected long |
executeChangeSetMethod(Method changeSetMethod,
Object changeLogInstance) |
Boolean |
executeMigration() |
protected String |
generateExecutionHostname(String executionId) |
protected Object |
getChangeLogInstance(Class<?> changeLogClass) |
protected void |
initializationAndValidation() |
protected boolean |
isAlreadyExecuted(ChangeSetItem changeSetItem) |
protected boolean |
isDriverTransactional() |
boolean |
isExecutionInProgress() |
protected boolean |
isStrategyPerChangeUnit() |
protected boolean |
isStrategyPerMigration() |
protected boolean |
isThereAnyChangeSetItemToBeExecuted(Collection<ChangeLogItem<ChangeSetItem>> changeLogs) |
protected void |
loadExecutedChangeEntries() |
protected void |
loopRawChangeSets(String executionId,
String executionHostName,
Object changeLogInstance,
ChangeLogItem<ChangeSetItem> changeLog,
List<? extends ChangeSetItem> changeSets) |
protected void |
prepareForStageExecutionIfApply(boolean applyPreparation) |
protected void |
processChangeLogInTransactionIfApplies(String executionId,
String executionHostname,
Object changeLogInstance,
ChangeLogItem<ChangeSetItem> changeLog) |
protected void |
processChangeLogs(String executionId,
String executionHostname,
Collection<ChangeLogItem<ChangeSetItem>> changeLogs) |
protected void |
processExceptionOnChangeSetExecution(Exception exception,
ChangeSetItem changeSetItem,
boolean throwException) |
protected void |
processMigration(Collection<ChangeLogItem<ChangeSetItem>> changeLogs,
String executionId,
String executionHostname) |
protected void |
processSingleChangeLog(String executionId,
String executionHostname,
ChangeLogItem<ChangeSetItem> changeLog) |
protected void |
processSingleChangeSet(String executionId,
String executionHostname,
Object changeLogInstance,
ChangeSetItem changeSet) |
protected void |
rollbackIfPresentAndTrackChangeEntry(String executionId,
String executionHostname,
Object changeLogInstance,
ChangeSetItem changeSetItem,
Exception changeSetException) |
protected void |
rollbackProcessedChangeSetsIfApply(String executionId,
String hostname,
Deque<Triple<Object,ChangeSetItem,Exception>> processedChangeSets)
changeSetsToRollBack collection contains "all and only" the changeSets to rollback "manually" in case of any
exception occurs, sorted in reverse order.
|
protected final Boolean globalTransactionEnabled
protected final Deque<Triple<Object,ChangeSetItem,Exception>> changeSetsToRollBack
protected final ConnectionDriver driver
protected final String serviceIdentifier
protected final boolean trackIgnored
protected final Set<ChangeLogItem<ChangeSetItem>> changeLogs
protected boolean executionInProgress
protected final String executionId
protected List<ChangeEntryExecuted> executedChangeEntries
public MigrationExecutorBase(String executionId, Set<ChangeLogItem<ChangeSetItem>> changeLogs, ConnectionDriver driver, ChangeLogRuntime changeLogRuntime, CONFIG config)
public boolean isExecutionInProgress()
isExecutionInProgress in interface Executorpublic Boolean executeMigration()
executeMigration in interface Executorprotected void processMigration(Collection<ChangeLogItem<ChangeSetItem>> changeLogs, String executionId, String executionHostname)
protected void processChangeLogs(String executionId, String executionHostname, Collection<ChangeLogItem<ChangeSetItem>> changeLogs)
protected void processSingleChangeLog(String executionId, String executionHostname, ChangeLogItem<ChangeSetItem> changeLog)
protected void processChangeLogInTransactionIfApplies(String executionId, String executionHostname, Object changeLogInstance, ChangeLogItem<ChangeSetItem> changeLog)
protected void loopRawChangeSets(String executionId, String executionHostName, Object changeLogInstance, ChangeLogItem<ChangeSetItem> changeLog, List<? extends ChangeSetItem> changeSets)
protected void rollbackProcessedChangeSetsIfApply(String executionId, String hostname, Deque<Triple<Object,ChangeSetItem,Exception>> processedChangeSets)
scenarios for the changeSetsToRollBack collection - strategy == MIGRATION and transactional: It should be empty, as all the changeSets, before included, should be rollBacked in the transaction. - strategy == MIGRATION and non-transactional: It should contain all the executed changeSets in the entire migration, main and before, in execution reverse order - strategy == CHANGE_LOG and transactional: It should contain only the before methods executed for the current changeLog - strategy == CHANGE_LOG and non-transactional: It should contain all the executed changeSets in the current changeLog, main and before, in execution reverse order
protected void processSingleChangeSet(String executionId, String executionHostname, Object changeLogInstance, ChangeSetItem changeSet)
protected boolean isThereAnyChangeSetItemToBeExecuted(Collection<ChangeLogItem<ChangeSetItem>> changeLogs)
protected boolean isAlreadyExecuted(ChangeSetItem changeSetItem)
protected void executeAndLogChangeSet(String executionId, String executionHostname, Object changelogInstance, ChangeSetItem changeSetItem) throws IllegalAccessException, InvocationTargetException
protected void rollbackIfPresentAndTrackChangeEntry(String executionId, String executionHostname, Object changeLogInstance, ChangeSetItem changeSetItem, Exception changeSetException) throws InvocationTargetException, IllegalAccessException
protected ChangeEntry buildChangeEntry(String executionId, String executionHostname, ChangeSetItem changeSetItem, long executionTimeMillis, ChangeState state, ChangeType type)
protected ChangeEntry buildChangeEntry(String executionId, String executionHostname, ChangeSetItem changeSetItem, long executionTimeMillis, ChangeState state, ChangeType type, Exception executionException, Exception rollbackException)
protected long executeChangeSetMethod(Method changeSetMethod, Object changeLogInstance) throws IllegalAccessException, InvocationTargetException
protected void processExceptionOnChangeSetExecution(Exception exception, ChangeSetItem changeSetItem, boolean throwException)
protected void initializationAndValidation()
throws MongockException
MongockExceptionprotected void loadExecutedChangeEntries()
protected final boolean isDriverTransactional()
protected final boolean isStrategyPerChangeUnit()
protected final boolean isStrategyPerMigration()
protected void prepareForStageExecutionIfApply(boolean applyPreparation)
protected void clearChangeSetsToRollbackIfApply(boolean applyPreparation)
Copyright © 2022. All rights reserved.