Package com.aoapps.io.filesystems.posix
Class RandomFailPosixFileSystem
java.lang.Object
com.aoapps.io.filesystems.FileSystemWrapper
com.aoapps.io.filesystems.RandomFailFileSystem
com.aoapps.io.filesystems.posix.RandomFailPosixFileSystem
- All Implemented Interfaces:
FileSystem
,PosixFileSystem
A Unix file system implementation that randomly fails, this is used by test
suites to verify correct behavior under expected failure modes.
- Author:
- AO Industries, Inc.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Provides the failure probabilities.Nested classes/interfaces inherited from class com.aoapps.io.filesystems.RandomFailFileSystem
RandomFailFileSystem.FailureProbabilities, RandomFailFileSystem.RandomFailIOException
Nested classes/interfaces inherited from class com.aoapps.io.filesystems.FileSystemWrapper
FileSystemWrapper.PathIteratorWrapper, FileSystemWrapper.PathWrapper
-
Field Summary
Fields inherited from class com.aoapps.io.filesystems.FileSystemWrapper
wrappedFileSystem
-
Constructor Summary
ConstructorDescriptionRandomFailPosixFileSystem
(PosixFileSystem wrappedFileSystem) Uses default probabilities and a default fast pseudo-random number generator for non-cryptographic purposes.RandomFailPosixFileSystem
(PosixFileSystem wrappedFileSystem, RandomFailPosixFileSystem.UnixFailureProbabilities unixFailureProbabilities, Random fastRandom) Creates a new random-fail POSIX filesystem, wrapping the given POSIX filesystem. -
Method Summary
Modifier and TypeMethodDescriptioncreateDirectory
(Path path, int mode) Atomically creates a directory (must not have already existed) with the given permissions.createFile
(Path path, int mode) Atomically creates an empty file (must not have already existed) with the given permissions.Delegates to the wrapped file system, but with a random chance of fail.Methods inherited from class com.aoapps.io.filesystems.RandomFailFileSystem
createDirectory, createFile, delete, list, lock, randomFail, size
Methods inherited from class com.aoapps.io.filesystems.FileSystemWrapper
checkSubPath, join, parsePath, unwrapPath, wrapPath, wrapSubPath
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.aoapps.io.filesystems.FileSystem
createDirectory, createFile, delete, join, list, lock, parsePath, size
Methods inherited from interface com.aoapps.io.filesystems.posix.PosixFileSystem
checkSubPath
-
Constructor Details
-
RandomFailPosixFileSystem
public RandomFailPosixFileSystem(PosixFileSystem wrappedFileSystem, RandomFailPosixFileSystem.UnixFailureProbabilities unixFailureProbabilities, Random fastRandom) Creates a new random-fail POSIX filesystem, wrapping the given POSIX filesystem.- Parameters:
fastRandom
- A fast pseudo-random number generator for non-cryptographic purposes.
-
RandomFailPosixFileSystem
Uses default probabilities and a default fast pseudo-random number generator for non-cryptographic purposes.- See Also:
-
-
Method Details
-
stat
Delegates to the wrapped file system, but with a random chance of fail.- Specified by:
stat
in interfacePosixFileSystem
- Parameters:
path
- Must be from this file system.- Throws:
RandomFailFileSystem.RandomFailIOException
IOException
-
createFile
Description copied from interface:PosixFileSystem
Atomically creates an empty file (must not have already existed) with the given permissions.- Specified by:
createFile
in interfacePosixFileSystem
- Returns:
- returns the path
- Throws:
IOException
- if an underlying I/O error occurs.
-
createDirectory
Description copied from interface:PosixFileSystem
Atomically creates a directory (must not have already existed) with the given permissions.- Specified by:
createDirectory
in interfacePosixFileSystem
- Returns:
- returns the path
- Throws:
IOException
- if an underlying I/O error occurs.
-