Skip to content

Commit 817251f

Browse files
lucas-a-martinsLucas Martins
andauthored
Enhancement in the accuracy of the logs regarding the capacity, usage, and threshold of secondary storages (#9043)
Co-authored-by: Lucas Martins <lucas.martins@scclouds.com.br>
1 parent dc1556c commit 817251f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@
6464
import org.apache.cloudstack.utils.usage.UsageUtils;
6565
import org.apache.commons.collections.CollectionUtils;
6666
import org.apache.commons.collections.MapUtils;
67-
import org.apache.commons.io.FileUtils;
6867
import org.apache.commons.lang3.BooleanUtils;
6968
import org.apache.commons.lang3.StringUtils;
7069
import org.apache.commons.lang3.time.DateUtils;
70+
import org.apache.logging.log4j.Level;
7171
import org.influxdb.BatchOptions;
7272
import org.influxdb.InfluxDB;
7373
import org.influxdb.InfluxDBFactory;
@@ -1714,7 +1714,8 @@ protected void runInContext() {
17141714
pool.setCapacityBytes(capacityBytes);
17151715
poolNeedsUpdating = true;
17161716
} else {
1717-
logger.warn("Not setting capacity bytes, received " + ((StorageStats)answer).getCapacityBytes() + " capacity for pool ID " + poolId);
1717+
logger.warn("Not setting capacity bytes, received {} capacity for pool ID {}",
1718+
NumbersUtil.toReadableSize(((StorageStats)answer).getCapacityBytes()), poolId);
17181719
}
17191720
}
17201721
if (((_storagePoolStats.get(poolId) != null && _storagePoolStats.get(poolId).getByteUsed() != usedBytes)
@@ -1831,16 +1832,15 @@ public boolean imageStoreHasEnoughCapacity(DataStore imageStore) {
18311832
double totalCapacity = imageStoreStats.getCapacityBytes();
18321833
double usedCapacity = imageStoreStats.getByteUsed();
18331834
double threshold = getImageStoreCapacityThreshold();
1834-
String readableTotalCapacity = FileUtils.byteCountToDisplaySize((long) totalCapacity);
1835-
String readableUsedCapacity = FileUtils.byteCountToDisplaySize((long) usedCapacity);
1836-
1837-
logger.debug(String.format("Verifying image storage [%s]. Capacity: total=[%s], used=[%s], threshold=[%s%%].", imageStoreId, readableTotalCapacity, readableUsedCapacity, threshold * 100));
1835+
String readableTotalCapacity = NumbersUtil.toReadableSize((long) totalCapacity);
1836+
String readableUsedCapacity = NumbersUtil.toReadableSize((long) usedCapacity);
18381837

1838+
logger.printf(Level.DEBUG, "Verifying image storage [%s]. Capacity: total=[%s], used=[%s], threshold=[%.2f%%].", imageStoreId, readableTotalCapacity, readableUsedCapacity, threshold * 100);
18391839
if (usedCapacity / totalCapacity <= threshold) {
18401840
return true;
18411841
}
18421842

1843-
logger.warn(String.format("Image storage [%s] has not enough capacity. Capacity: total=[%s], used=[%s], threshold=[%s%%].", imageStoreId, readableTotalCapacity, readableUsedCapacity, threshold * 100));
1843+
logger.printf(Level.WARN, "Image storage [%s] has not enough capacity. Capacity: total=[%s], used=[%s], threshold=[%.2f%%].", imageStoreId, readableTotalCapacity, readableUsedCapacity, threshold * 100);
18441844
return false;
18451845
}
18461846

0 commit comments

Comments
 (0)