|
|
package com.monitor.influxdb.mapper.impl;
|
|
|
|
|
|
import com.monitor.common.contants.InfluxDBContants;
|
|
|
import com.monitor.influxdb.InfluxDBModel;
|
|
|
import com.monitor.influxdb.InfluxDBQuery;
|
|
|
import com.monitor.influxdb.InluxDBSingle;
|
|
|
import com.monitor.influxdb.mapper.IZkMapper;
|
|
|
import com.monitor.influxdb.model.ZkInfo;
|
|
|
import com.monitor.model.domain.PageBean;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.influxdb.dto.Point;
|
|
|
import org.influxdb.dto.QueryResult;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
...
|
...
|
@@ -30,7 +33,6 @@ public class ZkMapper extends InfluxDBQuery implements IZkMapper { |
|
|
public void insert(ZkInfo zkInfo) {
|
|
|
|
|
|
Point point = Point.measurement(InfluxDBContants.ZOOKEEPER_ALARM)
|
|
|
.addField("id", zkInfo.getId())
|
|
|
.addField("hostIp", zkInfo.getHostIp())
|
|
|
.addField("isLive", zkInfo.getIsLive())
|
|
|
.time(System.currentTimeMillis() * 1000000 + random.nextInt(999999), TimeUnit.NANOSECONDS)
|
...
|
...
|
@@ -42,12 +44,64 @@ public class ZkMapper extends InfluxDBQuery implements IZkMapper { |
|
|
|
|
|
@Override
|
|
|
public int selectCountByCodition(PageBean page) {
|
|
|
String command = "SELECT COUNT(id) FROM "+InfluxDBContants.ZOOKEEPER_ALARM;
|
|
|
StringBuffer command=new StringBuffer();
|
|
|
command.append("SELECT COUNT(hostIp) FROM " + InfluxDBContants.ZOOKEEPER_ALARM) ;
|
|
|
String hostIp=(String)page.getParams().get("hostIP");
|
|
|
int flag=0;
|
|
|
if(StringUtils.isNotBlank(hostIp)){
|
|
|
flag=1;
|
|
|
command.append("where hostIp='"+hostIp+"'");
|
|
|
}
|
|
|
String time=(String)page.getParams().get("time");
|
|
|
if(StringUtils.isNotBlank(hostIp)){
|
|
|
if(flag==1){
|
|
|
command.append(" and time>'"+time+"'");
|
|
|
}else{
|
|
|
command.append(" where time>'"+time+"'");
|
|
|
}
|
|
|
}
|
|
|
String isLive=(String)page.getParams().get("isLive");
|
|
|
if(StringUtils.isNotBlank(hostIp)){
|
|
|
if(flag==1){
|
|
|
command.append(" and time="+isLive);
|
|
|
}else{
|
|
|
command.append("where and time="+isLive);
|
|
|
}
|
|
|
}
|
|
|
InfluxDBModel influxDBModel= inluxDBSingle.getInfluxDBByName(InfluxDBContants.ALARM);
|
|
|
QueryResult result= query(influxDBModel.getName(), command.toString(), InfluxDBContants.MIDDLEWARE_ALARM);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<ZkInfo> selectZkInfosByCodition(PageBean page) {
|
|
|
return null;
|
|
|
StringBuffer command=new StringBuffer();
|
|
|
command.append("SELECT hostIp,isLive,time FROM "+InfluxDBContants.ZOOKEEPER_ALARM) .append( " where 1=1") ;
|
|
|
String hostIp=(String)page.getParams().get("hostIP");
|
|
|
int flag=0;
|
|
|
if(StringUtils.isNotBlank(hostIp)){
|
|
|
flag=1;
|
|
|
command.append("where hostIp='"+hostIp+"'");
|
|
|
}
|
|
|
String time=(String)page.getParams().get("time");
|
|
|
if(StringUtils.isNotBlank(hostIp)){
|
|
|
if(flag==1){
|
|
|
command.append(" and time>'"+time+"'");
|
|
|
}else{
|
|
|
command.append(" where time>'"+time+"'");
|
|
|
}
|
|
|
}
|
|
|
String isLive=(String)page.getParams().get("isLive");
|
|
|
if(StringUtils.isNotBlank(hostIp)){
|
|
|
if(flag==1){
|
|
|
command.append(" and time="+isLive);
|
|
|
}else{
|
|
|
command.append("where and time="+isLive);
|
|
|
}
|
|
|
}
|
|
|
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;
|
|
|
}
|
|
|
} |
...
|
...
|
|