|
|
package com.monitor.influxdb.mapper.impl;
|
|
|
|
|
|
import com.monitor.common.contants.InfluxDBContants;
|
|
|
import com.monitor.influxdb.InfluxDBQuery;
|
|
|
import com.monitor.influxdb.InluxDBSingle;
|
|
|
import com.monitor.influxdb.mapper.IZookeeperMapper;
|
|
|
import com.monitor.influxdb.model.ZookeeperInfo;
|
|
|
import org.influxdb.dto.BatchPoints;
|
|
|
import com.monitor.influxdb.mapper.IZkMapper;
|
|
|
import com.monitor.influxdb.model.ZkInfo;
|
|
|
import com.monitor.model.domain.PageBean;
|
|
|
import org.influxdb.dto.Point;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Random;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
...
|
...
|
@@ -16,15 +18,16 @@ import java.util.concurrent.TimeUnit; |
|
|
* Created by yoho on 2016/6/21.
|
|
|
*/
|
|
|
@Component
|
|
|
public class ZookeeperMapper implements IZookeeperMapper{
|
|
|
public class ZkMapper extends InfluxDBQuery implements IZkMapper {
|
|
|
|
|
|
@Autowired
|
|
|
private InluxDBSingle inluxDBSingle;
|
|
|
|
|
|
|
|
|
Random random = new Random();
|
|
|
|
|
|
@Override
|
|
|
public void insert(ZookeeperInfo zkInfo) {
|
|
|
public void insert(ZkInfo zkInfo) {
|
|
|
|
|
|
Point point = Point.measurement(InfluxDBContants.ZOOKEEPER_ALARM)
|
|
|
.addField("id", zkInfo.getId())
|
...
|
...
|
@@ -36,4 +39,22 @@ public class ZookeeperMapper implements IZookeeperMapper{ |
|
|
.write(InfluxDBContants.MIDDLEWARE_ALARM, "default", point);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int selectCountByCodition(PageBean page) {
|
|
|
String command = "SELECT COUNT(id) FROM "+InfluxDBContants.ZOOKEEPER_ALARM;
|
|
|
return query(influxDBName, command, InfluxDBContants.ZOOKEEPER_ALARM,
|
|
|
"ZkMapper", "selectCountByCodition");
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<ZkInfo> selectZkInfosByCodition(PageBean page) {
|
|
|
String command="SELECT id, hostIp, isLive from "+InfluxDBContants.ZOOKEEPER_ALARM+
|
|
|
" ORDER BY time DESC LIMIT " + page.getParams().get("pageSize") +
|
|
|
" OFFSET " + page.getParams().get("startIndex");
|
|
|
|
|
|
return query(influxDBName, command, InfluxDBContants.ZOOKEEPER_ALARM,
|
|
|
"ZkMapper", "selectZkInfosByCodition");
|
|
|
}
|
|
|
} |
...
|
...
|
|