|
|
package com.monitor.influxdb.mapper.impl;
|
|
|
|
|
|
import com.monitor.common.contants.InfluxDBContants;
|
|
|
import com.monitor.influxdb.InluxDBSingle;
|
|
|
import com.monitor.influxdb.mapper.IZookeeperMapper;
|
|
|
import com.monitor.influxdb.model.ZookeeperInfo;
|
|
|
import org.influxdb.dto.BatchPoints;
|
|
|
import org.influxdb.dto.Point;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Random;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* Created by yoho on 2016/6/21.
|
|
|
*/
|
...
|
...
|
@@ -15,8 +21,19 @@ public class ZookeeperMapper implements IZookeeperMapper{ |
|
|
@Autowired
|
|
|
private InluxDBSingle inluxDBSingle;
|
|
|
|
|
|
Random random = new Random();
|
|
|
|
|
|
@Override
|
|
|
public void insert(String influxDBName, ZookeeperInfo 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)
|
|
|
.build();
|
|
|
inluxDBSingle.getInfluxDBByName(InfluxDBContants.ALARM).getInfluxDB()
|
|
|
.write(InfluxDBContants.MIDDLEWARE_ALARM, "default", point);
|
|
|
|
|
|
}
|
|
|
} |
...
|
...
|
|