From b8db4a786ac5364a673223d373f6dad509fef35b Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Thu, 14 Jan 2021 14:22:42 +0100 Subject: [PATCH] Disable automatic influx batch writes. --- src/main/java/biz/nellemann/hmci/InfluxClient.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/biz/nellemann/hmci/InfluxClient.java b/src/main/java/biz/nellemann/hmci/InfluxClient.java index ededbae..32d6ba2 100644 --- a/src/main/java/biz/nellemann/hmci/InfluxClient.java +++ b/src/main/java/biz/nellemann/hmci/InfluxClient.java @@ -36,6 +36,10 @@ class InfluxClient { private final static Logger log = LoggerFactory.getLogger(InfluxClient.class); + private static final int BATCH_ACTIONS_LIMIT = 5000; + private static final int BATCH_INTERVAL_DURATION = 1000; + + final private String url; final private String username; final private String password; @@ -67,14 +71,8 @@ class InfluxClient { log.debug("Connecting to InfluxDB - " + url); influxDB = InfluxDBFactory.connect(url, username, password); createDatabase(); - - // Enable batch writes to get better performance. - BatchOptions options = BatchOptions.DEFAULTS.actions(1000).flushDuration(5000).precision(TimeUnit.SECONDS); - influxDB.enableBatch(options); batchPoints = BatchPoints.database(database).precision(TimeUnit.SECONDS).build(); - connected = true; - } catch(Exception e) { sleep(15 * 1000); if(errors++ > 3) { @@ -107,7 +105,7 @@ class InfluxClient { synchronized void writeBatchPoints() throws Exception { log.debug("writeBatchPoints()"); try { - influxDB.write(batchPoints); + influxDB.writeWithRetry(batchPoints); } catch(Exception e) { log.error("writeBatchPoints() error - " + e.getMessage()); logoff();