fix #2667 add flush for config files
This commit is contained in:
parent
aeca590d0e
commit
9bc30b336c
2 changed files with 34 additions and 6 deletions
|
@ -118,12 +118,14 @@ public class AdminMaintenanceAction extends FessAdminAction {
|
|||
public HtmlResponse reloadDocIndex(final ActionForm form) {
|
||||
validate(form, messages -> {}, this::asIndexHtml);
|
||||
verifyToken(this::asIndexHtml);
|
||||
final String docIndex = fessConfig.getIndexDocumentUpdateIndex();
|
||||
searchEngineClient.admin().indices().prepareClose(docIndex).execute(ActionListener.wrap(res -> {
|
||||
logger.info("Close {}", docIndex);
|
||||
searchEngineClient.admin().indices().prepareOpen(docIndex).execute(
|
||||
ActionListener.wrap(res2 -> logger.info("Open {}", docIndex), e -> logger.warn("Failed to open {}", docIndex, e)));
|
||||
}, e -> logger.warn("Failed to close {}", docIndex, e)));
|
||||
searchEngineClient.flushConfigFiles(() -> {
|
||||
final String docIndex = fessConfig.getIndexDocumentUpdateIndex();
|
||||
searchEngineClient.admin().indices().prepareClose(docIndex).execute(ActionListener.wrap(res -> {
|
||||
logger.info("Close {}", docIndex);
|
||||
searchEngineClient.admin().indices().prepareOpen(docIndex).execute(
|
||||
ActionListener.wrap(res2 -> logger.info("Open {}", docIndex), e -> logger.warn("Failed to open {}", docIndex, e)));
|
||||
}, e -> logger.warn("Failed to close {}", docIndex, e)));
|
||||
});
|
||||
saveInfo(messages -> messages.addSuccessStartedDataUpdate(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
|
|
@ -636,6 +636,32 @@ public class SearchEngineClient implements Client {
|
|||
}
|
||||
}
|
||||
|
||||
public void flushConfigFiles(final Runnable callback) {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
|
||||
final String fesenType = fessConfig.getFesenType();
|
||||
switch (fesenType) {
|
||||
case Constants.FESEN_TYPE_CLOUD:
|
||||
case Constants.FESEN_TYPE_AWS:
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Skipped configsync flush: {}", fesenType);
|
||||
}
|
||||
callback.run();
|
||||
break;
|
||||
default:
|
||||
ComponentUtil.getCurlHelper().post("/_configsync/flush").execute(response -> {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Flushed config files: {} => {}", fesenType, response.getContentAsString());
|
||||
}
|
||||
callback.run();
|
||||
}, e -> {
|
||||
logger.warn("Failed to flush config files.", e);
|
||||
callback.run();
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected String generateNewIndexName(final String configIndex) {
|
||||
return configIndex + "." + new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue