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

Commit 9448c38

Browse files
authored
Merge pull request #497 from marklogic/feature/11792-custom-forests
MLE-11792 Submitting one request per custom forests file
2 parents 7d4298b + c338b0c commit 9448c38

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,19 @@ public DeployCustomForestsCommand() {
4949

5050
@Override
5151
public void execute(CommandContext context) {
52-
Configuration configuration = null;
53-
if (context.getAppConfig().getCmaConfig().isDeployForests()) {
54-
configuration = new Configuration();
55-
}
56-
5752
for (ConfigDir configDir : context.getAppConfig().getConfigDirs()) {
5853
File dir = new File(configDir.getBaseDir(), customForestsPath);
5954
if (dir != null && dir.exists()) {
6055
payloadParser = new PayloadParser();
6156
for (File f : dir.listFiles()) {
6257
if (f.isDirectory()) {
63-
processDirectory(f, context, configuration);
58+
processDirectory(f, context);
6459
}
6560
}
6661
} else {
6762
logResourceDirectoryNotFound(dir);
6863
}
6964
}
70-
71-
if (configuration != null) {
72-
deployConfiguration(context, configuration);
73-
}
7465
}
7566

7667
/**
@@ -79,7 +70,7 @@ public void execute(CommandContext context) {
7970
* @param dir
8071
* @param context
8172
*/
82-
protected void processDirectory(File dir, CommandContext context, Configuration configuration) {
73+
protected void processDirectory(File dir, CommandContext context) {
8374
if (logger.isInfoEnabled()) {
8475
logger.info("Processing custom forest files in directory: " + dir.getAbsolutePath());
8576
}
@@ -91,6 +82,11 @@ protected void processDirectory(File dir, CommandContext context, Configuration
9182
}
9283
String payload = readResourceFromFile(context, f);
9384

85+
// As of 4.6.1, create a CMA request per file so that the user has control over how many forests are
86+
// submitted in a single request, thus avoiding potential timeouts.
87+
Configuration configuration = context.getAppConfig().getCmaConfig().isDeployForests() ?
88+
new Configuration() : null;
89+
9490
if (payloadParser.isJsonPayload(payload)) {
9591
if (configuration != null) {
9692
addForestsToCmaConfiguration(context, payload, configuration);
@@ -104,6 +100,10 @@ protected void processDirectory(File dir, CommandContext context, Configuration
104100
mgr.save(payload);
105101
}
106102
}
103+
104+
if (configuration != null) {
105+
deployConfiguration(context, configuration);
106+
}
107107
}
108108
}
109109

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ public void test() {
5151
assertTrue(mgr.exists("sample-app-content-custom-3"));
5252
}
5353

54+
/**
55+
* Can examine logging to verify that one request is made per forest.
56+
*/
5457
@Test
55-
public void deployWithCma() {
56-
appConfig.getCmaConfig().enableAll();
58+
public void deployWithoutCMA() {
59+
appConfig.getCmaConfig().setDeployForests(false);
5760
test();
5861
}
5962
}

0 commit comments

Comments
 (0)