private boolean isInitRequired(DbEnvironment env) { return !isAuditTablePresent(env) && getExistingTablesInEnvironment(env).notEmpty(); }
@Override public void printArtifactsToProcessForUser2(Changeset artifactsToProcess, DeployStrategy deployStrategy, DbEnvironment env, ImmutableCollection<Change> deployedChanges, ImmutableCollection<Change> sourceChanges) { if (deployStrategy.isInitAllowedOnHashExceptions() && !isInitRequired(env)) { LOG.info("*******************************************"); LOG.info(INIT_WARNING_MESSAGE); LOG.info("*******************************************"); LOG.info(""); } }
@Override public void validateSetup() { validateProperDbUtilsVersion(); }
@Override public void doPostDeployAction(DbEnvironment env, final ImmutableList<Change> sourceChanges) { if (env.isChecksumDetectionEnabled()) { if (!dbChecksumManager.isInitialized()) { // need this check done here to account for existing clients dbChecksumManager.initialize(); } dbChecksumManager.applyChecksumDiffs(Predicates.and(getPlatformInclusionPredicate(env), getSourceChangesInclusionPredicate(env, sourceChanges))); } }
private Predicate<? super ChecksumEntry> getPlatformInclusionPredicate(DbEnvironment env) { // 1) exclude those tables that are excluded by default from source code, e.g. explain tables or others that users configure ImmutableSet<Predicate<? super ChecksumEntry>> schemaObjectNamePredicates = env.getSchemas().collect(new Function<Schema, Predicate<? super ChecksumEntry>>() { @Override public Predicate<? super ChecksumEntry> valueOf(Schema schema) { return schema.getObjectExclusionPredicateBuilder().build(ChecksumEntry.TO_OBJECT_TYPE, ChecksumEntry.TO_NAME1); } }); // 2) exclude the audit tables MutableMultimap<String, String> tablesToExclude = Multimaps.mutable.set.empty(); tablesToExclude.putAll(ChangeType.TABLE_STR, Sets.immutable.with( env.getPlatform().convertDbObjectName().valueOf(getArtifactDeployerDao().getAuditContainerName()), env.getPlatform().convertDbObjectName().valueOf(dbChecksumManager.getChecksumContainerName()), env.getPlatform().convertDbObjectName().valueOf(getDeployExecutionDao().getExecutionContainerName()), env.getPlatform().convertDbObjectName().valueOf(getDeployExecutionDao().getExecutionAttributeContainerName()) )); ObjectTypeAndNamePredicateBuilder auditTablePredicateBuilder = new ObjectTypeAndNamePredicateBuilder(tablesToExclude.toImmutable(), ObjectTypeAndNamePredicateBuilder.FilterType.EXCLUDE); Predicates<? super ChecksumEntry> auditTablePredicate = auditTablePredicateBuilder.build(ChecksumEntry.TO_OBJECT_TYPE, ChecksumEntry.TO_NAME1); return auditTablePredicate.and(schemaObjectNamePredicates); }
@Override public void logEnvironmentMetrics(DbEnvironment env) { getDeployMetricsCollector().addMetric("dbDataSourceName", env.getDbDataSourceName()); }
@Override public void validatePriorToDeployment(DbEnvironment env, DeployStrategy deployStrategy, ImmutableList<Change> sourceChanges, ImmutableCollection<Change> deployedChanges, Changeset artifactsToProcess) { if (env.isChecksumDetectionEnabled() && dbChecksumManager.isInitialized()) { Predicate<? super ChecksumEntry> platformInclusionPredicate = getPlatformInclusionPredicate(env); ImmutableCollection<ChecksumBreak> checksumBreaks = this.dbChecksumManager.determineChecksumDifferences(platformInclusionPredicate) .reject(ChecksumBreak.IS_EXPECTED_BREAK); if (checksumBreaks.notEmpty()) { LOG.info("*******************************************"); LOG.info("WARNING: The following objects were modified or managed outside of {}.", PlatformConfiguration.getInstance().getToolName()); LOG.info("Please revert these changes or incorporate into your {} codebase", PlatformConfiguration.getInstance().getToolName()); for (ChecksumBreak checksumBreak : checksumBreaks) { LOG.info("\t" + checksumBreak.toDisplayString()); } LOG.info("*******************************************"); LOG.info(""); } } }
@Override public void doPostDeployAction(DbEnvironment env, final ImmutableList<Change> sourceChanges) { if (env.isChecksumDetectionEnabled()) { if (!dbChecksumManager.isInitialized()) { // need this check done here to account for existing clients dbChecksumManager.initialize(); } dbChecksumManager.applyChecksumDiffs(Predicates.and(getPlatformInclusionPredicate(env), getSourceChangesInclusionPredicate(env, sourceChanges))); } }
private Predicate<? super ChecksumEntry> getPlatformInclusionPredicate(DbEnvironment env) { // 1) exclude those tables that are excluded by default from source code, e.g. explain tables or others that users configure ImmutableSet<Predicate<? super ChecksumEntry>> schemaObjectNamePredicates = env.getSchemas().collect(new Function<Schema, Predicate<? super ChecksumEntry>>() { @Override public Predicate<? super ChecksumEntry> valueOf(Schema schema) { return schema.getObjectExclusionPredicateBuilder().build(ChecksumEntry.TO_OBJECT_TYPE, ChecksumEntry.TO_NAME1); } }); // 2) exclude the audit tables MutableMultimap<String, String> tablesToExclude = Multimaps.mutable.set.empty(); tablesToExclude.putAll(ChangeType.TABLE_STR, Sets.immutable.with( env.getPlatform().convertDbObjectName().valueOf(getArtifactDeployerDao().getAuditContainerName()), env.getPlatform().convertDbObjectName().valueOf(dbChecksumManager.getChecksumContainerName()), env.getPlatform().convertDbObjectName().valueOf(getDeployExecutionDao().getExecutionContainerName()), env.getPlatform().convertDbObjectName().valueOf(getDeployExecutionDao().getExecutionAttributeContainerName()) )); ObjectTypeAndNamePredicateBuilder auditTablePredicateBuilder = new ObjectTypeAndNamePredicateBuilder(tablesToExclude.toImmutable(), ObjectTypeAndNamePredicateBuilder.FilterType.EXCLUDE); Predicates<? super ChecksumEntry> auditTablePredicate = auditTablePredicateBuilder.build(ChecksumEntry.TO_OBJECT_TYPE, ChecksumEntry.TO_NAME1); return auditTablePredicate.and(schemaObjectNamePredicates); }
@Override public void logEnvironmentMetrics(DbEnvironment env) { getDeployMetricsCollector().addMetric("dbDataSourceName", env.getDbDataSourceName()); }
@Override public void validatePriorToDeployment(DbEnvironment env, DeployStrategy deployStrategy, ImmutableList<Change> sourceChanges, ImmutableCollection<Change> deployedChanges, Changeset artifactsToProcess) { if (env.isChecksumDetectionEnabled() && dbChecksumManager.isInitialized()) { Predicate<? super ChecksumEntry> platformInclusionPredicate = getPlatformInclusionPredicate(env); ImmutableCollection<ChecksumBreak> checksumBreaks = this.dbChecksumManager.determineChecksumDifferences(platformInclusionPredicate) .reject(ChecksumBreak.IS_EXPECTED_BREAK); if (checksumBreaks.notEmpty()) { LOG.info("*******************************************"); LOG.info("WARNING: The following objects were modified or managed outside of {}.", PlatformConfiguration.getInstance().getToolName()); LOG.info("Please revert these changes or incorporate into your {} codebase", PlatformConfiguration.getInstance().getToolName()); for (ChecksumBreak checksumBreak : checksumBreaks) { LOG.info("\t" + checksumBreak.toDisplayString()); } LOG.info("*******************************************"); LOG.info(""); } } }
private boolean isInitRequired(DbEnvironment env) { return !isAuditTablePresent(env) && getExistingTablesInEnvironment(env).notEmpty(); }
@Override public void printArtifactsToProcessForUser2(Changeset artifactsToProcess, DeployStrategy deployStrategy, DbEnvironment env, ImmutableCollection<Change> deployedChanges, ImmutableCollection<Change> sourceChanges) { if (deployStrategy.isInitAllowedOnHashExceptions() && !isInitRequired(env)) { LOG.info("*******************************************"); LOG.info(INIT_WARNING_MESSAGE); LOG.info("*******************************************"); LOG.info(""); } }
@Override public void validateSetup() { validateProperDbUtilsVersion(); }