diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/VaultStats.java b/main/commons/src/main/java/org/cryptomator/common/vaults/VaultStats.java index 4ef791110..4d13163e9 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/VaultStats.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/VaultStats.java @@ -3,9 +3,11 @@ package org.cryptomator.common.vaults; import javafx.application.Platform; import javafx.beans.Observable; import javafx.beans.property.DoubleProperty; +import javafx.beans.property.IntegerProperty; import javafx.beans.property.LongProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleLongProperty; import javafx.beans.value.ObservableValue; import javafx.concurrent.ScheduledService; @@ -31,7 +33,11 @@ public class VaultStats { private final ScheduledService> updateService; private final LongProperty bytesPerSecondRead = new SimpleLongProperty(); private final LongProperty bytesPerSecondWritten = new SimpleLongProperty(); + private final LongProperty bytesPerSecondEncrypted = new SimpleLongProperty(); + private final LongProperty bytesPerSecondDecrypted = new SimpleLongProperty(); private final DoubleProperty cacheHitRate = new SimpleDoubleProperty(); + //private final IntegerProperty filesRead = new SimpleIntegerProperty(); + //private final IntegerProperty filesWritten = new SimpleIntegerProperty(); @Inject VaultStats(AtomicReference fs, ObjectProperty state, ExecutorService executor) { @@ -60,6 +66,8 @@ public class VaultStats { bytesPerSecondRead.set(stats.map(CryptoFileSystemStats::pollBytesRead).orElse(0l)); bytesPerSecondWritten.set(stats.map(CryptoFileSystemStats::pollBytesWritten).orElse(0l)); 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)); } private double getCacheHitRate(CryptoFileSystemStats stats) { @@ -110,6 +118,22 @@ public class VaultStats { return bytesPerSecondWritten.get(); } + public LongProperty bytesPerSecondEncryptedProperty() { + return bytesPerSecondEncrypted; + } + + public long getBytesPerSecondEnrypted() { + return bytesPerSecondEncrypted.get(); + } + + public LongProperty bytesPerSecondDecryptedProperty() { + return bytesPerSecondDecrypted; + } + + public long getBytesPerSecondDecrypted() { + return bytesPerSecondDecrypted.get(); + } + public DoubleProperty cacheHitRateProperty() { return cacheHitRate; } @@ -117,5 +141,6 @@ public class VaultStats { public double getCacheHitRate() { return cacheHitRate.get(); } - + + } diff --git a/main/ui/src/main/java/org/cryptomator/ui/common/WeakBindings.java b/main/ui/src/main/java/org/cryptomator/ui/common/WeakBindings.java index 34c90d212..e6071df1d 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/common/WeakBindings.java +++ b/main/ui/src/main/java/org/cryptomator/ui/common/WeakBindings.java @@ -1,6 +1,7 @@ package org.cryptomator.ui.common; import javafx.beans.binding.DoubleBinding; +import javafx.beans.binding.IntegerBinding; import javafx.beans.binding.LongBinding; import javafx.beans.binding.StringBinding; import javafx.beans.value.ObservableObjectValue; @@ -70,4 +71,23 @@ public final class WeakBindings { }; } + /** + * Create a new IntegerBinding that listens to changes from the given observable without being strongly referenced by it. + * + * @param observable The observable + * @return a IntegerBinding weakly referenced from the given observable + */ + public static IntegerBinding bindInterger(ObservableValue observable) { + return new IntegerBinding() { + { + bind(observable); + } + + @Override + protected int computeValue() { + return observable.getValue().intValue(); + } + }; + } + } diff --git a/main/ui/src/main/java/org/cryptomator/ui/stats/VaultStatisticsController.java b/main/ui/src/main/java/org/cryptomator/ui/stats/VaultStatisticsController.java index f8914c476..cc747b8f6 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/stats/VaultStatisticsController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/stats/VaultStatisticsController.java @@ -5,6 +5,7 @@ import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.beans.binding.Bindings; import javafx.beans.binding.DoubleBinding; +import javafx.beans.binding.IntegerBinding; import javafx.beans.binding.LongBinding; import javafx.event.ActionEvent; import javafx.event.EventHandler; @@ -40,6 +41,10 @@ public class VaultStatisticsController implements FxController { private final DoubleBinding cacheHitRate; private final DoubleBinding cacheHitDregrees; private final DoubleBinding cacheHitPercentage; + /*private final IntegerBinding filesRead; + private final IntegerBinding filesWritten;*/ + private final LongBinding bpsEncrypted; + private final LongBinding bpsDecrypted; public AreaChart readChart; public AreaChart writeChart; @@ -58,6 +63,10 @@ public class VaultStatisticsController implements FxController { this.cacheHitRate = WeakBindings.bindDouble(stats.cacheHitRateProperty()); this.cacheHitDregrees = cacheHitRate.multiply(-270); this.cacheHitPercentage = cacheHitRate.multiply(100); + /*this.filesRead = WeakBindings.bindInterger(); + this.filesWritten = WeakBindings.bindInterger();*/ + this.bpsEncrypted = WeakBindings.bindLong(stats.bytesPerSecondEncryptedProperty()); + this.bpsDecrypted = WeakBindings.bindLong(stats.bytesPerSecondDecryptedProperty()); this.ioAnimation = new Timeline(); //TODO Research better timer ioAnimation.getKeyFrames().add(new KeyFrame(Duration.seconds(IO_SAMPLING_INTERVAL), new IoSamplingAnimationHandler(readData, writeData))); @@ -157,4 +166,20 @@ public class VaultStatisticsController implements FxController { public double getCacheHitDregrees() { return cacheHitDregrees.get(); } + + public LongBinding bpsEncryptedProperty() { + return bpsEncrypted; + } + + public long getBpsEncrypted() { + return bpsEncrypted.get(); + } + + public LongBinding bpsDecryptedProperty() { + return bpsDecrypted; + } + + public long getBpsDecrypted() { + return bpsDecrypted.get(); + } } diff --git a/main/ui/src/main/resources/fxml/stats.fxml b/main/ui/src/main/resources/fxml/stats.fxml index d0cef21c4..85ea52efb 100644 --- a/main/ui/src/main/resources/fxml/stats.fxml +++ b/main/ui/src/main/resources/fxml/stats.fxml @@ -19,7 +19,7 @@ - + @@ -28,18 +28,18 @@ - - - - -