1
|
package com.monitor.influxdb.mapper.impl;
|
1
|
package com.monitor.influxdb.mapper.impl;
|
2
|
|
2
|
|
|
|
3
|
+import com.monitor.common.contants.InfluxDBContants;
|
3
|
import com.monitor.influxdb.InluxDBSingle;
|
4
|
import com.monitor.influxdb.InluxDBSingle;
|
4
|
import com.monitor.influxdb.mapper.IZookeeperMapper;
|
5
|
import com.monitor.influxdb.mapper.IZookeeperMapper;
|
5
|
import com.monitor.influxdb.model.ZookeeperInfo;
|
6
|
import com.monitor.influxdb.model.ZookeeperInfo;
|
|
|
7
|
+import org.influxdb.dto.BatchPoints;
|
|
|
8
|
+import org.influxdb.dto.Point;
|
6
|
import org.springframework.beans.factory.annotation.Autowired;
|
9
|
import org.springframework.beans.factory.annotation.Autowired;
|
7
|
import org.springframework.stereotype.Component;
|
10
|
import org.springframework.stereotype.Component;
|
8
|
|
11
|
|
|
|
12
|
+import java.util.Random;
|
|
|
13
|
+import java.util.concurrent.TimeUnit;
|
|
|
14
|
+
|
9
|
/**
|
15
|
/**
|
10
|
* Created by yoho on 2016/6/21.
|
16
|
* Created by yoho on 2016/6/21.
|
11
|
*/
|
17
|
*/
|
|
@@ -15,8 +21,19 @@ public class ZookeeperMapper implements IZookeeperMapper{ |
|
@@ -15,8 +21,19 @@ public class ZookeeperMapper implements IZookeeperMapper{ |
15
|
@Autowired
|
21
|
@Autowired
|
16
|
private InluxDBSingle inluxDBSingle;
|
22
|
private InluxDBSingle inluxDBSingle;
|
17
|
|
23
|
|
|
|
24
|
+ Random random = new Random();
|
|
|
25
|
+
|
18
|
@Override
|
26
|
@Override
|
19
|
public void insert(String influxDBName, ZookeeperInfo zkInfo) {
|
27
|
public void insert(String influxDBName, ZookeeperInfo zkInfo) {
|
20
|
|
28
|
|
|
|
29
|
+ Point point = Point.measurement(InfluxDBContants.ZOOKEEPER_ALARM)
|
|
|
30
|
+ .addField("id", zkInfo.getId())
|
|
|
31
|
+ .addField("hostIp", zkInfo.getHostIp())
|
|
|
32
|
+ .addField("isLive", zkInfo.getIsLive())
|
|
|
33
|
+ .time(System.currentTimeMillis() * 1000000 + random.nextInt(999999), TimeUnit.NANOSECONDS)
|
|
|
34
|
+ .build();
|
|
|
35
|
+ inluxDBSingle.getInfluxDBByName(InfluxDBContants.ALARM).getInfluxDB()
|
|
|
36
|
+ .write(InfluxDBContants.MIDDLEWARE_ALARM, "default", point);
|
|
|
37
|
+
|
21
|
}
|
38
|
}
|
22
|
} |
39
|
} |