private Document getDocumentFromDeployExecution(DeployExecution deployExecution, boolean forUpdate) { ImmutableSet<Document> attrs = deployExecution.getAttributes().collect(new Function<DeployExecutionAttribute, Document>() { @Override public Document valueOf(DeployExecutionAttribute object) { return new Document() .append(attrNameColName, object.getName()) .append(attrValueColName, object.getValue()); } }); return new Document() .append(idColName, deployExecution.getId()) .append(requesterIdColName, deployExecution.getRequesterId()) .append(deployExecutionIdColName, deployExecution.getExecutorId()) .append(dbSchemaColName, deployExecution.getSchema()) .append(toolVersionColName, deployExecution.getToolVersion()) .append(deployTimeColName, new Date(deployExecution.getDeployTime().getTime())) .append(initCommandColName, deployExecution.isInit()) .append(rollbackCommandColName, deployExecution.isRollback()) .append(productVersionColName, deployExecution.getProductVersion()) .append(reasonColName, deployExecution.getReason()) .append("attrs", new ArrayList<>(attrs.toList())); }
private void logDeployExecutions(ImmutableCollection<DeployExecution> deployExecutions, String message) { if (LOG.isInfoEnabled()) { LOG.info("Found {} {} for this schema", deployExecutions.size(), message); if (LOG.isDebugEnabled()) { for (DeployExecution deployExecution : deployExecutions.toSortedListBy(new Function<DeployExecution, Long>() { @Override public Long valueOf(DeployExecution deployExecution1) { return deployExecution1.getId(); } })) { LOG.debug("Execution ID={}, Version Name={}, Deploy Time={}, Rollback={}", deployExecution.getId(), getDeployVersion(deployExecution), deployExecution.getDeployTime(), deployExecution.isRollback()); } } } }
@Override public Long valueOf(DeployExecution deployExecution) { return deployExecution.getId(); } });
private void verifyExecution3(DeployExecution execution3) { assertEquals("try3", execution3.getReason()); assertEquals( Sets.immutable.with( new DeployExecutionAttributeImpl("F", "fval") ), execution3.getAttributes()); } }
private DeployExecution newExecution(long id, String versionName, boolean rollback) { DeployExecution exec = mock(DeployExecution.class); when(exec.getId()).thenReturn(id); when(exec.isRollback()).thenReturn(rollback); when(exec.getProductVersion()).thenReturn(versionName); return exec; } }
private String getDeployVersion(DeployExecution deployExecution) { return ObjectUtils.defaultIfNull(deployExecution.getProductVersion(), "no-version-available"); } }
if (!currentExecution.isRollback()) { executionStack.push(currentExecution); } else {
@Override public void update(DeployExecution deployExecution) { MongoDatabase database = mongoClient.getDatabase(env.getPhysicalSchema(deployExecution.getSchema()).getPhysicalName()); MongoCollection<Document> auditCollection = database.getCollection(deployExecutionTableName); auditCollection.replaceOne(getChangeFilter(deployExecution), getDocumentFromDeployExecution(deployExecution, true)); }
@Override public Long valueOf(DeployExecution deployExecution1) { return deployExecution1.getId(); } })) {
private void verifyExecution3(DeployExecution execution3) { assertEquals("try3", execution3.getReason()); assertEquals( Sets.immutable.with( new DeployExecutionAttributeImpl("F", "fval") ), execution3.getAttributes()); } }
private void logDeployExecutions(ImmutableCollection<DeployExecution> deployExecutions, String message) { if (LOG.isInfoEnabled()) { LOG.info("Found {} {} for this schema", deployExecutions.size(), message); if (LOG.isDebugEnabled()) { for (DeployExecution deployExecution : deployExecutions.toSortedListBy(new Function<DeployExecution, Long>() { @Override public Long valueOf(DeployExecution deployExecution1) { return deployExecution1.getId(); } })) { LOG.debug("Execution ID={}, Version Name={}, Deploy Time={}, Rollback={}", deployExecution.getId(), getDeployVersion(deployExecution), deployExecution.getDeployTime(), deployExecution.isRollback()); } } } }
private String getDeployVersion(DeployExecution deployExecution) { return ObjectUtils.defaultIfNull(deployExecution.getProductVersion(), "no-version-available"); } }
if (!currentExecution.isRollback()) { executionStack.push(currentExecution); } else {
@Override public void update(DeployExecution deployExecution) { MongoDatabase database = mongoClient.getDatabase(env.getPhysicalSchema(deployExecution.getSchema()).getPhysicalName()); MongoCollection<Document> auditCollection = database.getCollection(deployExecutionTableName); auditCollection.replaceOne(getChangeFilter(deployExecution), getDocumentFromDeployExecution(deployExecution, true)); }
private Document getDocumentFromDeployExecution(DeployExecution deployExecution, boolean forUpdate) { ImmutableSet<Document> attrs = deployExecution.getAttributes().collect(new Function<DeployExecutionAttribute, Document>() { @Override public Document valueOf(DeployExecutionAttribute object) { return new Document() .append(attrNameColName, object.getName()) .append(attrValueColName, object.getValue()); } }); return new Document() .append(idColName, deployExecution.getId()) .append(requesterIdColName, deployExecution.getRequesterId()) .append(deployExecutionIdColName, deployExecution.getExecutorId()) .append(dbSchemaColName, deployExecution.getSchema()) .append(toolVersionColName, deployExecution.getToolVersion()) .append(deployTimeColName, new Date(deployExecution.getDeployTime().getTime())) .append(initCommandColName, deployExecution.isInit()) .append(rollbackCommandColName, deployExecution.isRollback()) .append(productVersionColName, deployExecution.getProductVersion()) .append(reasonColName, deployExecution.getReason()) .append("attrs", new ArrayList<>(attrs.toList())); }
@Override public Long valueOf(DeployExecution deployExecution1) { return deployExecution1.getId(); } })) {