Class FS.FileStoreAttributes

  • Enclosing class:
    FS

    public static final class FS.FileStoreAttributes
    extends java.lang.Object
    Attributes of FileStores on this system
    Since:
    5.1.9
    • Field Detail

      • UNDEFINED_DURATION

        private static final java.time.Duration UNDEFINED_DURATION
      • FALLBACK_TIMESTAMP_RESOLUTION

        public static final java.time.Duration FALLBACK_TIMESTAMP_RESOLUTION
        Fallback filesystem timestamp resolution. The worst case timestamp resolution on FAT filesystems is 2 seconds.
      • FALLBACK_FILESTORE_ATTRIBUTES

        public static final FS.FileStoreAttributes FALLBACK_FILESTORE_ATTRIBUTES
        Fallback FileStore attributes used when we can't measure the filesystem timestamp resolution. The last modified time granularity of FAT filesystems is 2 seconds.
      • JAVA_VERSION_PREFIX

        private static final java.lang.String JAVA_VERSION_PREFIX
      • FALLBACK_MIN_RACY_INTERVAL

        private static final java.time.Duration FALLBACK_MIN_RACY_INTERVAL
      • attributeCache

        private static final java.util.Map<java.nio.file.FileStore,​FS.FileStoreAttributes> attributeCache
      • background

        private static final java.util.concurrent.atomic.AtomicBoolean background
      • locks

        private static final java.util.Map<java.nio.file.FileStore,​java.util.concurrent.locks.Lock> locks
      • threadNumber

        private static final java.util.concurrent.atomic.AtomicInteger threadNumber
      • FUTURE_RUNNER

        private static final 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.

        Instead use normal daemon threads. They'll belong to the SecurityManager's thread group, or use the one of the calling thread, as appropriate.

        See Also:
        Executors.newCachedThreadPool()
      • fsTimestampResolution

        @NonNull
        private final java.time.Duration fsTimestampResolution
      • minimalRacyInterval

        private java.time.Duration minimalRacyInterval
    • Constructor Detail

      • FileStoreAttributes

        public FileStoreAttributes​(@NonNull
                                   java.time.Duration fsTimestampResolution)
        Construct a FileStoreAttributeCache entry for the given filesystem timestamp resolution
        Parameters:
        fsTimestampResolution -
    • Method Detail

      • setBackground

        public static void setBackground​(boolean async)
        Whether FileStore attributes should be determined asynchronously
        Parameters:
        async - whether FileStore attributes should be determined asynchronously. If false access to cached attributes may block for some seconds for the first call per FileStore
        Since:
        5.6.2
      • configureAttributesPathCache

        public static void configureAttributesPathCache​(int maxSize,
                                                        float purgeFactor)
        Configures size and purge factor of the path-based cache for file system attributes. Caching of file system attributes avoids recurring lookup of @{code FileStore} of files which may be expensive on some platforms.
        Parameters:
        maxSize - maximum size of the cache, default is 100
        purgeFactor - 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 happens
        Since:
        5.1.9
      • get

        public static FS.FileStoreAttributes get​(java.nio.file.Path path)
        Get the FileStoreAttributes for the given FileStore
        Parameters:
        path - file residing in the FileStore to get attributes for
        Returns:
        FileStoreAttributes for the given path.
      • getFileStoreAttributes

        private static FS.FileStoreAttributes getFileStoreAttributes​(java.nio.file.Path dir)
      • measureMinimalRacyInterval

        private static java.time.Duration measureMinimalRacyInterval​(java.nio.file.Path dir)
      • write

        private static void write​(java.nio.file.Path p,
                                  java.lang.String body)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        private static java.lang.String read​(java.nio.file.Path p)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • measureFsTimestampResolution

        private static java.util.Optional<java.time.Duration> measureFsTimestampResolution​(java.nio.file.FileStore s,
                                                                                           java.nio.file.Path dir)
      • measureClockResolution

        private static java.time.Duration measureClockResolution()
      • deleteProbe

        private static void deleteProbe​(java.nio.file.Path probe)
      • readFromConfig

        private static java.util.Optional<FS.FileStoreAttributes> readFromConfig​(java.nio.file.FileStore s)
      • getConfigKey

        private static java.lang.String getConfigKey​(java.nio.file.FileStore s)
      • getUnit

        private static java.util.concurrent.TimeUnit getUnit​(long nanos)
      • getMinimalRacyInterval

        public java.time.Duration getMinimalRacyInterval()
        Returns:
        the measured minimal interval after a file has been modified in which we cannot rely on lastModified to detect modifications
      • getFsTimestampResolution

        @NonNull
        public java.time.Duration getFsTimestampResolution()
        Returns:
        the measured filesystem timestamp resolution
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object