Skip to content

Commit

Permalink
[fix](ES catalog) throw exception when ES meta track failed (apache#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
qidaye authored Jan 26, 2024
1 parent 7a103e5 commit c1006a0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.doris.catalog;

import org.apache.doris.common.DdlException;
import org.apache.doris.common.UserException;
import org.apache.doris.common.io.Text;
import org.apache.doris.external.elasticsearch.EsMetaStateTracker;
import org.apache.doris.external.elasticsearch.EsRestClient;
Expand Down Expand Up @@ -140,15 +141,15 @@ public EsTable(long id, String name, List<Column> schema, TableType tableType) {
super(id, name, tableType, schema);
}

public Map<String, String> fieldsContext() {
public Map<String, String> fieldsContext() throws UserException {
return esMetaStateTracker.searchContext().fetchFieldsContext();
}

public Map<String, String> docValueContext() {
public Map<String, String> docValueContext() throws UserException {
return esMetaStateTracker.searchContext().docValueFieldsContext();
}

public List<String> needCompatDateFields() {
public List<String> needCompatDateFields() throws UserException {
return esMetaStateTracker.searchContext().needCompatDateFields();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
package org.apache.doris.external.elasticsearch;

import org.apache.doris.catalog.EsTable;
import org.apache.doris.common.UserException;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.LinkedList;
import java.util.List;
Expand All @@ -32,6 +36,8 @@
*/
public class EsMetaStateTracker {

private static final Logger LOG = LogManager.getLogger(EsMetaStateTracker.class);

private List<SearchPhase> builtinSearchPhase = new LinkedList<>();
private SearchContext searchContext;

Expand All @@ -41,7 +47,11 @@ public EsMetaStateTracker(EsRestClient client, EsTable esTable) {
searchContext = new SearchContext(esTable);
}

public SearchContext searchContext() {
public SearchContext searchContext() throws UserException {
if (searchContext == null) {
LOG.warn("ES meta state track failed, please check ES health status.");
throw new UserException("ES meta state track failed, please check ES health status.");
}
return searchContext;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public String getNodeExplainString(String prefix, TExplainLevel detailLevel) {
return output.toString();
}

private void buildQuery() {
private void buildQuery() throws UserException {
if (conjuncts.isEmpty()) {
queryBuilder = QueryBuilders.matchAllQuery();
} else {
Expand Down

0 comments on commit c1006a0

Please sign in to comment.