From 4944a634fb9a3bd36e72abf04a30b38bcea52e4e Mon Sep 17 00:00:00 2001 From: Martin Beyer Date: Thu, 14 Apr 2022 15:47:41 +0200 Subject: [PATCH] Add counter for file access --- .../cryptomator/common/vaults/VaultStats.java | 23 +++++++++++++++++++ .../ui/stats/VaultStatisticsController.java | 23 +++++++++++++++++++ src/main/resources/fxml/stats.fxml | 17 ++++++++++++++ src/main/resources/i18n/strings.properties | 4 ++++ 4 files changed, 67 insertions(+) diff --git a/src/main/java/org/cryptomator/common/vaults/VaultStats.java b/src/main/java/org/cryptomator/common/vaults/VaultStats.java index ac0b8df38..f5733fcd2 100644 --- a/src/main/java/org/cryptomator/common/vaults/VaultStats.java +++ b/src/main/java/org/cryptomator/common/vaults/VaultStats.java @@ -34,13 +34,16 @@ public class VaultStats { private final LongProperty bytesPerSecondWritten = new SimpleLongProperty(); private final LongProperty bytesPerSecondEncrypted = new SimpleLongProperty(); private final LongProperty bytesPerSecondDecrypted = new SimpleLongProperty(); + private final LongProperty bytesPerSecondAccessed = new SimpleLongProperty(); private final DoubleProperty cacheHitRate = new SimpleDoubleProperty(); private final LongProperty totalBytesRead = new SimpleLongProperty(); private final LongProperty totalBytesWritten = new SimpleLongProperty(); private final LongProperty totalBytesEncrypted = new SimpleLongProperty(); private final LongProperty totalBytesDecrypted = new SimpleLongProperty(); + private final LongProperty totalBytesAccessed = new SimpleLongProperty(); private final LongProperty filesRead = new SimpleLongProperty(); private final LongProperty filesWritten = new SimpleLongProperty(); + private final LongProperty filesAccessed = new SimpleLongProperty(); private final ObjectProperty lastActivity = new SimpleObjectProperty<>(); @Inject @@ -75,13 +78,16 @@ public class VaultStats { cacheHitRate.set(stats.map(this::getCacheHitRate).orElse(0.0)); bytesPerSecondDecrypted.set(stats.map(CryptoFileSystemStats::pollBytesDecrypted).orElse(0L)); bytesPerSecondEncrypted.set(stats.map(CryptoFileSystemStats::pollBytesEncrypted).orElse(0L)); + bytesPerSecondAccessed.set(stats.map(CryptoFileSystemStats::pollBytesAccessed).orElse(0L)); totalBytesRead.set(stats.map(CryptoFileSystemStats::pollTotalBytesRead).orElse(0L)); totalBytesWritten.set(stats.map(CryptoFileSystemStats::pollTotalBytesWritten).orElse(0L)); totalBytesEncrypted.set(stats.map(CryptoFileSystemStats::pollTotalBytesEncrypted).orElse(0L)); totalBytesDecrypted.set(stats.map(CryptoFileSystemStats::pollTotalBytesDecrypted).orElse(0L)); + totalBytesAccessed.set(stats.map(CryptoFileSystemStats::pollTotalBytesAccessed).orElse(0L)); var oldAccessCount = filesRead.get() + filesWritten.get(); filesRead.set(stats.map(CryptoFileSystemStats::pollAmountOfAccessesRead).orElse(0L)); filesWritten.set(stats.map(CryptoFileSystemStats::pollAmountOfAccessesWritten).orElse(0L)); + filesAccessed.set(stats.map(CryptoFileSystemStats::pollAmountOfAccesses).orElse(0L)); var newAccessCount = filesRead.get() + filesWritten.get(); // check for any I/O activity @@ -158,6 +164,14 @@ public class VaultStats { return bytesPerSecondDecrypted.get(); } + public LongProperty bytesPerSecondAccessedProperty() { + return bytesPerSecondAccessed; + } + + public long getBytesPerSecondAccessed(){ + return bytesPerSecondAccessed.get(); + } + public DoubleProperty cacheHitRateProperty() { return cacheHitRate; } public double getCacheHitRate() { @@ -180,6 +194,10 @@ public class VaultStats { public long getTotalBytesDecrypted() { return totalBytesDecrypted.get();} + public LongProperty getTotalBytesAccessedProperty() {return totalBytesAccessed;} + + public long getTotalBytesAccessed() { return totalBytesAccessed.get();} + public LongProperty filesRead() { return filesRead;} public long getFilesRead() { return filesRead.get();} @@ -188,6 +206,11 @@ public class VaultStats { public long getFilesWritten() {return filesWritten.get();} + public LongProperty filesAccessed() { + return filesAccessed;} + + public long getFilesAccessed() {return filesAccessed.get();} + public ObjectProperty lastActivityProperty() { return lastActivity; } diff --git a/src/main/java/org/cryptomator/ui/stats/VaultStatisticsController.java b/src/main/java/org/cryptomator/ui/stats/VaultStatisticsController.java index 56729f1fe..ef4963168 100644 --- a/src/main/java/org/cryptomator/ui/stats/VaultStatisticsController.java +++ b/src/main/java/org/cryptomator/ui/stats/VaultStatisticsController.java @@ -9,8 +9,10 @@ import javax.inject.Inject; import javafx.animation.Animation; import javafx.animation.KeyFrame; import javafx.animation.Timeline; +import javafx.beans.binding.Bindings; import javafx.beans.binding.DoubleBinding; import javafx.beans.binding.LongBinding; +import javafx.beans.property.LongProperty; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; @@ -21,6 +23,7 @@ import javafx.scene.chart.XYChart.Series; import javafx.stage.Stage; import javafx.util.Duration; import java.util.Arrays; +import java.util.concurrent.Callable; @VaultStatisticsScoped public class VaultStatisticsController implements FxController { @@ -42,10 +45,13 @@ public class VaultStatisticsController implements FxController { private final LongBinding totalBytesWritten; private final LongBinding totalBytesEncrypted; private final LongBinding totalBytesDecrypted; + private final LongBinding totalBytesAccessed; private final LongBinding filesRead; private final LongBinding filesWritten; + private final LongBinding filesAccessed; private final LongBinding bpsEncrypted; private final LongBinding bpsDecrypted; + private final LongBinding bpsAccessed; public AreaChart readChart; public AreaChart writeChart; @@ -69,10 +75,13 @@ public class VaultStatisticsController implements FxController { this.totalBytesWritten = WeakBindings.bindLong(stats.totalBytesWrittenProperty()); this.totalBytesDecrypted = WeakBindings.bindLong(stats.totalBytesDecryptedProperty()); this.totalBytesEncrypted = WeakBindings.bindLong(stats.totalBytesEncryptedProperty()); + this.totalBytesAccessed = WeakBindings.bindLong(stats.getTotalBytesAccessedProperty()); this.filesRead = WeakBindings.bindLong(stats.filesRead()); this.filesWritten = WeakBindings.bindLong(stats.filesWritten()); + this.filesAccessed = WeakBindings.bindLong(stats.filesAccessed()); this.bpsEncrypted = WeakBindings.bindLong(stats.bytesPerSecondEncryptedProperty()); this.bpsDecrypted = WeakBindings.bindLong(stats.bytesPerSecondDecryptedProperty()); + this.bpsAccessed = WeakBindings.bindLong(stats.bytesPerSecondAccessedProperty()); this.ioAnimation = new Timeline(); //TODO Research better timer ioAnimation.getKeyFrames().add(new KeyFrame(Duration.seconds(IO_SAMPLING_INTERVAL), new IoSamplingAnimationHandler(readData, writeData))); @@ -184,6 +193,10 @@ public class VaultStatisticsController implements FxController { public long getTotalBytesDecrypted() { return totalBytesDecrypted.get();} + public LongBinding getTotalBytesAccessedProperty() {return totalBytesAccessed;} + + public long getTotalBytesAccessed() { return totalBytesAccessed.get();} + public LongBinding bpsEncryptedProperty() { return bpsEncrypted; } @@ -200,6 +213,12 @@ public class VaultStatisticsController implements FxController { return bpsDecrypted.get(); } + public LongBinding bpsAccessedProperty() { + return bpsAccessed; + } + + public long getBpsAccessed(){ return bpsAccessed.get();} + public LongBinding filesReadProperty() { return filesRead;} public long getFilesRead() { return filesRead.get();} @@ -207,4 +226,8 @@ public class VaultStatisticsController implements FxController { public LongBinding filesWrittenProperty() {return filesWritten;} public long getFilesWritten() {return filesWritten.get();} + + public LongBinding filesAccessedProperty() {return filesAccessed;} + + public long getFilesAccessed() {return filesAccessed.get();} } diff --git a/src/main/resources/fxml/stats.fxml b/src/main/resources/fxml/stats.fxml index b17dc67f6..6d7cc8291 100644 --- a/src/main/resources/fxml/stats.fxml +++ b/src/main/resources/fxml/stats.fxml @@ -72,4 +72,21 @@ + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/i18n/strings.properties b/src/main/resources/i18n/strings.properties index 0ea837435..dac3c021a 100644 --- a/src/main/resources/i18n/strings.properties +++ b/src/main/resources/i18n/strings.properties @@ -262,6 +262,10 @@ stats.encr.total.data.mib=Data encrypted: %.1f MiB stats.encr.total.data.gib=Data encrypted: %.1f GiB stats.write.accessCount=Total writes: %d +## Accesses +stats.access.accessCount=Total accessed: %d + + # Main Window main.closeBtn.tooltip=Close main.minimizeBtn.tooltip=Minimize