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

Commit bb63514

Browse files
committed
#382 Fix for setting mlDatabaseGroups and mlDatabasesWithForestsOnOneHost
1 parent c219016 commit bb63514

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/main/java/com/marklogic/appdeployer/AppConfig.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,13 @@ public void setCatchUndeployExceptions(boolean catchUndeployExceptions) {
11281128
this.catchUndeployExceptions = catchUndeployExceptions;
11291129
}
11301130

1131+
public boolean isDatabaseWithForestsOnOneHost(String databaseName) {
1132+
if (databasesWithForestsOnOneHost == null) {
1133+
return false;
1134+
}
1135+
return databasesWithForestsOnOneHost.contains(databaseName);
1136+
}
1137+
11311138
public Set<String> getDatabasesWithForestsOnOneHost() {
11321139
return databasesWithForestsOnOneHost;
11331140
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public DefaultHostCalculator(HostNameProvider hostNameProvider) {
2020
public List<String> calculateHostNames(String databaseName, CommandContext context) {
2121
List<String> hostNamesFromDatabaseGroups = determineHostsNamesBasedOnDatabaseGroups(databaseName, context);
2222
if (hostNamesFromDatabaseGroups != null) {
23+
if (hostNamesFromDatabaseGroups.size() > 1 && context.getAppConfig().isDatabaseWithForestsOnOneHost(databaseName)) {
24+
return hostNamesFromDatabaseGroups.subList(0, 1);
25+
}
2326
return hostNamesFromDatabaseGroups;
2427
}
2528

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,22 @@ public void test() {
4949
assertTrue(hostNames.contains("name4"));
5050
assertTrue(hostNames.contains("name5"));
5151
}
52+
53+
@Test
54+
public void databaseWithForestOnOneHost() {
55+
TestHostNameProvider hostNameProvider = new TestHostNameProvider("name1", "name2", "name3");
56+
hostNameProvider.addGroupHostNames("group1", "name1");
57+
hostNameProvider.addGroupHostNames("group2", "name2", "name3");
58+
59+
DefaultHostCalculator hostCalculator = new DefaultHostCalculator(hostNameProvider);
60+
61+
Properties props = new Properties();
62+
props.setProperty("mlDatabaseGroups", "test-db,group2");
63+
props.setProperty("mlDatabasesWithForestsOnOneHost", "test-db");
64+
65+
CommandContext context = new CommandContext(new DefaultAppConfigFactory(new SimplePropertySource(props)).newAppConfig(), null, null);
66+
List<String> hostNames = hostCalculator.calculateHostNames("test-db", context);
67+
assertEquals("The database should only have a forest on the first host", 1, hostNames.size());
68+
assertEquals("name2", hostNames.get(0));
69+
}
5270
}

0 commit comments

Comments
 (0)