Authored by FengRuwei

Merge branch 'master' of http://git.yoho.cn/ops/monitor-service

... ... @@ -111,3 +111,4 @@ monitor-service-middleware/.gitignore
monitor-service-middleware/.settings/org.eclipse.core.resources.prefs
monitor-service-middleware/.settings/org.eclipse.jdt.core.prefs
monitor-service-middleware/.settings/org.eclipse.m2e.core.prefs
monitor-service-influxdb/src/main/java/com/monitor/influxdb/QueryResultUtil.java
... ...
... ... @@ -31,21 +31,21 @@ public class ZkMonitorCtrl {
@RequestMapping("/getZkMonitorRecords")
@ResponseBody
public BaseResponse<PageResponse<ZkInfo>> getZkMonitorRecords(@RequestBody ZkInfoReq req) throws Exception {
public BaseResponse<PageResponse<Object>> getZkMonitorRecords(@RequestBody ZkInfoReq req) throws Exception {
log.info("getHostInfos with param is {}", req);
// 查询列表
PageResponse<ZkInfo> responseBO = zkMoitorService.getZkMonitorRecords(req);
PageResponse<Object> responseBO = zkMoitorService.getZkMonitorRecords(req);
if (responseBO == null || CollectionUtils.isEmpty(responseBO.getRows())) {
return new BaseResponse<PageResponse<ZkInfo>>();
return null;
}
PageResponse<ZkInfo> response = new PageResponse<ZkInfo>();
PageResponse<Object> response = new PageResponse<Object>();
response.setCurrentPage(responseBO.getCurrentPage());
response.setRows(responseBO.getRows());
response.setPageSize(responseBO.getPageSize());
response.setTotal(responseBO.getTotal());
log.info("getHostInfos success and total={}", response.getTotal());
return new BaseResponse<PageResponse<ZkInfo>>(response);
return new BaseResponse<PageResponse<Object>>(response);
}
}
... ...
package com.monitor.cmdb.service;
import com.monitor.influxdb.model.ZkInfo;
import com.monitor.model.request.ZkInfoReq;
import com.monitor.model.response.PageResponse;
... ... @@ -9,5 +8,5 @@ import com.monitor.model.response.PageResponse;
*/
public interface IZkMoitorService {
PageResponse<ZkInfo> getZkMonitorRecords(ZkInfoReq req);
PageResponse<Object> getZkMonitorRecords(ZkInfoReq req);
}
... ...
... ... @@ -2,7 +2,6 @@ package com.monitor.cmdb.service.impl;
import com.monitor.cmdb.service.IZkMoitorService;
import com.monitor.influxdb.mapper.IZkMapper;
import com.monitor.influxdb.model.ZkInfo;
import com.monitor.model.domain.PageBean;
import com.monitor.model.request.ZkInfoReq;
import com.monitor.model.response.PageResponse;
... ... @@ -10,7 +9,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
... ... @@ -27,7 +25,7 @@ public class ZkMoitorServiceImpl implements IZkMoitorService {
IZkMapper zkMapper;
@Override
public PageResponse<ZkInfo> getZkMonitorRecords(ZkInfoReq req) {
public PageResponse<Object> getZkMonitorRecords(ZkInfoReq req) {
logger.info("getHostInfos with param is {}", req);
// 组装分页对象
PageBean page = PageBean.initPageInfo(req.getCurrentPage(),
... ... @@ -42,16 +40,16 @@ public class ZkMoitorServiceImpl implements IZkMoitorService {
return null;
}
// 获取列表
List<ZkInfo> zkInfos = zkMapper.selectZkInfosByCodition(page);
if (CollectionUtils.isEmpty(zkInfos)) {
logger.debug("getHostInfos is null with param is {}", req);
List<?> zkInfos = zkMapper.selectZkInfosByCodition(page);
if (zkInfos==null) {
logger.debug("selectZkInfosByCodition is null with param is {}", page);
return null;
}
PageResponse<ZkInfo> response = new PageResponse<ZkInfo>();
PageResponse<Object> response = new PageResponse<Object>();
response.setCurrentPage(req.getCurrentPage());
response.setPageSize(req.getPageSize());
response.setTotal(total);
response.setRows(zkInfos);
response.setRows((List<Object>) zkInfos);
return response;
}
}
... ...
... ... @@ -14,5 +14,5 @@ public interface IZkMapper {
public int selectCountByCodition(PageBean page);
List<ZkInfo> selectZkInfosByCodition(PageBean page);
List<List<Object>> selectZkInfosByCodition(PageBean page);
}
... ...
package com.monitor.influxdb.mapper.impl;
import com.monitor.common.contants.InfluxDBContants;
import com.monitor.common.util.QueryResultUtil;
import com.monitor.influxdb.InfluxDBModel;
import com.monitor.influxdb.InfluxDBQuery;
import com.monitor.influxdb.InluxDBSingle;
... ... @@ -70,13 +71,13 @@ public class ZkMapper extends InfluxDBQuery implements IZkMapper {
}
InfluxDBModel influxDBModel= inluxDBSingle.getInfluxDBByName(InfluxDBContants.ALARM);
QueryResult result= query(influxDBModel.getName(), command.toString(), InfluxDBContants.MIDDLEWARE_ALARM);
return 1;
return QueryResultUtil.getCount(result);
}
@Override
public List<ZkInfo> selectZkInfosByCodition(PageBean page) {
public List<List<Object>> selectZkInfosByCodition(PageBean page) {
StringBuffer command=new StringBuffer();
command.append("SELECT hostIp,isLive,time FROM "+InfluxDBContants.ZOOKEEPER_ALARM) .append( " where 1=1") ;
command.append("SELECT hostIp,isLive,time FROM "+InfluxDBContants.ZOOKEEPER_ALARM) ;
String hostIp=(String)page.getParams().get("hostIP");
int flag=0;
if(StringUtils.isNotBlank(hostIp)){
... ... @@ -99,9 +100,9 @@ public class ZkMapper extends InfluxDBQuery implements IZkMapper {
command.append("where and time="+isLive);
}
}
command.append("' ORDER BY time DESC LIMIT " + page.getPageSize() + " OFFSET " + page.getStartIndex());
command.append(" ORDER BY time DESC LIMIT " + page.getPageSize() + " OFFSET " + page.getStartIndex());
InfluxDBModel influxDBModel= inluxDBSingle.getInfluxDBByName(InfluxDBContants.ALARM);
QueryResult result= query(influxDBModel.getName(), command.toString(), InfluxDBContants.MIDDLEWARE_ALARM);
return null;
return QueryResultUtil.getValues(result);
}
}
... ...
... ... @@ -7,4 +7,8 @@ influxdb.user=yoho;root
influxdb.pwd=Yoho_9646;root
influxdb.connect.timeout=15;15
influxdb.read.timeout=40;40
influxdb.write.timeout=20;20
\ No newline at end of file
influxdb.write.timeout=20;20
aws.influxdb.url=http://123.206.79.151:8086
aws.influxdb.user=root
aws.influxdb.pwd=root
\ No newline at end of file
... ...