Add third stats graph, displaying general file(attribute) accesses

This commit is contained in:
Martin Beyer
2022-05-05 00:09:39 +02:00
parent 01412070ad
commit e3c609351f
5 changed files with 47 additions and 38 deletions

View File

@@ -27,7 +27,7 @@
<nonModularGroupIds>com.github.serceman,com.github.jnr,org.ow2.asm,net.java.dev.jna,org.apache.jackrabbit,org.apache.httpcomponents,de.swiesend,org.purejava,com.github.hypfvieh</nonModularGroupIds>
<!-- cryptomator dependencies -->
<cryptomator.cryptofs.version>2.4.1</cryptomator.cryptofs.version>
<cryptomator.cryptofs.version>2.5.0-SNAPSHOT</cryptomator.cryptofs.version>
<cryptomator.integrations.version>1.1.0</cryptomator.integrations.version>
<cryptomator.integrations.win.version>1.1.0</cryptomator.integrations.win.version>
<cryptomator.integrations.mac.version>1.1.0</cryptomator.integrations.mac.version>

View File

@@ -34,16 +34,15 @@ 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 LongProperty totalFilesAccessed = new SimpleLongProperty();
private final ObjectProperty<Instant> lastActivity = new SimpleObjectProperty<>();
@Inject
@@ -78,16 +77,15 @@ 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));
totalFilesAccessed.set(stats.map(CryptoFileSystemStats::pollTotalAmountOfAccesses).orElse(0L));
var newAccessCount = filesRead.get() + filesWritten.get();
// check for any I/O activity
@@ -164,14 +162,6 @@ 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() {
@@ -194,10 +184,6 @@ 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();}
@@ -211,6 +197,14 @@ public class VaultStats {
public long getFilesAccessed() {return filesAccessed.get();}
public LongProperty totalFilesAccessed(){
return totalFilesAccessed;
}
public long getTotalFilesAccessed(){
return totalFilesAccessed.get();
}
public ObjectProperty<Instant> lastActivityProperty() {
return lastActivity;
}

View File

@@ -35,6 +35,7 @@ public class VaultStatisticsController implements FxController {
private final VaultStats stats;
private final Series<Number, Number> readData;
private final Series<Number, Number> writeData;
private final Series<Number, Number> accessData;
private final Timeline ioAnimation;
private final LongBinding bpsRead;
private final LongBinding bpsWritten;
@@ -45,20 +46,22 @@ 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 totalFilesAccessed;
private final LongBinding bpsEncrypted;
private final LongBinding bpsDecrypted;
private final LongBinding bpsAccessed;
public AreaChart<Number, Number> readChart;
public AreaChart<Number, Number> writeChart;
public AreaChart<Number, Number> accessChart;
public NumberAxis readChartXAxis;
public NumberAxis readChartYAxis;
public NumberAxis writeChartXAxis;
public NumberAxis writeChartYAxis;
public NumberAxis accessChartXAxis;
public NumberAxis accessChartYAxis;
@Inject
public VaultStatisticsController(VaultStatisticsComponent component, @VaultStatisticsWindow Stage window, @VaultStatisticsWindow Vault vault) {
@@ -66,6 +69,7 @@ public class VaultStatisticsController implements FxController {
this.stats = vault.getStats();
this.readData = new Series<>();
this.writeData = new Series<>();
this.accessData = new Series<>();
this.bpsRead = WeakBindings.bindLong(stats.bytesPerSecondReadProperty());
this.bpsWritten = WeakBindings.bindLong(stats.bytesPerSecondWrittenProperty());
this.cacheHitRate = WeakBindings.bindDouble(stats.cacheHitRateProperty());
@@ -75,16 +79,15 @@ 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.totalFilesAccessed = WeakBindings.bindLong(stats.totalFilesAccessed());
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)));
ioAnimation.getKeyFrames().add(new KeyFrame(Duration.seconds(IO_SAMPLING_INTERVAL), new IoSamplingAnimationHandler(readData, writeData, accessData)));
ioAnimation.setCycleCount(Animation.INDEFINITE);
ioAnimation.play();
@@ -98,6 +101,7 @@ public class VaultStatisticsController implements FxController {
public void initialize() {
readChart.getData().addAll(readData);
writeChart.getData().addAll(writeData);
accessChart.getData().addAll(accessData);
}
private class IoSamplingAnimationHandler implements EventHandler<ActionEvent> {
@@ -105,16 +109,21 @@ public class VaultStatisticsController implements FxController {
private long step = IO_SAMPLING_STEPS;
private final Series<Number, Number> decryptedBytesRead;
private final Series<Number, Number> encryptedBytesWrite;
private final Series<Number, Number> accessedFiles;
private final long[] maxBuf = new long[IO_SAMPLING_STEPS];
private final long[] maxAccessBuf = new long[IO_SAMPLING_STEPS];
public IoSamplingAnimationHandler(Series<Number, Number> readData, Series<Number, Number> writeData) {
public IoSamplingAnimationHandler(Series<Number, Number> readData, Series<Number, Number> writeData, Series<Number, Number> accessData) {
this.decryptedBytesRead = readData;
this.encryptedBytesWrite = writeData;
this.accessedFiles = accessData;
// initialize data once and change value of data points later:
for (int i = 0; i < IO_SAMPLING_STEPS; i++) {
decryptedBytesRead.getData().add(new Data<>(i, 0));
encryptedBytesWrite.getData().add(new Data<>(i, 0));
accessedFiles.getData().add(new Data<>(i, 0));
}
}
@@ -123,17 +132,22 @@ public class VaultStatisticsController implements FxController {
final long currentStep = step++;
final long decBytes = stats.bytesPerSecondReadProperty().get();
final long encBytes = stats.bytesPerSecondWrittenProperty().get();
final long accFiles = stats.filesAccessed().get();
maxBuf[(int) currentStep % IO_SAMPLING_STEPS] = Math.max(decBytes, encBytes);
long allTimeMax = Arrays.stream(maxBuf).max().orElse(0l);
long allTimeMax = Arrays.stream(maxBuf).max().orElse(0L);
maxAccessBuf[(int) currentStep % IO_SAMPLING_STEPS] = accFiles;
long allTimeMaxAccessedFiles = Arrays.stream(maxAccessBuf).max().orElse(0L);
// remove oldest value:
decryptedBytesRead.getData().remove(0);
encryptedBytesWrite.getData().remove(0);
accessedFiles.getData().remove(0);
// add latest value:
decryptedBytesRead.getData().add(new Data<>(currentStep, decBytes));
encryptedBytesWrite.getData().add(new Data<>(currentStep, encBytes));
accessedFiles.getData().add(new Data<>(currentStep, accFiles));
// adjust ranges:
readChartXAxis.setLowerBound(currentStep - IO_SAMPLING_STEPS * 1.0);
@@ -142,6 +156,9 @@ public class VaultStatisticsController implements FxController {
writeChartXAxis.setLowerBound(currentStep - IO_SAMPLING_STEPS * 1.0);
writeChartXAxis.setUpperBound(currentStep);
writeChartYAxis.setUpperBound(allTimeMax);
accessChartXAxis.setLowerBound(currentStep - IO_SAMPLING_STEPS * 1.0);
accessChartXAxis.setUpperBound(currentStep);
accessChartYAxis.setUpperBound(allTimeMaxAccessedFiles);
}
}
@@ -193,10 +210,6 @@ 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;
}
@@ -213,12 +226,6 @@ 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();}
@@ -230,4 +237,8 @@ public class VaultStatisticsController implements FxController {
public LongBinding filesAccessedProperty() {return filesAccessed;}
public long getFilesAccessed() {return filesAccessed.get();}
public LongBinding totalFilesAccessedProperty() {return totalFilesAccessed;}
public long getTotalFilesAccessed() {return totalFilesAccessed.get();}
}

View File

@@ -74,19 +74,22 @@
</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}"/>
<FormattedLabel styleClass="label-large" format="%stats.access.accessCount" arg1="${controller.filesAccessed}"/>
<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"/>
<NumberAxis fx:id="accessChartYAxis" styleClass="io-stats" autoRanging="true" 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}"/>
<Label></Label> <!-- So the three graphs are aligned -->
<FormattedLabel format="%stats.access.accessCount" arg1="${controller.filesAccessed}"/>
<FormattedLabel format="%stats.access.totalAccessCount" arg1="${controller.totalFilesAccessed}"/>
</VBox>
</HBox>

View File

@@ -263,7 +263,8 @@ stats.encr.total.data.gib=Data encrypted: %.1f GiB
stats.write.accessCount=Total writes: %d
## Accesses
stats.access.accessCount=Total accessed: %d
stats.access.totalAccessCount=Total accessed: %d
stats.access.accessCount=Currently accessed: %d
# Main Window