fix #535 : improve refresh method
This commit is contained in:
parent
8d3a2542ae
commit
453db85ac3
6 changed files with 49 additions and 10 deletions
|
@ -237,7 +237,7 @@ public class ElevateWordService {
|
|||
logger.warn("Failed to read a sugget elevate word: " + list, e);
|
||||
}
|
||||
}
|
||||
fessEsClient.refresh("_all"); // TODO replace _all
|
||||
elevateWordBhv.refresh();
|
||||
} catch (final IOException e) {
|
||||
logger.warn("Failed to read a sugget elevate word.", e);
|
||||
}
|
||||
|
|
|
@ -374,7 +374,7 @@ public class AdminUpgradeAction extends FessAdminAction {
|
|||
|
||||
saveInfo(messages -> messages.addSuccessUpgradeFrom(GLOBAL));
|
||||
|
||||
fessEsClient.refresh("_all");
|
||||
fessEsClient.refresh();
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to upgrade data.", e);
|
||||
saveError(messages -> messages.addErrorsFailedToUpgradeFrom(GLOBAL, "10.0", e.getLocalizedMessage()));
|
||||
|
|
|
@ -722,36 +722,36 @@ public class FessEsClient implements Client {
|
|||
}
|
||||
}
|
||||
|
||||
public void refresh(final String index) {
|
||||
client.admin().indices().prepareRefresh(index).execute(new ActionListener<RefreshResponse>() {
|
||||
public void refresh(final String... indices) {
|
||||
client.admin().indices().prepareRefresh(indices).execute(new ActionListener<RefreshResponse>() {
|
||||
@Override
|
||||
public void onResponse(final RefreshResponse response) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Refreshed " + index + ".");
|
||||
logger.debug("Refreshed " + stream(indices).get(stream -> stream.collect(Collectors.joining(", "))) + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(final Throwable e) {
|
||||
logger.error("Failed to refresh " + index + ".", e);
|
||||
logger.error("Failed to refresh " + stream(indices).get(stream -> stream.collect(Collectors.joining(", "))) + ".", e);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void flush(final String index) {
|
||||
client.admin().indices().prepareFlush(index).execute(new ActionListener<FlushResponse>() {
|
||||
public void flush(final String... indices) {
|
||||
client.admin().indices().prepareFlush(indices).execute(new ActionListener<FlushResponse>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(final FlushResponse response) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Flushed " + index + ".");
|
||||
logger.debug("Flushed " + stream(indices).get(stream -> stream.collect(Collectors.joining(", "))) + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(final Throwable e) {
|
||||
logger.error("Failed to flush " + index + ".", e);
|
||||
logger.error("Failed to flush " + stream(indices).get(stream -> stream.collect(Collectors.joining(", "))) + ".", e);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.dbflute.cbean.result.ListResultBean;
|
|||
import org.dbflute.exception.FetchingOverSafetySizeException;
|
||||
import org.dbflute.exception.IllegalBehaviorStateException;
|
||||
import org.dbflute.util.DfTypeUtil;
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
|
||||
import org.elasticsearch.action.bulk.BulkItemResponse;
|
||||
import org.elasticsearch.action.bulk.BulkRequestBuilder;
|
||||
import org.elasticsearch.action.bulk.BulkResponse;
|
||||
|
@ -72,6 +73,7 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
|
|||
protected String scrollSearchTimeout = "3m";
|
||||
protected String bulkTimeout = "3m";
|
||||
protected String deleteTimeout = "3m";
|
||||
protected String refreshTimeout = "1m";
|
||||
|
||||
protected abstract String asEsIndex();
|
||||
|
||||
|
@ -81,6 +83,13 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
|
|||
|
||||
protected abstract <RESULT extends ENTITY> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType);
|
||||
|
||||
// ===================================================================================
|
||||
// Elasticsearch
|
||||
// ======
|
||||
public RefreshResponse refresh() {
|
||||
return client.admin().indices().prepareRefresh(asEsIndex()).execute().actionGet(refreshTimeout);
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Select
|
||||
// ======
|
||||
|
@ -474,6 +483,10 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
|
|||
this.deleteTimeout = deleteTimeout;
|
||||
}
|
||||
|
||||
public void setRefreshTimeout(String refreshTimeout) {
|
||||
this.refreshTimeout = refreshTimeout;
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.dbflute.cbean.result.ListResultBean;
|
|||
import org.dbflute.exception.FetchingOverSafetySizeException;
|
||||
import org.dbflute.exception.IllegalBehaviorStateException;
|
||||
import org.dbflute.util.DfTypeUtil;
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
|
||||
import org.elasticsearch.action.bulk.BulkItemResponse;
|
||||
import org.elasticsearch.action.bulk.BulkRequestBuilder;
|
||||
import org.elasticsearch.action.bulk.BulkResponse;
|
||||
|
@ -72,6 +73,7 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
|
|||
protected String scrollSearchTimeout = "3m";
|
||||
protected String bulkTimeout = "3m";
|
||||
protected String deleteTimeout = "3m";
|
||||
protected String refreshTimeout = "1m";
|
||||
|
||||
protected abstract String asEsIndex();
|
||||
|
||||
|
@ -81,6 +83,13 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
|
|||
|
||||
protected abstract <RESULT extends ENTITY> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType);
|
||||
|
||||
// ===================================================================================
|
||||
// Elasticsearch
|
||||
// ======
|
||||
public RefreshResponse refresh() {
|
||||
return client.admin().indices().prepareRefresh(asEsIndex()).execute().actionGet(refreshTimeout);
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Select
|
||||
// ======
|
||||
|
@ -474,6 +483,10 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
|
|||
this.deleteTimeout = deleteTimeout;
|
||||
}
|
||||
|
||||
public void setRefreshTimeout(String refreshTimeout) {
|
||||
this.refreshTimeout = refreshTimeout;
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.dbflute.cbean.result.ListResultBean;
|
|||
import org.dbflute.exception.FetchingOverSafetySizeException;
|
||||
import org.dbflute.exception.IllegalBehaviorStateException;
|
||||
import org.dbflute.util.DfTypeUtil;
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
|
||||
import org.elasticsearch.action.bulk.BulkItemResponse;
|
||||
import org.elasticsearch.action.bulk.BulkRequestBuilder;
|
||||
import org.elasticsearch.action.bulk.BulkResponse;
|
||||
|
@ -72,6 +73,7 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
|
|||
protected String scrollSearchTimeout = "3m";
|
||||
protected String bulkTimeout = "3m";
|
||||
protected String deleteTimeout = "3m";
|
||||
protected String refreshTimeout = "1m";
|
||||
|
||||
protected abstract String asEsIndex();
|
||||
|
||||
|
@ -81,6 +83,13 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
|
|||
|
||||
protected abstract <RESULT extends ENTITY> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType);
|
||||
|
||||
// ===================================================================================
|
||||
// Elasticsearch
|
||||
// ======
|
||||
public RefreshResponse refresh() {
|
||||
return client.admin().indices().prepareRefresh(asEsIndex()).execute().actionGet(refreshTimeout);
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Select
|
||||
// ======
|
||||
|
@ -474,6 +483,10 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
|
|||
this.deleteTimeout = deleteTimeout;
|
||||
}
|
||||
|
||||
public void setRefreshTimeout(String refreshTimeout) {
|
||||
this.refreshTimeout = refreshTimeout;
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
|
|
Loading…
Add table
Reference in a new issue