Java Code Examples for org.influxdb.dto.BatchPoints#Builder
The following examples show how to use
org.influxdb.dto.BatchPoints#Builder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BatchDAO.java From skywalking with Apache License 2.0 | 6 votes |
@Override public void synchronous(List<PrepareRequest> prepareRequests) { if (CollectionUtils.isEmpty(prepareRequests)) { return; } if (log.isDebugEnabled()) { log.debug("batch sql statements execute, data size: {}", prepareRequests.size()); } final BatchPoints.Builder builder = BatchPoints.builder(); prepareRequests.forEach(e -> { builder.point(((InfluxInsertRequest) e).getPoint()); }); client.write(builder.build()); }
Example 2
Source File: InfluxDBAbstractSink.java From pulsar with Apache License 2.0 | 5 votes |
@Override protected void writePoints(List<Point> points) throws Exception { BatchPoints.Builder batchBuilder = BatchPoints .database(influxDatabase) .retentionPolicy(retentionPolicy) .consistency(consistencyLevel); points.forEach((batchBuilder::point)); influxDB.write(batchBuilder.build()); }
Example 3
Source File: InfluxDBPusher.java From incubator-gobblin with Apache License 2.0 | 5 votes |
/** * Push multiple points at once. * @param points list of {@link Point}s to report */ public void push(List<Point> points) { BatchPoints.Builder batchPointsBuilder = BatchPoints.database(database); for (Point point : points) { batchPointsBuilder.point(point); } influxDB.write(batchPointsBuilder.build()); }
Example 4
Source File: RetryCapableBatchWriterTest.java From influxdb-java with MIT License | 5 votes |
BatchPoints getBP(int count) { BatchPoints.Builder b = BatchPoints.database("d1"); for (int i = 0; i < count; i++) { b.point(Point.measurement("x1").addField("x", 1).build()).build(); } return b.build(); }
Example 5
Source File: InfluxDBPusher.java From incubator-gobblin with Apache License 2.0 | 4 votes |
/** * Push a single Point * @param point the {@link Point} to report */ public void push(Point point) { BatchPoints.Builder batchPointsBuilder = BatchPoints.database(database); batchPointsBuilder.point(point); influxDB.write(batchPointsBuilder.build()); }
Example 6
Source File: RetryCapableBatchWriterTest.java From influxdb-java with MIT License | 4 votes |
@Test public void testRetryingKeepChronologicalOrder() { BatchPoints.Builder b = BatchPoints.database("d1"); for (int i = 0; i < 200; i++) { b.point(Point.measurement("x1").time(1,TimeUnit.HOURS). addField("x", 1). tag("t", "v1").build()).build(); } BatchPoints bp1 = b.build(); b = BatchPoints.database("d1"); b.point(Point.measurement("x1").time(1,TimeUnit.HOURS). addField("x", 2). tag("t", "v2").build()).build(); for (int i = 0; i < 199; i++) { b.point(Point.measurement("x1").time(2,TimeUnit.HOURS). addField("x", 2). tag("t", "v2").build()).build(); } BatchPoints bp2 = b.build(); InfluxDB mockInfluxDB = mock(InfluxDB.class); BiConsumer<Iterable<Point>, Throwable> errorHandler = mock(BiConsumer.class); RetryCapableBatchWriter rw = new RetryCapableBatchWriter(mockInfluxDB, errorHandler, 450, 150); doAnswer(new TestAnswer() { int i = 0; @Override protected void check(InvocationOnMock invocation) { if (i++ < 1) { throw InfluxDBException.buildExceptionForErrorState("cache-max-memory-size exceeded 104/1400"); } return; } }).when(mockInfluxDB).write(any(BatchPoints.class)); rw.write(Collections.singletonList(bp1)); rw.write(Collections.singletonList(bp2)); ArgumentCaptor<BatchPoints> captor4Write = ArgumentCaptor.forClass(BatchPoints.class); verify(mockInfluxDB, times(3)).write(captor4Write.capture()); //bp1 written but failed because of recoverable cache-max-memory-size error Assertions.assertEquals(bp1, captor4Write.getAllValues().get(0)); //bp1 rewritten on writing of bp2 Assertions.assertEquals(bp1, captor4Write.getAllValues().get(1)); //bp2 written Assertions.assertEquals(bp2, captor4Write.getAllValues().get(2)); }
Example 7
Source File: Points.java From camel-quarkus with Apache License 2.0 | 3 votes |
public BatchPoints toBatchPoints() { BatchPoints.Builder batchPoints = BatchPoints.database(this.database); points.forEach(p -> batchPoints.point(p.toPoint())); return batchPoints.build(); }