use of liquibase.exception.LockException in project liquibase by liquibase.
the class Liquibase method changeLogSync.
public void changeLogSync(Contexts contexts, LabelExpression labelExpression) throws LiquibaseException {
changeLogParameters.setContexts(contexts);
changeLogParameters.setLabels(labelExpression);
LockService lockService = LockServiceFactory.getInstance().getLockService(database);
lockService.waitForLock();
try {
DatabaseChangeLog changeLog = getDatabaseChangeLog();
checkLiquibaseTables(true, changeLog, contexts, labelExpression);
ChangeLogHistoryServiceFactory.getInstance().getChangeLogService(database).generateDeploymentId();
changeLog.validate(database, contexts, labelExpression);
ChangeLogIterator logIterator = new ChangeLogIterator(changeLog, new NotRanChangeSetFilter(database.getRanChangeSetList()), new ContextChangeSetFilter(contexts), new LabelChangeSetFilter(labelExpression), new DbmsChangeSetFilter(database));
logIterator.run(new ChangeLogSyncVisitor(database, changeLogSyncListener), new RuntimeEnvironment(database, contexts, labelExpression));
} finally {
try {
lockService.releaseLock();
} catch (LockException e) {
log.severe("Could not release lock", e);
}
resetServices();
}
}
use of liquibase.exception.LockException in project liquibase by liquibase.
the class Liquibase method rollback.
public void rollback(Date dateToRollBackTo, String rollbackScript, Contexts contexts, LabelExpression labelExpression) throws LiquibaseException {
changeLogParameters.setContexts(contexts);
changeLogParameters.setLabels(labelExpression);
LockService lockService = LockServiceFactory.getInstance().getLockService(database);
lockService.waitForLock();
try {
DatabaseChangeLog changeLog = getDatabaseChangeLog();
checkLiquibaseTables(false, changeLog, contexts, labelExpression);
changeLog.validate(database, contexts, labelExpression);
changeLog.setIgnoreClasspathPrefix(ignoreClasspathPrefix);
List<RanChangeSet> ranChangeSetList = database.getRanChangeSetList();
ChangeLogIterator logIterator = new ChangeLogIterator(ranChangeSetList, changeLog, new ExecutedAfterChangeSetFilter(dateToRollBackTo, ranChangeSetList), new AlreadyRanChangeSetFilter(ranChangeSetList, ignoreClasspathPrefix), new ContextChangeSetFilter(contexts), new LabelChangeSetFilter(labelExpression), new DbmsChangeSetFilter(database));
if (rollbackScript == null) {
logIterator.run(new RollbackVisitor(database, changeExecListener), new RuntimeEnvironment(database, contexts, labelExpression));
} else {
executeRollbackScript(rollbackScript, contexts, labelExpression);
removeRunStatus(logIterator, contexts, labelExpression);
}
} finally {
try {
lockService.releaseLock();
} catch (LockException e) {
log.severe("Could not release lock", e);
}
}
resetServices();
}
use of liquibase.exception.LockException in project liquibase by liquibase.
the class Liquibase method rollback.
public void rollback(String tagToRollBackTo, String rollbackScript, Contexts contexts, LabelExpression labelExpression) throws LiquibaseException {
changeLogParameters.setContexts(contexts);
changeLogParameters.setLabels(labelExpression);
LockService lockService = LockServiceFactory.getInstance().getLockService(database);
lockService.waitForLock();
try {
DatabaseChangeLog changeLog = getDatabaseChangeLog();
checkLiquibaseTables(false, changeLog, contexts, labelExpression);
changeLog.validate(database, contexts, labelExpression);
changeLog.setIgnoreClasspathPrefix(ignoreClasspathPrefix);
List<RanChangeSet> ranChangeSetList = database.getRanChangeSetList();
ChangeLogIterator logIterator = new ChangeLogIterator(ranChangeSetList, changeLog, new AfterTagChangeSetFilter(tagToRollBackTo, ranChangeSetList), new AlreadyRanChangeSetFilter(ranChangeSetList, ignoreClasspathPrefix), new ContextChangeSetFilter(contexts), new LabelChangeSetFilter(labelExpression), new DbmsChangeSetFilter(database));
if (rollbackScript == null) {
logIterator.run(new RollbackVisitor(database, changeExecListener), new RuntimeEnvironment(database, contexts, labelExpression));
} else {
executeRollbackScript(rollbackScript, contexts, labelExpression);
removeRunStatus(logIterator, contexts, labelExpression);
}
} finally {
try {
lockService.releaseLock();
} catch (LockException e) {
log.severe("Could not release lock", e);
}
}
resetServices();
}
use of liquibase.exception.LockException in project liquibase by liquibase.
the class Liquibase method generateDocumentation.
public void generateDocumentation(String outputDirectory, Contexts contexts, LabelExpression labelExpression) throws LiquibaseException {
log.info("Generating Database Documentation");
changeLogParameters.setContexts(contexts);
changeLogParameters.setLabels(labelExpression);
LockService lockService = LockServiceFactory.getInstance().getLockService(database);
lockService.waitForLock();
try {
DatabaseChangeLog changeLog = getDatabaseChangeLog();
checkLiquibaseTables(false, changeLog, new Contexts(), new LabelExpression());
changeLog.validate(database, contexts, labelExpression);
ChangeLogIterator logIterator = new ChangeLogIterator(changeLog, new DbmsChangeSetFilter(database));
DBDocVisitor visitor = new DBDocVisitor(database);
logIterator.run(visitor, new RuntimeEnvironment(database, contexts, labelExpression));
visitor.writeHTML(new File(outputDirectory), resourceAccessor);
} catch (IOException e) {
throw new LiquibaseException(e);
} finally {
try {
lockService.releaseLock();
} catch (LockException e) {
log.severe("Could not release lock", e);
}
}
// try {
// if (!LockService.getExecutor(database).waitForLock()) {
// return;
// }
//
// DBDocChangeLogHandler changeLogHandler = new DBDocChangeLogHandler(outputDirectory, this, changeLogFile,resourceAccessor);
// runChangeLogs(changeLogHandler);
//
// changeLogHandler.writeHTML(this);
// } finally {
// releaseLock();
// }
}
use of liquibase.exception.LockException in project liquibase by liquibase.
the class Liquibase method update.
public void update(Contexts contexts, LabelExpression labelExpression, boolean checkLiquibaseTables) throws LiquibaseException {
LockService lockService = LockServiceFactory.getInstance().getLockService(database);
lockService.waitForLock();
changeLogParameters.setContexts(contexts);
changeLogParameters.setLabels(labelExpression);
try {
DatabaseChangeLog changeLog = getDatabaseChangeLog();
if (checkLiquibaseTables) {
checkLiquibaseTables(true, changeLog, contexts, labelExpression);
}
ChangeLogHistoryServiceFactory.getInstance().getChangeLogService(database).generateDeploymentId();
changeLog.validate(database, contexts, labelExpression);
ChangeLogIterator changeLogIterator = getStandardChangelogIterator(contexts, labelExpression, changeLog);
changeLogIterator.run(createUpdateVisitor(), new RuntimeEnvironment(database, contexts, labelExpression));
} finally {
database.setObjectQuotingStrategy(ObjectQuotingStrategy.LEGACY);
try {
lockService.releaseLock();
} catch (LockException e) {
log.severe("Could not release lock", e);
}
resetServices();
}
}
Aggregations