use of com.alibaba.druid.admin.model.dto.DataSourceResult in project druid by alibaba.
the class MonitorStatService method getDataSourceStatData.
/**
* 数据源监控
*
* @param
* @return
*/
public String getDataSourceStatData() {
Map<String, ServiceNode> allNodeMap = getAllServiceNodeMap();
DataSourceResult lastResult = new DataSourceResult();
List<DataSourceResult.ContentBean> contentBeans = new ArrayList<>();
for (String nodeKey : allNodeMap.keySet()) {
ServiceNode serviceNode = allNodeMap.get(nodeKey);
String serviceName = serviceNode.getServiceName();
String url = "http://" + serviceNode.getAddress() + ":" + serviceNode.getPort() + "/druid/datasource.json";
DataSourceResult dataSourceResult = HttpUtil.get(url, lastResult.getClass());
if (dataSourceResult != null) {
List<DataSourceResult.ContentBean> nodeContent = dataSourceResult.getContent();
if (nodeContent != null) {
for (DataSourceResult.ContentBean contentBean : nodeContent) {
contentBean.setName(serviceName);
contentBean.setServiceId(serviceNode.getId());
}
contentBeans.addAll(nodeContent);
}
}
}
lastResult.setContent(contentBeans);
return JSON.toJSONString(lastResult);
}
Aggregations