use of cn.exrick.manager.dto.EsCount in project xmall by Exrick.
the class SearchItemServiceImpl method getEsInfo.
@Override
public EsInfo getEsInfo() {
String healthUrl = "http://" + ES_CONNECT_IP + ":" + ES_NODE_CLIENT_PORT + "/_cluster/health";
String countUrl = "http://" + ES_CONNECT_IP + ":" + ES_NODE_CLIENT_PORT + "/_count";
String healthResult = HttpUtil.sendGet(healthUrl);
String countResult = HttpUtil.sendGet(countUrl);
if (StringUtils.isBlank(healthResult) || StringUtils.isBlank(countResult)) {
throw new XmallException("连接集群失败,请检查ES运行状态");
}
EsInfo esInfo = new EsInfo();
EsCount esCount = new EsCount();
try {
esInfo = new Gson().fromJson(healthResult, EsInfo.class);
esCount = new Gson().fromJson(countResult, EsCount.class);
esInfo.setCount(esCount.getCount());
} catch (Exception e) {
e.printStackTrace();
throw new XmallException("获取ES信息出错");
}
return esInfo;
}
Aggregations