Package org.eclipse.jgit.util
Class FS.FileStoreAttributes
java.lang.Object
org.eclipse.jgit.util.FS.FileStoreAttributes
- Enclosing class:
- FS
Attributes of FileStores on this system
- Since:
- 5.1.9
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final SimpleLruCache<Path,
FS.FileStoreAttributes> private static final Map<FileStore,
FS.FileStoreAttributes> private static final AtomicBoolean
static final FS.FileStoreAttributes
Fallback FileStore attributes used when we can't measure the filesystem timestamp resolution.private static final Duration
static final Duration
Fallback filesystem timestamp resolution.private final Duration
private static final Executor
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 final String
private Duration
private static final long
Minimum file system timestamp resolution granularity to check, in nanoseconds.private static final long
private static final long
private static final long
private static final Executor
Use a separate executor with at most one thread to synchronize writing to the config.private static final AtomicInteger
private static final Duration
Marker to detect undefined values when reading from the config file. -
Constructor Summary
ConstructorsConstructorDescriptionFileStoreAttributes
(Duration fsTimestampResolution) Construct a FileStoreAttributeCache entry for the given filesystem timestamp resolution -
Method Summary
Modifier and TypeMethodDescriptionstatic void
configureAttributesPathCache
(int maxSize, float purgeFactor) Configures size and purge factor of the path-based cache for file system attributes.private static void
deleteProbe
(Path probe) static FS.FileStoreAttributes
Get the FileStoreAttributes for the given FileStoreprivate static String
private static FS.FileStoreAttributes
private static Duration
getFsResolution
(FileStore s, Path dir, Path probe) private static TimeUnit
getUnit
(long nanos) private static Duration
private static Duration
private static String
private static Optional<FS.FileStoreAttributes>
private static void
static void
setBackground
(boolean async) Whether FileStore attributes should be determined asynchronouslytoString()
private static void
-
Field Details
-
UNDEFINED_DURATION
Marker to detect undefined values when reading from the config file. -
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
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_NANOSMinimum file system timestamp resolution granularity to check, in nanoseconds. Should be a positive power of ten smaller thanONE_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
-
FALLBACK_MIN_RACY_INTERVAL
-
attributeCache
-
attrCacheByPath
-
background
-
locks
-
threadNumber
-
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
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
-
minimalRacyInterval
-
-
Constructor Details
-
FileStoreAttributes
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 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 ofmaxSize
to purge when this happens- Since:
- 5.1.9
-
get
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
-
measureMinimalRacyInterval
-
write
- Throws:
IOException
-
read
- Throws:
IOException
-
measureFsTimestampResolution
-
getFsResolution
- Throws:
IOException
-
measureClockResolution
-
deleteProbe
-
readFromConfig
-
saveToConfig
-
getConfigKey
-
getUnit
-
getMinimalRacyInterval
- Returns:
- the measured minimal interval after a file has been modified in which we cannot rely on lastModified to detect modifications
-
getFsTimestampResolution
- Returns:
- the measured filesystem timestamp resolution
-
toString
-