Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<cs.guava.version>23.6-jre</cs.guava.version>
<cs.httpclient.version>4.5.4</cs.httpclient.version>
<cs.httpcore.version>4.4.8</cs.httpcore.version>
<cs.influxdb-java.version>2.15</cs.influxdb-java.version>
<cs.influxdb-java.version>2.20</cs.influxdb-java.version>
<cs.jackson.version>2.9.2</cs.jackson.version>
<cs.jasypt.version>1.9.2</cs.jasypt.version>
<cs.java-ipv6.version>0.16</cs.java-ipv6.version>
Expand Down
30 changes: 18 additions & 12 deletions server/src/main/java/com/cloud/server/StatsCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -1334,21 +1334,25 @@ abstract class AbstractStatsCollector extends ManagedContextRunnable {
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<>();
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));
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);
for (Object metricsObject : metricsObjects) {
Point vmPoint = creteInfluxDbPoint(metricsObject);
points.add(vmPoint);
}
writeBatches(influxDbConnection, databaseName, points);
} finally {
influxDbConnection.close();
}
writeBatches(influxDbConnection, databaseName, points);
}

/**
Expand Down Expand Up @@ -1507,7 +1511,9 @@ protected InfluxDB createInfluxDbConnection() {
*/
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);
Expand Down