public static final class FS.FileStoreAttributes
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static SimpleLruCache<java.nio.file.Path,FS.FileStoreAttributes> |
attrCacheByPath |
private static java.util.Map<java.nio.file.FileStore,FS.FileStoreAttributes> |
attributeCache |
private static java.util.concurrent.atomic.AtomicBoolean |
background |
static FS.FileStoreAttributes |
FALLBACK_FILESTORE_ATTRIBUTES
Fallback FileStore attributes used when we can't measure the
filesystem timestamp resolution.
|
private static java.time.Duration |
FALLBACK_MIN_RACY_INTERVAL |
static java.time.Duration |
FALLBACK_TIMESTAMP_RESOLUTION
Fallback filesystem timestamp resolution.
|
private java.time.Duration |
fsTimestampResolution |
private static java.util.concurrent.Executor |
FUTURE_RUNNER
Don't use the default thread factory of the ForkJoinPool for the
CompletableFuture; it runs without any privileges, which causes
trouble if a SecurityManager is present.
|
private static java.lang.String |
JAVA_VERSION_PREFIX |
private static java.util.Map<java.nio.file.FileStore,java.util.concurrent.locks.Lock> |
locks |
private java.time.Duration |
minimalRacyInterval |
private static java.util.concurrent.atomic.AtomicInteger |
threadNumber |
private static java.time.Duration |
UNDEFINED_DURATION |
Constructor and Description |
---|
FileStoreAttributes(java.time.Duration fsTimestampResolution)
Construct a FileStoreAttributeCache entry for the given filesystem
timestamp resolution
|
Modifier and Type | Method and Description |
---|---|
static void |
configureAttributesPathCache(int maxSize,
float purgeFactor)
Configures size and purge factor of the path-based cache for file
system attributes.
|
private static void |
deleteProbe(java.nio.file.Path probe) |
static FS.FileStoreAttributes |
get(java.nio.file.Path path)
Get the FileStoreAttributes for the given FileStore
|
private static java.lang.String |
getConfigKey(java.nio.file.FileStore s) |
private static FS.FileStoreAttributes |
getFileStoreAttributes(java.nio.file.Path dir) |
java.time.Duration |
getFsTimestampResolution() |
java.time.Duration |
getMinimalRacyInterval() |
private static java.util.concurrent.TimeUnit |
getUnit(long nanos) |
private static java.time.Duration |
measureClockResolution() |
private static java.util.Optional<java.time.Duration> |
measureFsTimestampResolution(java.nio.file.FileStore s,
java.nio.file.Path dir) |
private static java.time.Duration |
measureMinimalRacyInterval(java.nio.file.Path dir) |
private static java.lang.String |
read(java.nio.file.Path p) |
private static java.util.Optional<FS.FileStoreAttributes> |
readFromConfig(java.nio.file.FileStore s) |
private static void |
saveToConfig(java.nio.file.FileStore s,
FS.FileStoreAttributes c) |
static void |
setBackground(boolean async)
Whether FileStore attributes should be determined asynchronously
|
java.lang.String |
toString() |
private static void |
write(java.nio.file.Path p,
java.lang.String body) |
private static final java.time.Duration UNDEFINED_DURATION
public static final java.time.Duration FALLBACK_TIMESTAMP_RESOLUTION
public static final FS.FileStoreAttributes FALLBACK_FILESTORE_ATTRIBUTES
private static final java.lang.String JAVA_VERSION_PREFIX
private static final java.time.Duration FALLBACK_MIN_RACY_INTERVAL
private static final java.util.Map<java.nio.file.FileStore,FS.FileStoreAttributes> attributeCache
private static final SimpleLruCache<java.nio.file.Path,FS.FileStoreAttributes> attrCacheByPath
private static final java.util.concurrent.atomic.AtomicBoolean background
private static final java.util.Map<java.nio.file.FileStore,java.util.concurrent.locks.Lock> locks
private static final java.util.concurrent.atomic.AtomicInteger threadNumber
private static final java.util.concurrent.Executor FUTURE_RUNNER
Instead use normal daemon threads. They'll belong to the SecurityManager's thread group, or use the one of the calling thread, as appropriate.
Executors.newCachedThreadPool()
@NonNull private final java.time.Duration fsTimestampResolution
private java.time.Duration minimalRacyInterval
public FileStoreAttributes(@NonNull java.time.Duration fsTimestampResolution)
fsTimestampResolution
- public static void setBackground(boolean async)
async
- whether FileStore attributes should be determined
asynchronously. If false access to cached attributes may block
for some seconds for the first call per FileStorepublic static void configureAttributesPathCache(int maxSize, float purgeFactor)
maxSize
- maximum size of the cache, default is 100purgeFactor
- when the size of the map reaches maxSize the oldest
entries will be purged to free up some space for new
entries, purgeFactor
is the fraction of
maxSize
to purge when this happenspublic static FS.FileStoreAttributes get(java.nio.file.Path path)
path
- file residing in the FileStore to get attributes forprivate static FS.FileStoreAttributes getFileStoreAttributes(java.nio.file.Path dir)
private static java.time.Duration measureMinimalRacyInterval(java.nio.file.Path dir)
private static void write(java.nio.file.Path p, java.lang.String body) throws java.io.IOException
java.io.IOException
private static java.lang.String read(java.nio.file.Path p) throws java.io.IOException
java.io.IOException
private static java.util.Optional<java.time.Duration> measureFsTimestampResolution(java.nio.file.FileStore s, java.nio.file.Path dir)
private static java.time.Duration measureClockResolution()
private static void deleteProbe(java.nio.file.Path probe)
private static java.util.Optional<FS.FileStoreAttributes> readFromConfig(java.nio.file.FileStore s)
private static void saveToConfig(java.nio.file.FileStore s, FS.FileStoreAttributes c)
private static java.lang.String getConfigKey(java.nio.file.FileStore s)
private static java.util.concurrent.TimeUnit getUnit(long nanos)
public java.time.Duration getMinimalRacyInterval()
@NonNull public java.time.Duration getFsTimestampResolution()
public java.lang.String toString()
toString
in class java.lang.Object