use of org.influxdb.dto.Point in project camel by apache.
the class InfluxDbProducerBatchTest method createBatchPoints.
private BatchPoints createBatchPoints() {
BatchPoints batchPoints = BatchPoints.database("myTestTimeSeries").build();
Point point1 = Point.measurement("cpu").time(System.currentTimeMillis(), TimeUnit.MILLISECONDS).addField("idle", 90L).addField("user", 9L).addField("system", 1L).build();
Point point2 = Point.measurement("disk").time(System.currentTimeMillis(), TimeUnit.MILLISECONDS).addField("used", 8L).addField("free", 1L).build();
batchPoints.point(point1);
batchPoints.point(point2);
return batchPoints;
}
use of org.influxdb.dto.Point in project camel by apache.
the class CamelInfluxDbConverterTest method doesNotAddCamelHeaders.
@Test
public void doesNotAddCamelHeaders() {
Map<String, Object> pointInMapFormat = new HashMap<>();
pointInMapFormat.put(InfluxDbConstants.MEASUREMENT_NAME, "testCPU");
double value = 99.999999d;
pointInMapFormat.put("busy", value);
Point p = CamelInfluxDbConverters.fromMapToPoint(pointInMapFormat);
assertNotNull(p);
String line = p.lineProtocol();
assertNotNull(line);
LOG.debug("doesNotAddCamelHeaders generated: \"{}\"", line);
assertTrue(!line.contains(InfluxDbConstants.MEASUREMENT_NAME));
}
use of org.influxdb.dto.Point in project camel by apache.
the class CamelInfluxDbConverterTest method canAddDouble.
@Test
public void canAddDouble() {
Map<String, Object> pointInMapFormat = new HashMap<>();
pointInMapFormat.put(InfluxDbConstants.MEASUREMENT_NAME, "testCPU");
double value = 99.999999d;
pointInMapFormat.put("busy", value);
Point p = CamelInfluxDbConverters.fromMapToPoint(pointInMapFormat);
assertNotNull(p);
String line = p.lineProtocol();
assertNotNull(line);
LOG.debug("Doublecommand generated: \"{}\"", line);
assertTrue(line.contains("busy=99.999999"));
}
use of org.influxdb.dto.Point in project jmxtrans by jmxtrans.
the class InfluxDbWriterTests method pointsAreWrittenToInfluxDb.
@Test
public void pointsAreWrittenToInfluxDb() throws Exception {
InfluxDbWriter writer = getTestInfluxDbWriterWithDefaultSettings();
writer.doWrite(dummyServer(), dummyQuery(), results);
verify(influxDB).write(messageCaptor.capture());
BatchPoints batchPoints = messageCaptor.getValue();
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>
Map<String, String> expectedTags = new TreeMap<String, String>();
expectedTags.put(enumValueToAttribute(ResultAttribute.ATTRIBUTE_NAME), result.getAttributeName());
expectedTags.put(enumValueToAttribute(ResultAttribute.CLASS_NAME), result.getClassName());
expectedTags.put(enumValueToAttribute(ResultAttribute.OBJ_DOMAIN), result.getObjDomain());
expectedTags.put(enumValueToAttribute(ResultAttribute.TYPE_NAME), result.getTypeName());
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.Point in project jmxtrans by jmxtrans.
the class InfluxDbWriterTests method emptyCustomTagsDoesntBotherWrite.
@Test
public void emptyCustomTagsDoesntBotherWrite() throws Exception {
InfluxDbWriter writer = getTestInfluxDbWriterWithDefaultSettings();
writer.doWrite(dummyServer(), dummyQuery(), results);
verify(influxDB).write(messageCaptor.capture());
BatchPoints batchPoints = messageCaptor.getValue();
assertThat(batchPoints.getDatabase()).isEqualTo(DATABASE_NAME);
List<Point> points = batchPoints.getPoints();
assertThat(points).hasSize(1);
}
Aggregations