Package org.h2.test.utils
Class FilePathReorderWrites
- java.lang.Object
-
- org.h2.store.fs.FilePath
-
- org.h2.store.fs.FilePathWrapper
-
- org.h2.test.utils.FilePathReorderWrites
-
public class FilePathReorderWrites extends FilePathWrapper
An unstable file system. It is used to simulate file system problems (for example out of disk space).
-
-
Constructor Summary
Constructors Constructor Description FilePathReorderWrites()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete()Delete a file or directory if it exists.longgetMaxAge()intgetPowerOffCountdown()java.lang.StringgetScheme()Get the scheme (prefix) for this file provider.java.nio.channels.FileChannelopen(java.lang.String mode)Open a random access file object.static FilePathReorderWritesregister()Register the file system.static voidsetPartialWrites(boolean b)Whether partial writes are possible (writing only part of the data).voidsetPowerOffCountdown(int count, int seed)Set the number of write operations before a simulated power failure, and the random seed (for partial writes).-
Methods inherited from class org.h2.store.fs.FilePathWrapper
canWrite, createDirectory, createFile, createTempFile, exists, getBase, getParent, getPath, getPrefix, isAbsolute, isDirectory, isRegularFile, lastModified, moveTo, newDirectoryStream, newInputStream, newOutputStream, setReadOnly, size, toRealPath, unwrap, unwrap, wrap
-
Methods inherited from class org.h2.store.fs.FilePath
get, getName, newFileChannelOutputStream, register, toString, unregister
-
-
-
-
Method Detail
-
register
public static FilePathReorderWrites register()
Register the file system.- Returns:
- the instance
-
setPowerOffCountdown
public void setPowerOffCountdown(int count, int seed)Set the number of write operations before a simulated power failure, and the random seed (for partial writes).- Parameters:
count- the number of write operations (0 to never fail, Integer.MAX_VALUE to count the operations)seed- the new seed
-
getPowerOffCountdown
public int getPowerOffCountdown()
-
setPartialWrites
public static void setPartialWrites(boolean b)
Whether partial writes are possible (writing only part of the data).- Parameters:
b- true to enable
-
open
public java.nio.channels.FileChannel open(java.lang.String mode) throws java.io.IOExceptionDescription copied from class:FilePathOpen a random access file object.- Overrides:
openin classFilePathWrapper- Parameters:
mode- the access mode. Supported are r, rw, rws, rwd- Returns:
- the file object
- Throws:
java.io.IOException- If an I/O error occurs
-
getScheme
public java.lang.String getScheme()
Description copied from class:FilePathGet the scheme (prefix) for this file provider. This is similar tojava.nio.file.spi.FileSystemProvider.getScheme.
-
getMaxAge
public long getMaxAge()
-
delete
public void delete()
Description copied from class:FilePathDelete a file or directory if it exists. Directories may only be deleted if they are empty.- Overrides:
deletein classFilePathWrapper
-
-