Class FS.FileStoreAttributes

java.lang.Object
org.eclipse.jgit.util.FS.FileStoreAttributes
Enclosing class:
FS

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

    • UNDEFINED_DURATION

      private static final Duration UNDEFINED_DURATION
      Marker to detect undefined values when reading from the config file.
    • FALLBACK_TIMESTAMP_RESOLUTION

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

      Must be at least 1 second.

    • 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.
    • ONE_MICROSECOND

      private static final long ONE_MICROSECOND
    • ONE_MILLISECOND

      private static final long ONE_MILLISECOND
    • ONE_SECOND

      private static final long ONE_SECOND
    • MINIMUM_RESOLUTION_NANOS

      private static final long MINIMUM_RESOLUTION_NANOS
      Minimum file system timestamp resolution granularity to check, in nanoseconds. Should be a positive power of ten smaller than ONE_SECOND. Must be strictly greater than zero, i.e., minimum value is 1 nanosecond.

      Currently set to 1 microsecond, but could also be lower still.

    • JAVA_VERSION_PREFIX

      private static final String JAVA_VERSION_PREFIX
    • FALLBACK_MIN_RACY_INTERVAL

      private static final Duration FALLBACK_MIN_RACY_INTERVAL
    • attributeCache

      private static final Map<FileStore,FS.FileStoreAttributes> attributeCache
    • attrCacheByPath

      private static final SimpleLruCache<Path,FS.FileStoreAttributes> attrCacheByPath
    • background

      private static final AtomicBoolean background
    • locks

      private static final Map<FileStore,Lock> locks
    • threadNumber

      private static final AtomicInteger threadNumber
    • FUTURE_RUNNER

      private static final 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:
    • SAVE_RUNNER

      private static final Executor SAVE_RUNNER
      Use a separate executor with at most one thread to synchronize writing to the config. We write asynchronously since the config itself might be on a different file system, which might otherwise lead to locking problems.

      Writing the config must not use a daemon thread, otherwise we may leave an inconsistent state on disk when the JVM shuts down. Use a small keep-alive time to avoid delays on shut-down.

    • fsTimestampResolution

      @NonNull private final Duration fsTimestampResolution
    • minimalRacyInterval

      private Duration minimalRacyInterval
  • Constructor Details

    • FileStoreAttributes

      public FileStoreAttributes(@NonNull Duration fsTimestampResolution)
      Construct a FileStoreAttributeCache entry for the given filesystem timestamp resolution
      Parameters:
      fsTimestampResolution -
  • Method Details

    • 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(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(Path dir)
    • measureMinimalRacyInterval

      private static Duration measureMinimalRacyInterval(Path dir)
    • write

      private static void write(Path p, String body) throws IOException
      Throws:
      IOException
    • read

      private static String read(Path p) throws IOException
      Throws:
      IOException
    • measureFsTimestampResolution

      private static Optional<Duration> measureFsTimestampResolution(FileStore s, Path dir)
    • getFsResolution

      private static Duration getFsResolution(FileStore s, Path dir, Path probe) throws IOException
      Throws:
      IOException
    • measureClockResolution

      private static Duration measureClockResolution()
    • deleteProbe

      private static void deleteProbe(Path probe)
    • readFromConfig

      private static Optional<FS.FileStoreAttributes> readFromConfig(FileStore s)
    • saveToConfig

      private static void saveToConfig(FileStore s, FS.FileStoreAttributes c)
    • getConfigKey

      private static String getConfigKey(FileStore s)
    • getUnit

      private static TimeUnit getUnit(long nanos)
    • getMinimalRacyInterval

      public 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 Duration getFsTimestampResolution()
      Returns:
      the measured filesystem timestamp resolution
    • toString

      public String toString()
      Overrides:
      toString in class Object