Merge branch 'develop' into feature/#1013-#1061-cleanupAndInformation

This commit is contained in:
Armin Schrenk
2020-11-10 12:08:23 +01:00
25 changed files with 932 additions and 71 deletions
@@ -32,7 +32,9 @@ import javafx.beans.Observable;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.binding.StringBinding;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import java.io.IOException;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
@@ -68,6 +70,7 @@ public class Vault {
private final BooleanBinding unknownError;
private final StringBinding accessPoint;
private final BooleanBinding accessPointPresent;
private final BooleanProperty showingStats;
private volatile Volume volume;
@@ -90,6 +93,7 @@ public class Vault {
this.unknownError = Bindings.createBooleanBinding(this::isUnknownError, state);
this.accessPoint = Bindings.createStringBinding(this::getAccessPoint, state);
this.accessPointPresent = this.accessPoint.isNotEmpty();
this.showingStats = new SimpleBooleanProperty(false);
}
// ******************************************************************************
@@ -268,6 +272,15 @@ public class Vault {
}
}
public BooleanProperty showingStatsProperty() {
return showingStats;
}
public boolean isShowingStats() {
return accessPointPresent.get();
}
// ******************************************************************************
// Getter/Setter
// *******************************************************************************/
@@ -8,8 +8,10 @@ import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javafx.application.Platform;
import javafx.beans.Observable;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.LongProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.concurrent.ScheduledService;
import javafx.concurrent.Task;
@@ -28,6 +30,15 @@ public class VaultStats {
private final ScheduledService<Optional<CryptoFileSystemStats>> 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 LongProperty toalBytesRead = new SimpleLongProperty();
private final LongProperty toalBytesWritten = new SimpleLongProperty();
private final LongProperty totalBytesEncrypted = new SimpleLongProperty();
private final LongProperty totalBytesDecrypted = new SimpleLongProperty();
private final LongProperty filesRead = new SimpleLongProperty();
private final LongProperty filesWritten = new SimpleLongProperty();
@Inject
VaultStats(AtomicReference<CryptoFileSystem> fs, ObjectProperty<VaultState> state, ExecutorService executor) {
@@ -53,8 +64,28 @@ public class VaultStats {
private void updateStats(Optional<CryptoFileSystemStats> stats) {
assert Platform.isFxApplicationThread();
bytesPerSecondRead.set(stats.map(CryptoFileSystemStats::pollBytesRead).orElse(0l));
bytesPerSecondWritten.set(stats.map(CryptoFileSystemStats::pollBytesWritten).orElse(0l));
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));
toalBytesRead.set(stats.map(CryptoFileSystemStats::pollTotalBytesRead).orElse(0L));
toalBytesWritten.set(stats.map(CryptoFileSystemStats::pollTotalBytesWritten).orElse(0L));
totalBytesEncrypted.set(stats.map(CryptoFileSystemStats::pollTotalBytesEncrypted).orElse(0L));
totalBytesDecrypted.set(stats.map(CryptoFileSystemStats::pollTotalBytesDecrypted).orElse(0L));
filesRead.set(stats.map(CryptoFileSystemStats::pollAmountOfAccessesRead).orElse(0L));
filesWritten.set(stats.map(CryptoFileSystemStats::pollAmountOfAccessesWritten).orElse(0L));
}
private double getCacheHitRate(CryptoFileSystemStats stats) {
long accesses = stats.pollChunkCacheAccesses();
long hits = stats.pollChunkCacheHits();
if (accesses == 0) {
return 0.0;
} else {
return hits / (double) accesses;
}
}
private class UpdateStatsService extends ScheduledService<Optional<CryptoFileSystemStats>> {
@@ -98,4 +129,50 @@ public class VaultStats {
public long getBytesPerSecondWritten() {
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; }
public double getCacheHitRate() {
return cacheHitRate.get();
}
public LongProperty toalBytesReadProperty() {return toalBytesRead;}
public long getTotalBytesRead() { return toalBytesRead.get();}
public LongProperty toalBytesWrittenProperty() {return toalBytesWritten;}
public long getTotalBytesWritten() { return toalBytesWritten.get();}
public LongProperty totalBytesEncryptedProperty() {return totalBytesEncrypted;}
public long getTotalBytesEncrypted() { return totalBytesEncrypted.get();}
public LongProperty totalBytesDecryptedProperty() {return totalBytesDecrypted;}
public long getTotalBytesDecrypted() { return totalBytesDecrypted.get();}
public LongProperty filesRead() { return filesRead;}
public long getFilesRead() { return filesRead.get();}
public LongProperty filesWritten() {return filesWritten;}
public long getFilesWritten() {return filesWritten.get();}
}