[Bugfix](multi-catalog)If es hosts ends with "/", the index cannot be obtained. (#24272)
This commit is contained in:
@ -56,14 +56,15 @@ import javax.net.ssl.X509TrustManager;
|
||||
public class EsRestClient {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(EsRestClient.class);
|
||||
private static OkHttpClient networkClient = new OkHttpClient.Builder().readTimeout(10, TimeUnit.SECONDS).build();
|
||||
private static final OkHttpClient networkClient = new OkHttpClient
|
||||
.Builder().readTimeout(10, TimeUnit.SECONDS).build();
|
||||
|
||||
private static OkHttpClient sslNetworkClient;
|
||||
private Request.Builder builder;
|
||||
private String[] nodes;
|
||||
private final Request.Builder builder;
|
||||
private final String[] nodes;
|
||||
private String currentNode;
|
||||
private int currentNodeIndex = 0;
|
||||
private boolean httpSslEnable;
|
||||
private final boolean httpSslEnable;
|
||||
|
||||
/**
|
||||
* For EsTable.
|
||||
@ -129,9 +130,7 @@ public class EsRestClient {
|
||||
**/
|
||||
public boolean existIndex(OkHttpClient httpClient, String indexName) {
|
||||
String path = indexName + "/_mapping";
|
||||
Response response;
|
||||
try {
|
||||
response = executeResponse(httpClient, path);
|
||||
try (Response response = executeResponse(httpClient, path)) {
|
||||
if (response.isSuccessful()) {
|
||||
return true;
|
||||
}
|
||||
@ -228,7 +227,10 @@ public class EsRestClient {
|
||||
if (!(currentNode.startsWith("http://") || currentNode.startsWith("https://"))) {
|
||||
currentNode = "http://" + currentNode;
|
||||
}
|
||||
Request request = builder.get().url(currentNode + "/" + path).build();
|
||||
if (!currentNode.endsWith("/")) {
|
||||
currentNode = currentNode + "/";
|
||||
}
|
||||
Request request = builder.get().url(currentNode + path).build();
|
||||
if (LOG.isInfoEnabled()) {
|
||||
LOG.info("es rest client request URL: {}", currentNode + "/" + path);
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ enableHiveTest=true
|
||||
hms_port=7141
|
||||
|
||||
enableEsTest=true
|
||||
es_6_port=19200
|
||||
es_6_port="19200/"
|
||||
es_7_port=29200
|
||||
es_8_port=39200
|
||||
|
||||
|
||||
Reference in New Issue
Block a user