Skip to content

Commit d567e7c

Browse files
committed
New enableBatch method
1 parent 87487a0 commit d567e7c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/main/java/org/influxdb/InfluxDB.java

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.influxdb.dto.Pong;
1111
import org.influxdb.dto.Query;
1212
import org.influxdb.dto.QueryResult;
13+
import org.influxdb.impl.BatchProcessor;
1314

1415
/**
1516
* Interface with all available methods to access a InfluxDB database.
@@ -93,6 +94,14 @@ public String value() {
9394
*/
9495
public boolean isGzipEnabled();
9596

97+
/**
98+
* Enable batching of single Point writes as {@link #enableBatch(int, int, TimeUnit, ThreadFactory)}}
99+
* and {@link #enableBatch(int, int, TimeUnit, ThreadFactory)} with a given {@link org.influxdb.impl.BatchProcessor}
100+
*
101+
* @see org.influxdb.impl.BatchProcessor
102+
*/
103+
public InfluxDB enableBatch(final BatchProcessor batchProcessor);
104+
96105
/**
97106
* Enable batching of single Point writes as {@link #enableBatch(int, int, TimeUnit, ThreadFactory)}}
98107
* using {@linkplain java.util.concurrent.Executors#defaultThreadFactory() default thread factory}.

src/main/java/org/influxdb/impl/InfluxDBImpl.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ public boolean isGzipEnabled() {
150150
return this.gzipRequestInterceptor.isEnabled();
151151
}
152152

153+
@Override
154+
public InfluxDB enableBatch(BatchProcessor batchProcessor) {
155+
this.batchProcessor = batchProcessor;
156+
this.batchEnabled.set(true);
157+
return this;
158+
}
159+
153160
@Override
154161
public InfluxDB enableBatch(final int actions, final int flushDuration,
155162
final TimeUnit flushDurationTimeUnit) {
@@ -163,13 +170,13 @@ public InfluxDB enableBatch(final int actions, final int flushDuration,
163170
if (this.batchEnabled.get()) {
164171
throw new IllegalStateException("BatchProcessing is already enabled.");
165172
}
166-
this.batchProcessor = BatchProcessor
173+
BatchProcessor batchProcessor = BatchProcessor
167174
.builder(this)
168175
.actions(actions)
169176
.interval(flushDuration, flushDurationTimeUnit)
170177
.threadFactory(threadFactory)
171178
.build();
172-
this.batchEnabled.set(true);
179+
enableBatch(batchProcessor);
173180
return this;
174181
}
175182

0 commit comments

Comments
 (0)