Retry login to InfluxDB.
Bumped version.
This commit is contained in:
parent
13a34b0412
commit
f4e9e9ab69
11
README.md
11
README.md
|
@ -51,7 +51,16 @@ Below are screenshots of the provided Grafana dashboards (found in the **doc/**
|
|||
|
||||
## Notes
|
||||
|
||||
### InfluxDB
|
||||
### Start InfluxDB and Grafana at boot on RedHat 7+
|
||||
|
||||
systemctl enable influxdb
|
||||
systemctl start influxdb
|
||||
|
||||
systemctl enable grafana-server
|
||||
systemctl start grafana-server
|
||||
|
||||
|
||||
### InfluxDB Retention Policy
|
||||
|
||||
Per default the *hmci* influx database has no retention policy, so data will be kept forever. It is recommended to set a retention policy, which is shown below.
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
id = hmci
|
||||
group = biz.nellemann.hmci
|
||||
version = 0.2.7
|
||||
version = 0.2.8
|
||||
|
|
|
@ -30,6 +30,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static java.lang.Thread.sleep;
|
||||
|
||||
class InfluxClient {
|
||||
|
||||
private final static Logger log = LoggerFactory.getLogger(InfluxClient.class);
|
||||
|
@ -57,20 +59,33 @@ class InfluxClient {
|
|||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
log.debug("Connecting to InfluxDB - " + url);
|
||||
influxDB = InfluxDBFactory.connect(url, username, password);
|
||||
createDatabase();
|
||||
boolean connected = false;
|
||||
int errors = 0;
|
||||
|
||||
// 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();
|
||||
do {
|
||||
try {
|
||||
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) {
|
||||
log.error("login() error, giving up - " + e.getMessage());
|
||||
throw new Exception(e);
|
||||
} else {
|
||||
log.warn("login() error, retrying - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
} while(!connected);
|
||||
|
||||
} catch(Exception e) {
|
||||
log.error("login() error - " + e.getMessage());
|
||||
throw new Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ package biz.nellemann.hmci;
|
|||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -38,11 +37,10 @@ class Insights {
|
|||
|
||||
Insights(Configuration configuration) {
|
||||
this.configuration = configuration;
|
||||
|
||||
try {
|
||||
influxClient = new InfluxClient(configuration.influx);
|
||||
influxClient.login();
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue