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

Commit 92f6d99

Browse files
committed
Added a limit for # of retries
1 parent 6f85e1d commit 92f6d99

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/main/java/com/marklogic/mgmt/admin/AdminManager.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
public class AdminManager extends AbstractManager {
1818

1919
private int waitForRestartCheckInterval = 1000;
20+
private int waitForRestartLimit = 30;
2021
private RestTemplate restTemplate;
2122
private AdminConfig adminConfig;
2223

@@ -139,18 +140,28 @@ public String getLastRestartTimestamp() {
139140
}
140141

141142
public void waitForRestart() {
143+
waitForRestartInternal(1);
144+
}
145+
146+
private void waitForRestartInternal(int attempt) {
147+
if (attempt > this.waitForRestartLimit) {
148+
logger.error("Reached limit of " + waitForRestartLimit
149+
+ ", and MarkLogic has not restarted yet; check MarkLogic status");
150+
return;
151+
}
142152
try {
143153
Thread.sleep(waitForRestartCheckInterval);
144154
getLastRestartTimestamp();
145155
if (logger.isInfoEnabled()) {
146156
logger.info("Finished waiting for MarkLogic to restart");
147157
}
148158
} catch (Exception ex) {
149-
logger.info("Waiting for MarkLogic to restart...");
159+
attempt++;
160+
logger.info("Waiting for MarkLogic to restart, attempt: " + attempt);
150161
if (logger.isTraceEnabled()) {
151162
logger.trace("Caught exception while waiting for MarkLogic to restart: " + ex.getMessage(), ex);
152163
}
153-
waitForRestart();
164+
waitForRestartInternal(attempt);
154165
}
155166
}
156167

@@ -159,8 +170,7 @@ public void waitForRestart() {
159170
*/
160171
public void setSslFipsEnabled(final boolean enabled) {
161172
final String xquery = "import module namespace admin = 'http://marklogic.com/xdmp/admin' at '/MarkLogic/admin.xqy'; "
162-
+ "admin:save-configuration(admin:cluster-set-ssl-fips-enabled(admin:get-configuration(), "
163-
+ enabled
173+
+ "admin:save-configuration(admin:cluster-set-ssl-fips-enabled(admin:get-configuration(), " + enabled
164174
+ "()))";
165175

166176
invokeActionRequiringRestart(new ActionRequiringRestart() {
@@ -191,4 +201,8 @@ public void setWaitForRestartCheckInterval(int waitForRestartCheckInterval) {
191201
this.waitForRestartCheckInterval = waitForRestartCheckInterval;
192202
}
193203

204+
public void setWaitForRestartLimit(int waitForRestartLimit) {
205+
this.waitForRestartLimit = waitForRestartLimit;
206+
}
207+
194208
}

0 commit comments

Comments
 (0)