Improved error handling.
This commit is contained in:
parent
e0dc65a1e6
commit
02804232b0
|
@ -29,7 +29,7 @@ dependencies {
|
|||
implementation 'com.squareup.moshi:moshi:1.13.0'
|
||||
implementation 'com.serjltt.moshi:moshi-lazy-adapters:2.2'
|
||||
implementation 'org.tomlj:tomlj:1.0.0'
|
||||
implementation 'org.influxdb:influxdb-java:2.21'
|
||||
implementation 'org.influxdb:influxdb-java:2.22'
|
||||
implementation 'org.slf4j:slf4j-api:1.7.35'
|
||||
implementation 'org.slf4j:slf4j-simple:1.7.35'
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class HmcInstance implements Runnable {
|
|||
do {
|
||||
Instant instantStart = Instant.now();
|
||||
try {
|
||||
if(doEnergy) {
|
||||
if (doEnergy) {
|
||||
getMetricsForEnergy();
|
||||
}
|
||||
getMetricsForSystems();
|
||||
|
@ -107,9 +107,9 @@ class HmcInstance implements Runnable {
|
|||
executions = 0;
|
||||
discover();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("run()", e);
|
||||
log.error("run() - fatal error: {}", e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Instant instantEnd = Instant.now();
|
||||
|
|
|
@ -67,6 +67,7 @@ class InfluxClient {
|
|||
try {
|
||||
log.debug("Connecting to InfluxDB - {}", url);
|
||||
influxDB = InfluxDBFactory.connect(url, username, password).setDatabase(database);
|
||||
influxDB.version(); // This ensures that we actually try to connect to the db
|
||||
batchPoints = BatchPoints.database(database).precision(TimeUnit.SECONDS).build();
|
||||
connected = true;
|
||||
} catch(Exception e) {
|
||||
|
@ -95,8 +96,12 @@ class InfluxClient {
|
|||
log.trace("writeBatchPoints()");
|
||||
try {
|
||||
influxDB.writeWithRetry(batchPoints);
|
||||
errorCounter = 0;
|
||||
} catch (InfluxDBException.DatabaseNotFoundException e) {
|
||||
log.error("writeBatchPoints() - database \"{}\" not found/created: can't write data", database);
|
||||
if(++errorCounter > 3) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
log.warn("writeBatchPoints() {}", e.getMessage());
|
||||
|
|
Loading…
Reference in a new issue