Merge remote-tracking branch 'origin/4.14'

This commit is contained in:
Rohit Yadav 2020-09-01 16:02:33 +05:30
commit c7328652fd
2 changed files with 22 additions and 16 deletions

View File

@ -134,7 +134,7 @@
<cs.guava.version>28.2-jre</cs.guava.version>
<cs.httpclient.version>4.5.11</cs.httpclient.version>
<cs.httpcore.version>4.4.13</cs.httpcore.version>
<cs.influxdb-java.version>2.17</cs.influxdb-java.version>
<cs.influxdb-java.version>2.20</cs.influxdb-java.version>
<cs.jackson.version>2.10.3</cs.jackson.version>
<cs.jasypt.version>1.9.3</cs.jasypt.version>
<cs.java-ipv6.version>0.17</cs.java-ipv6.version>

View File

@ -1336,21 +1336,25 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
protected void sendMetricsToInfluxdb(Map<Object, Object> metrics) {
InfluxDB influxDbConnection = createInfluxDbConnection();
Pong response = influxDbConnection.ping();
if (response.getVersion().equalsIgnoreCase("unknown")) {
throw new CloudRuntimeException(String.format("Cannot ping influxdb host %s:%s.", externalStatsHost, externalStatsPort));
try {
Pong response = influxDbConnection.ping();
if (response.getVersion().equalsIgnoreCase("unknown")) {
throw new CloudRuntimeException(String.format("Cannot ping influxdb host %s:%s.", externalStatsHost, externalStatsPort));
}
Collection<Object> metricsObjects = metrics.values();
List<Point> points = new ArrayList<>();
s_logger.debug(String.format("Sending stats to %s host %s:%s", externalStatsType, externalStatsHost, externalStatsPort));
for (Object metricsObject : metricsObjects) {
Point vmPoint = creteInfluxDbPoint(metricsObject);
points.add(vmPoint);
}
writeBatches(influxDbConnection, databaseName, points);
} finally {
influxDbConnection.close();
}
Collection<Object> metricsObjects = metrics.values();
List<Point> points = new ArrayList<>();
s_logger.debug(String.format("Sending stats to %s host %s:%s", externalStatsType, externalStatsHost, externalStatsPort));
for (Object metricsObject : metricsObjects) {
Point vmPoint = creteInfluxDbPoint(metricsObject);
points.add(vmPoint);
}
writeBatches(influxDbConnection, databaseName, points);
}
/**
@ -1523,7 +1527,9 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
*/
protected void writeBatches(InfluxDB influxDbConnection, String dbName, List<Point> points) {
BatchPoints batchPoints = BatchPoints.database(dbName).build();
influxDbConnection.enableBatch(BatchOptions.DEFAULTS);
if(!influxDbConnection.isBatchEnabled()){
influxDbConnection.enableBatch(BatchOptions.DEFAULTS);
}
for (Point point : points) {
batchPoints.point(point);