use of org.influxdb.dto.BatchPoints 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);
}
use of org.influxdb.dto.BatchPoints in project camel by apache.
the class InfluxDbProducerBatchTest method writeBatchPoints.
@Test
public void writeBatchPoints() throws InterruptedException {
errorEndpoint.expectedMessageCount(0);
successEndpoint.expectedMessageCount(1);
BatchPoints batchPoints = createBatchPoints();
sendBody("direct:test", batchPoints);
errorEndpoint.assertIsSatisfied();
successEndpoint.assertIsSatisfied();
}
use of org.influxdb.dto.BatchPoints 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.BatchPoints in project oap by oaplatform.
the class InfluxDBReporter method report.
@Override
public synchronized void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) {
try {
final long time = DateTimeUtils.currentTimeMillis();
BatchPoints.Builder pointsBuilder = BatchPoints.database(database);
BatchPoints points = pointsBuilder.build();
final SortedMap<String, Point.Builder> builders = new TreeMap<>();
reportCounters(counters, builders);
reportMeters(meters, builders);
reportTimers(timers, builders);
reportGauges(gauges, builders);
reportHistograms(histograms, builders);
builders.values().forEach(b -> points.point(b.time(time, MILLISECONDS).build()));
logger.trace("reporting {} counters, {} meters, {} timers, {} gauges, {} histograms", counters.size(), meters.size(), timers.size(), gauges.size(), histograms);
influxDB.write(points);
} catch (Exception e) {
Throwable rootCause = Throwables.getRootCause(e);
if (rootCause instanceof SocketException || rootCause instanceof InterruptedIOException) {
logger.error(e.getMessage());
} else {
logger.error(e.getMessage(), e);
}
}
}
use of org.influxdb.dto.BatchPoints in project xDrip by NightscoutFoundation.
the class InfluxDBUploader method upload.
public boolean upload(List<BgReading> glucoseDataSets, List<Calibration> meterRecords, List<Calibration> calRecords) {
try {
BatchPoints batchPoints = BatchPoints.database(dbName).retentionPolicy("autogen").consistency(InfluxDB.ConsistencyLevel.ALL).build();
for (BgReading record : glucoseDataSets) {
if (record == null) {
Log.e(TAG, "InfluxDB glucose record is null");
continue;
}
batchPoints.point(createGlucosePoint(record));
}
for (Calibration record : meterRecords) {
if (record == null) {
Log.e(TAG, "InfluxDB meter record is null");
continue;
}
batchPoints.point(createMeterPoint(record));
}
for (Calibration record : calRecords) {
if (record == null) {
Log.e(TAG, "InfluxDB calibration record is null");
continue;
}
if (record.slope == 0d)
continue;
batchPoints.point(createCalibrationPoint(record));
}
try {
Log.d(TAG, "Influx url: " + dbUri);
InfluxDBFactory.connect(dbUri, dbUser, dbPassword, client).enableGzip().write(batchPoints);
last_error = null;
return true;
} catch (java.lang.ExceptionInInitializerError e) {
Log.e(TAG, "InfluxDB failed: " + e.getCause());
return false;
} catch (java.lang.NoClassDefFoundError e) {
Log.e(TAG, "InfluxDB failed more: " + e);
return false;
} catch (IllegalArgumentException e) {
Log.wtf(TAG, "InfluxDB problem: " + e);
return false;
} catch (Exception e) {
Log.e(TAG, "Write to InfluxDB failed: " + e);
last_error = e.getMessage();
return false;
}
} catch (Exception e) {
Log.wtf(TAG, "Exception during initialization: ", e);
return false;
}
}
Aggregations