|
@@ -184,6 +184,8 @@ public class FessEsClient implements Client {
|
|
|
|
|
|
protected String scrollForDelete = "1m";
|
|
protected String scrollForDelete = "1m";
|
|
|
|
|
|
|
|
+ protected int maxConfigSyncStatusRetry = 10;
|
|
|
|
+
|
|
public void addIndexConfig(final String path) {
|
|
public void addIndexConfig(final String path) {
|
|
indexConfigList.add(path);
|
|
indexConfigList.add(path);
|
|
}
|
|
}
|
|
@@ -604,20 +606,35 @@ public class FessEsClient implements Client {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void waitForConfigSyncStatus() {
|
|
|
|
- try (CurlResponse response = ComponentUtil.getCurlHelper().get("/_configsync/wait").param("status", "green").execute()) {
|
|
|
|
- if (response.getHttpStatusCode() == 200) {
|
|
|
|
- logger.info("ConfigSync is ready.");
|
|
|
|
- } else {
|
|
|
|
- if (response.getContentException() != null) {
|
|
|
|
- throw new FessSystemException("Configsync is not available.", response.getContentException());
|
|
|
|
|
|
+ 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()) {
|
|
|
|
+ final int httpStatusCode = response.getHttpStatusCode();
|
|
|
|
+ if (httpStatusCode == 200) {
|
|
|
|
+ logger.info("ConfigSync is ready.");
|
|
|
|
+ return;
|
|
} else {
|
|
} else {
|
|
- throw new FessSystemException("Configsync is not available.", response.getContentException());
|
|
|
|
|
|
+ final String message = "Configsync is not available. HTTP Status is " + httpStatusCode;
|
|
|
|
+ if (response.getContentException() != null) {
|
|
|
|
+ throw new FessSystemException(message, response.getContentException());
|
|
|
|
+ } else {
|
|
|
|
+ throw new FessSystemException(message);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } 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
|
|
}
|
|
}
|
|
- } catch (final IOException e) {
|
|
|
|
- throw new FessSystemException("Configsync is not available.", e);
|
|
|
|
}
|
|
}
|
|
|
|
+ throw cause;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1434,6 +1451,10 @@ public class FessEsClient implements Client {
|
|
this.scrollForSearch = scrollForSearch;
|
|
this.scrollForSearch = scrollForSearch;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void setMaxConfigSyncStatusRetry(int maxConfigSyncStatusRetry) {
|
|
|
|
+ this.maxConfigSyncStatusRetry = maxConfigSyncStatusRetry;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Client filterWithHeader(final Map<String, String> headers) {
|
|
public Client filterWithHeader(final Map<String, String> headers) {
|
|
return client.filterWithHeader(headers);
|
|
return client.filterWithHeader(headers);
|