Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 1eb9592

Browse files
committed
#80 Fixing bug where config from AppConfig wasn't applied when undoing forest replicas
1 parent 7e7904c commit 1eb9592

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

src/main/java/com/marklogic/appdeployer/command/forests/ConfigureForestReplicasCommand.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,18 @@ public void execute(CommandContext context) {
9292
@Override
9393
public void undo(CommandContext context) {
9494
if (deleteReplicasOnUndo) {
95+
String str = context.getAppConfig().getDatabaseNamesAndReplicaCounts();
96+
if (str != null) {
97+
setDatabaseNamesAndReplicaCountsAsString(str);
98+
}
99+
95100
DatabaseManager dbMgr = new DatabaseManager(context.getManageClient());
96101
ForestManager forestMgr = new ForestManager(context.getManageClient());
97102

98103
for (String databaseName : databaseNamesAndReplicaCounts.keySet()) {
99104
logger.info(format("Deleting forest replicas for database %s", databaseName));
100-
for (String forestName : dbMgr.getForestNames(databaseName)) {
105+
List<String> forestNames = dbMgr.getForestNames(databaseName);
106+
for (String forestName : forestNames) {
101107
deleteReplicas(forestName, forestMgr);
102108
}
103109
logger.info(format("Finished deleting forest replicas for database %s", databaseName));

src/test/java/com/marklogic/appdeployer/command/forests/ConfigureForestReplicasDebug.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.marklogic.appdeployer.AppConfig;
44
import com.marklogic.appdeployer.command.CommandContext;
5+
import com.marklogic.appdeployer.command.databases.DeployDatabaseCommand;
56
import com.marklogic.mgmt.ManageClient;
67
import com.marklogic.mgmt.ManageConfig;
78

@@ -18,16 +19,22 @@ public static void main(String[] args) {
1819
ManageConfig config = new ManageConfig(host, 8002, "admin", password);
1920
ManageClient manageClient = new ManageClient(config);
2021
AppConfig appConfig = new AppConfig();
22+
appConfig.setDatabaseNamesAndReplicaCounts("testdb,1");
2123
CommandContext context = new CommandContext(appConfig, manageClient, null);
2224

23-
// Configure replicas
24-
ConfigureForestReplicasCommand command = new ConfigureForestReplicasCommand();
25-
// command.getForestNamesAndReplicaCounts().put("Security", 1);
26-
// command.getForestNamesAndReplicaCounts().put("Schemas", 2);
27-
//command.getDatabaseNamesAndReplicaCounts().put("failover-example-content", 2);
28-
command.execute(context);
25+
DeployDatabaseCommand ddc = new DeployDatabaseCommand();
26+
ddc.setForestsPerHost(1);
27+
ddc.setCreateDatabaseWithoutFile(true);
28+
ddc.setDatabaseName("testdb");
2929

30-
// And then delete those replicas
31-
command.undo(context);
30+
ConfigureForestReplicasCommand cfrc = new ConfigureForestReplicasCommand();
31+
32+
// Deploy the database, and then configure replicas
33+
ddc.execute(context);
34+
cfrc.execute(context);
35+
36+
// Then delete the replicas, and then undeploy the database
37+
cfrc.undo(context);
38+
ddc.undo(context);
3239
}
3340
}

0 commit comments

Comments
 (0)