use of org.influxdb.dto.BatchPoints in project jmxtrans by jmxtrans.
the class InfluxDbWriterTests method writeConsistencyLevelsAreAppliedToBatchPointsBeingWritten.
@Test
public void writeConsistencyLevelsAreAppliedToBatchPointsBeingWritten() throws Exception {
for (ConsistencyLevel consistencyLevel : ConsistencyLevel.values()) {
BatchPoints batchPoints = writeAtLeastOnceToInfluxDb(getTestInfluxDbWriterWithWriteConsistency(consistencyLevel));
assertThat(batchPoints.getConsistency()).isEqualTo(consistencyLevel);
}
}
use of org.influxdb.dto.BatchPoints in project jmxtrans by jmxtrans.
the class InfluxDbWriterTests method pointsAreWrittenToInfluxDb.
@Test
public void pointsAreWrittenToInfluxDb() throws Exception {
BatchPoints batchPoints = writeToInfluxDb(getTestInfluxDbWriterWithDefaultSettings());
// The database name is present
assertThat(batchPoints.getDatabase()).isEqualTo(DATABASE_NAME);
// Point only exposes its state via a line protocol so we have to
// make assertions against this.
// Format is:
// measurement,<comma separated key=val tags>" " <comma separated
// key=val fields>" "time
Map<String, String> expectedTags = new TreeMap<String, String>();
expectedTags.put(ResultAttributes.ATTRIBUTE_NAME.getName(), result.getAttributeName());
expectedTags.put(ResultAttributes.CLASS_NAME.getName(), result.getClassName());
expectedTags.put(ResultAttributes.OBJ_DOMAIN.getName(), result.getObjDomain());
expectedTags.put(TAG_HOSTNAME, HOST);
String lineProtocol = buildLineProtocol(result.getKeyAlias(), expectedTags);
List<Point> points = batchPoints.getPoints();
assertThat(points).hasSize(1);
Point point = points.get(0);
assertThat(point.lineProtocol()).startsWith(lineProtocol);
}
use of org.influxdb.dto.BatchPoints in project jmxtrans by jmxtrans.
the class InfluxDbWriterTests method jmxPortIsReportedAsTag.
@Test
public void jmxPortIsReportedAsTag() throws Exception {
BatchPoints batchPoints = writeToInfluxDb(getTestInfluxDbWriterWithReportJmxPortAsTag());
verifyJMXPortOnlyInToken(batchPoints.getPoints().get(0).lineProtocol(), 0);
}
use of org.influxdb.dto.BatchPoints in project jmxtrans by jmxtrans.
the class InfluxDbWriterTests method valueString.
@Test
public void valueString() throws Exception {
InfluxDbWriter writer = getTestInfluxDbWriterWithStringValue();
writer.doWrite(dummyServer(), dummyQuery(), resultsStr);
verify(influxDB).write(messageCaptor.capture());
BatchPoints batchPoints = messageCaptor.getValue();
assertThat(batchPoints.getDatabase()).isEqualTo(DATABASE_NAME);
List<Point> points = batchPoints.getPoints();
assertThat(points).hasSize(1);
Point point = points.get(0);
assertThat(point.lineProtocol()).contains("key=\"hello\"");
}
use of org.influxdb.dto.BatchPoints in project weicoder by wdcode.
the class Influx method insertMany.
/**
* 批量插入
*
* @param measurement 表
* @param tagsfieldsList 标签字段列表
*/
public void insertMany(String measurement, List<Map<Map<String, String>, Map<String, Object>>> tagsfieldsList) {
// 声明BatchPoints
BatchPoints batchPoints = BatchPoints.database(database).consistency(ConsistencyLevel.ONE).precision(TimeUnit.MILLISECONDS).build();
// 设置标签字段.
tagsfieldsList.forEach(tf -> tf.forEach((k, v) -> batchPoints.point(Point.measurement(measurement).tag(k).fields(v).build())));
// 写数据
db.write(batchPoints);
}
Aggregations