Skip to content

Commit 578d29e

Browse files
committed
Merge remote-tracking branch 'origin/4.13' into 4.14
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2 parents 14c0d9e + 5c29d5b commit 578d29e

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
<cs.guava.version>28.2-jre</cs.guava.version>
135135
<cs.httpclient.version>4.5.11</cs.httpclient.version>
136136
<cs.httpcore.version>4.4.13</cs.httpcore.version>
137-
<cs.influxdb-java.version>2.17</cs.influxdb-java.version>
137+
<cs.influxdb-java.version>2.20</cs.influxdb-java.version>
138138
<cs.jackson.version>2.10.3</cs.jackson.version>
139139
<cs.jasypt.version>1.9.3</cs.jasypt.version>
140140
<cs.java-ipv6.version>0.17</cs.java-ipv6.version>

server/src/main/java/com/cloud/server/StatsCollector.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,21 +1334,25 @@ abstract class AbstractStatsCollector extends ManagedContextRunnable {
13341334
protected void sendMetricsToInfluxdb(Map<Object, Object> metrics) {
13351335
InfluxDB influxDbConnection = createInfluxDbConnection();
13361336

1337-
Pong response = influxDbConnection.ping();
1338-
if (response.getVersion().equalsIgnoreCase("unknown")) {
1339-
throw new CloudRuntimeException(String.format("Cannot ping influxdb host %s:%s.", externalStatsHost, externalStatsPort));
1340-
}
1337+
try {
1338+
Pong response = influxDbConnection.ping();
1339+
if (response.getVersion().equalsIgnoreCase("unknown")) {
1340+
throw new CloudRuntimeException(String.format("Cannot ping influxdb host %s:%s.", externalStatsHost, externalStatsPort));
1341+
}
13411342

1342-
Collection<Object> metricsObjects = metrics.values();
1343-
List<Point> points = new ArrayList<>();
1343+
Collection<Object> metricsObjects = metrics.values();
1344+
List<Point> points = new ArrayList<>();
13441345

1345-
s_logger.debug(String.format("Sending stats to %s host %s:%s", externalStatsType, externalStatsHost, externalStatsPort));
1346+
s_logger.debug(String.format("Sending stats to %s host %s:%s", externalStatsType, externalStatsHost, externalStatsPort));
13461347

1347-
for (Object metricsObject : metricsObjects) {
1348-
Point vmPoint = creteInfluxDbPoint(metricsObject);
1349-
points.add(vmPoint);
1348+
for (Object metricsObject : metricsObjects) {
1349+
Point vmPoint = creteInfluxDbPoint(metricsObject);
1350+
points.add(vmPoint);
1351+
}
1352+
writeBatches(influxDbConnection, databaseName, points);
1353+
} finally {
1354+
influxDbConnection.close();
13501355
}
1351-
writeBatches(influxDbConnection, databaseName, points);
13521356
}
13531357

13541358
/**
@@ -1521,7 +1525,9 @@ protected InfluxDB createInfluxDbConnection() {
15211525
*/
15221526
protected void writeBatches(InfluxDB influxDbConnection, String dbName, List<Point> points) {
15231527
BatchPoints batchPoints = BatchPoints.database(dbName).build();
1524-
influxDbConnection.enableBatch(BatchOptions.DEFAULTS);
1528+
if(!influxDbConnection.isBatchEnabled()){
1529+
influxDbConnection.enableBatch(BatchOptions.DEFAULTS);
1530+
}
15251531

15261532
for (Point point : points) {
15271533
batchPoints.point(point);

0 commit comments

Comments
 (0)