mirror of
https://gitee.com/dromara/easy-es.git
synced 2025-12-07 01:28:37 +08:00
!54 EEVersionUtil工具类获取es客户端版本失败改为打印日志
Merge pull request !54 from 花落陌/feature
This commit is contained in:
commit
a5a62fbe00
@ -4,7 +4,6 @@ import lombok.AccessLevel;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.elasticsearch.client.RequestOptions;
|
import org.elasticsearch.client.RequestOptions;
|
||||||
import org.elasticsearch.client.RestHighLevelClient;
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
import org.elasticsearch.client.core.MainResponse;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -44,12 +43,13 @@ public class EEVersionUtils {
|
|||||||
* @return client version
|
* @return client version
|
||||||
*/
|
*/
|
||||||
public static String getClientVersion(RestHighLevelClient restHighLevelClient) {
|
public static String getClientVersion(RestHighLevelClient restHighLevelClient) {
|
||||||
MainResponse info;
|
|
||||||
try {
|
try {
|
||||||
info = restHighLevelClient.info(RequestOptions.DEFAULT);
|
return restHighLevelClient.info(RequestOptions.DEFAULT)
|
||||||
|
.getVersion()
|
||||||
|
.getNumber();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
LogUtils.formatWarn("get client version error");
|
||||||
}
|
}
|
||||||
return info.getVersion().getNumber();
|
return "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user