Add counter for file access

This commit is contained in:
Martin Beyer
2022-04-14 15:47:41 +02:00
parent e71b375437
commit 4944a634fb
4 changed files with 67 additions and 0 deletions

View File

@@ -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<Instant> 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<Instant> lastActivityProperty() {
return lastActivity;
}

View File

@@ -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<Number, Number> readChart;
public AreaChart<Number, Number> 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();}
}

View File

@@ -72,4 +72,21 @@
<DataLabel byteFormat="%stats.encr.total.data.none" kibFormat="%stats.encr.total.data.kib" mibFormat="%stats.encr.total.data.mib" gibFormat="%stats.encr.total.data.gib" dataInBytes="${controller.totalBytesEncrypted}"/>
<FormattedLabel format="%stats.write.accessCount" arg1="${controller.filesWritten}"/>
</VBox>
<!-- Access -->
<VBox prefWidth="300" prefHeight="300" spacing="6" alignment="CENTER">
<ThroughputLabel styleClass="label-large" idleFormat="%stats.read.throughput.idle" kibsFormat="%stats.read.throughput.kibs" mibsFormat="%stats.read.throughput.mibs" bytesPerSecond="${controller.bpsAccessed}"/>
<AreaChart fx:id="accessChart" styleClass="io-stats" createSymbols="false" animated="false">
<xAxis>
<NumberAxis fx:id="accessChartXAxis" styleClass="io-stats" autoRanging="false" forceZeroInRange="false" side="BOTTOM"/>
</xAxis>
<yAxis>
<NumberAxis fx:id="accessChartYAxis" styleClass="io-stats" autoRanging="false" forceZeroInRange="true" side="LEFT" tickUnit="Infinity"/>
</yAxis>
<cursor>
<Cursor fx:constant="DEFAULT"/>
</cursor>
</AreaChart>
<DataLabel byteFormat="%stats.encr.total.data.none" kibFormat="%stats.encr.total.data.kib" mibFormat="%stats.encr.total.data.mib" gibFormat="%stats.encr.total.data.gib" dataInBytes="${controller.totalBytesAccessed}"/>
<FormattedLabel format="%stats.access.accessCount" arg1="${controller.filesAccessed}"/>
</VBox>
</HBox>

View File

@@ -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