Skip to content

Commit 896ae4a

Browse files
Change MongoDB collection change type to incremental from rerunnable
1 parent 5d13075 commit 896ae4a

File tree

22 files changed

+161
-40
lines changed

22 files changed

+161
-40
lines changed

obevo-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<name>${project.artifactId}</name>
3030

3131
<properties>
32-
<jacoco.minCoverage>0.39</jacoco.minCoverage>
32+
<jacoco.minCoverage>0.35</jacoco.minCoverage>
3333
</properties>
3434

3535
<build>

obevo-core/src/main/java/com/gs/obevo/apps/reveng/AbstractReveng.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public Iterable<ChangeEntry> valueOf(FileProcessingContext fileProcessingContext
290290
// });
291291

292292
new RevengWriter().write(platform, changeEntries, new File(args.getOutputPath(), "final"), args.isGenerateBaseline(), RevengWriter.defaultShouldOverwritePredicate(), args.getExcludeObjects());
293-
new RevengWriter().writeConfig("deployer/reveng/system-config-template.xml.ftl", platform, new File(args.getOutputPath(), "final"), args.getDbSchema(),
293+
new RevengWriter().writeConfig("deployer/reveng/system-config-template.xml.ftl", platform, new File(args.getOutputPath(), "final"), Lists.mutable.of(args.getDbSchema()),
294294
Maps.immutable.of(
295295
"jdbcUrl", args.getJdbcUrl(),
296296
"dbHost", args.getDbHost(),

obevo-core/src/main/java/com/gs/obevo/apps/reveng/DbMergeInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.eclipse.collections.impl.collection.mutable.CollectionAdapter;
2727
import org.eclipse.collections.impl.factory.Lists;
2828

29-
class DbMergeInfo {
29+
public class DbMergeInfo {
3030
private final String name;
3131
private final File inputDir;
3232
private String driverClassName;

obevo-core/src/main/java/com/gs/obevo/apps/reveng/Reveng.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* Copyright 2017 Goldman Sachs.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing,
10+
* software distributed under the License is distributed on an
11+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12+
* KIND, either express or implied. See the License for the
13+
* specific language governing permissions and limitations
14+
* under the License.
15+
*/
116
package com.gs.obevo.apps.reveng;
217

318
public interface Reveng {

obevo-core/src/main/java/com/gs/obevo/apps/reveng/RevengWriter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ class RevengWriter {
151151
}
152152
}
153153

154-
fun writeConfig(templatePath: String, platform: Platform, outputDir: File, schema: String, params: Map<String, String>) {
154+
fun writeConfig(templatePath: String, platform: Platform, outputDir: File, schemas: Collection<String>, params: Map<String, String>) {
155155
FileWriter(File(outputDir, "system-config.xml")).use { fileWriter ->
156156
val template = templateConfig.getTemplate(templatePath)
157157

158158
val displayParams = Maps.mutable.empty<String, Any>()
159159
displayParams["platform"] = platform.name
160-
displayParams["schemas"] = listOf(schema)
161-
params.forEach { key, value -> displayParams[key] = value }
160+
displayParams["schemas"] = schemas
161+
params.forEach { (key, value) -> displayParams[key] = value }
162162
template.process(displayParams, fileWriter)
163163
}
164164
}

obevo-db/src/main/java/com/gs/obevo/db/apps/reveng/AquaRevengMain.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.eclipse.collections.api.multimap.Multimap;
5454
import org.eclipse.collections.api.partition.list.PartitionMutableList;
5555
import org.eclipse.collections.api.set.ImmutableSet;
56+
import org.eclipse.collections.api.set.MutableSet;
5657
import org.eclipse.collections.api.tuple.Pair;
5758
import org.eclipse.collections.impl.block.factory.StringFunctions;
5859
import org.eclipse.collections.impl.block.factory.StringPredicates;
@@ -157,7 +158,15 @@ public Comparable valueOf(File file) {
157158

158159
File outputWriteFolder = tablespaceToken ? outputDir : new File(outputDir, "final"); // check the tablespaceToken value for backwards-compatibility
159160
new RevengWriter().write(platform, allRevEngDestinations, outputWriteFolder, this.generateBaseline, null, args.getExcludeObjects());
160-
new RevengWriter().writeConfig("deployer/reveng/system-config-template.xml.ftl", platform, outputWriteFolder, args.getDbSchema(),
161+
162+
// For legacy reasons w/ Aqua Reverse Engineering, get the list of schemas from the generated destinations
163+
MutableSet<String> schemas = allRevEngDestinations.collect(new Function<ChangeEntry, String>() {
164+
@Override
165+
public String valueOf(ChangeEntry object) {
166+
return object.getDestination().getSchema();
167+
}
168+
}).toSet();
169+
new RevengWriter().writeConfig("deployer/reveng/system-config-template.xml.ftl", platform, outputWriteFolder, schemas,
161170
Maps.immutable.of(
162171
"jdbcUrl", args.getJdbcUrl(),
163172
"dbHost", args.getDbHost(),

obevo-dists/obevo-cli/src/main/java/com/gs/obevo/dist/Main.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
import java.util.Date;
1919

20-
import com.gs.obevo.apps.reveng.AbstractReveng;
21-
import com.gs.obevo.cmdline.DeployerArgs;
2220
import com.gs.obevo.apps.reveng.AquaRevengArgs;
23-
import com.gs.obevo.db.apps.reveng.AquaRevengMain;
2421
import com.gs.obevo.apps.reveng.DbFileMerger;
2522
import com.gs.obevo.apps.reveng.DbFileMergerArgs;
23+
import com.gs.obevo.apps.reveng.Reveng;
24+
import com.gs.obevo.cmdline.DeployerArgs;
25+
import com.gs.obevo.db.apps.reveng.AquaRevengMain;
2626
import com.gs.obevo.db.apps.reveng.TableSyncher;
2727
import com.gs.obevo.db.cmdline.DbDeployerMain;
2828
import com.gs.obevo.db.impl.core.compare.data.DbDataComparisonUtil;
@@ -204,7 +204,7 @@ public void value(String[] argSubset) {
204204
@Override
205205
public void value(String[] argSubset) {
206206
AquaRevengArgs newArgsObj = new ArgsParser().parse(argSubset, new AquaRevengArgs());
207-
AbstractReveng ddlReveng = newArgsObj.getPlatform().getDdlReveng();
207+
Reveng ddlReveng = newArgsObj.getPlatform().getDdlReveng();
208208
ddlReveng.reveng(newArgsObj);
209209
}
210210
});

obevo-mongodb/src/main/java/com/gs/obevo/mongodb/impl/MongoDbDeployerAppContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ public MongoDbDeployerAppContext setupEnvInfra(boolean strictSetupEnvInfra, Bool
123123

124124
@Override
125125
public MongoDbDeployerAppContext cleanEnvironment() {
126-
LOG.info("setupEnvInfra is not implemented; doing nothing");
126+
MongoDbEnvironmentCleaner cleaner = new MongoDbEnvironmentCleaner(getMongoClient(), env);
127+
cleaner.clean();
127128
return this;
128129
}
129130
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Copyright 2017 Goldman Sachs.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing,
10+
* software distributed under the License is distributed on an
11+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12+
* KIND, either express or implied. See the License for the
13+
* specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
package com.gs.obevo.mongodb.impl
17+
18+
import com.gs.obevo.impl.MainDeployer
19+
import com.gs.obevo.mongodb.api.appdata.MongoDbEnvironment
20+
import com.mongodb.MongoClient
21+
import org.slf4j.LoggerFactory
22+
23+
class MongoDbEnvironmentCleaner internal constructor(private val mongoClient: MongoClient, private val env: MongoDbEnvironment) {
24+
fun clean() {
25+
for ((physicalName) in env.physicalSchemas) {
26+
val database = mongoClient.getDatabase(physicalName)
27+
database.listCollectionNames().forEach { collectionName ->
28+
LOG.info("Found collection {} to drop", collectionName)
29+
val collection = database.getCollection(collectionName)
30+
collection.drop()
31+
}
32+
}
33+
}
34+
35+
companion object {
36+
private val LOG = LoggerFactory.getLogger(MainDeployer::class.java)
37+
}
38+
}

obevo-mongodb/src/main/java/com/gs/obevo/mongodb/impl/MongoDbPlatform.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class MongoDbPlatform implements Platform {
3636

3737
public MongoDbPlatform() {
3838
this.changeTypes = Lists.immutable.<ChangeType>of(
39-
ChangeTypeImpl.newChangeType(CHANGE_TYPE_COLLECTION, true, 0).build(),
39+
ChangeTypeImpl.newChangeType(CHANGE_TYPE_COLLECTION, false, 0).build(),
4040
ChangeTypeImpl.newChangeType(ChangeType.MIGRATION_STR, false, 100).setEnrichableForDependenciesInText(false).build()
4141
);
4242
}

0 commit comments

Comments
 (0)