fix add maxConfigSyncStatusRetry
@@ -184,6 +184,8 @@ public class FessEsClient implements Client {
protected String scrollForDelete = "1m";
+ protected int maxConfigSyncStatusRetry = 10;
+
public void addIndexConfig(final String path) {
indexConfigList.add(path);
}
@@ -604,21 +606,36 @@ public class FessEsClient implements Client {
}
}
- private void waitForConfigSyncStatus() {
+ protected void waitForConfigSyncStatus() {
+ FessSystemException cause = null;
+ for (int i = 0; i < maxConfigSyncStatusRetry; i++) {
try (CurlResponse response = ComponentUtil.getCurlHelper().get("/_configsync/wait").param("status", "green").execute()) {
- if (response.getHttpStatusCode() == 200) {
+ final int httpStatusCode = response.getHttpStatusCode();
+ if (httpStatusCode == 200) {
logger.info("ConfigSync is ready.");
+ return;
} else {
+ final String message = "Configsync is not available. HTTP Status is " + httpStatusCode;
if (response.getContentException() != null) {
- throw new FessSystemException("Configsync is not available.", response.getContentException());
+ throw new FessSystemException(message, response.getContentException());
} else {
- throw new FessSystemException("Configsync is not available.", response.getContentException());
+ throw new FessSystemException(message);
}
}
- } catch (final IOException e) {
- throw new FessSystemException("Configsync is not available.", e);
+ } catch (final Exception e) {
+ cause = new FessSystemException("Configsync is not available.", e);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Failed to access to configsync:" + i, cause);
+ }
+ try {
+ Thread.sleep(1000L);
+ } catch (InterruptedException e) {
+ // ignore
}
}
+ throw cause;
+ }
@Override
@PreDestroy
@@ -1434,6 +1451,10 @@ public class FessEsClient implements Client {
this.scrollForSearch = scrollForSearch;
}
+ public void setMaxConfigSyncStatusRetry(int maxConfigSyncStatusRetry) {
+ this.maxConfigSyncStatusRetry = maxConfigSyncStatusRetry;
+ }
+
@Override
public Client filterWithHeader(final Map<String, String> headers) {
return client.filterWithHeader(headers);
