Merge branch 'main' into testing

This commit is contained in:
Michael Lipp 2025-03-18 16:45:07 +01:00
commit 8ee68c1109

View file

@ -313,7 +313,7 @@ public class StatusUpdater extends VmDefUpdater {
} }
lastRamChange = now; lastRamChange = now;
lastRamValue = event.size(); lastRamValue = event.size();
updateRam(lastRamValue); updateRam();
return; return;
} }
@ -323,10 +323,11 @@ public class StatusUpdater extends VmDefUpdater {
if (balloonTimer != null) { if (balloonTimer != null) {
return; return;
} }
final var pipeline = activeEventPipeline();
balloonTimer = Components.schedule(t -> { balloonTimer = Components.schedule(t -> {
activeEventPipeline().submit("Update RAM size", () -> { pipeline.submit("Update RAM size", () -> {
try { try {
updateRam(lastRamValue); updateRam();
} catch (ApiException e) { } catch (ApiException e) {
logger.log(Level.WARNING, e, logger.log(Level.WARNING, e,
() -> "Failed to update ram size: " + e.getMessage()); () -> "Failed to update ram size: " + e.getMessage());
@ -336,11 +337,11 @@ public class StatusUpdater extends VmDefUpdater {
}, now.plusSeconds(15)); }, now.plusSeconds(15));
} }
private void updateRam(BigInteger size) throws ApiException { private void updateRam() throws ApiException {
vmStub.updateStatus(from -> { vmStub.updateStatus(from -> {
JsonObject status = from.statusJson(); JsonObject status = from.statusJson();
status.addProperty(Status.RAM, status.addProperty(Status.RAM,
new Quantity(new BigDecimal(size), Format.BINARY_SI) new Quantity(new BigDecimal(lastRamValue), Format.BINARY_SI)
.toSuffixedString()); .toSuffixedString());
return status; return status;
}); });