Class DurableFiles

java.lang.Object
io.jenkins.plugins.batchcontrol.store.DurableFiles

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public final class DurableFiles extends Object
#34: the forced writes every store write goes through, as core's AtomicFileWriter does them. A file that replaces another is written and forced to disk before the atomic rename, and its directory is forced after it, so a power loss leaves either the old or the new file, never a zero-length one; an appended record is forced before the operation that wrote it reports success.

Forces go through FileChannel.force(boolean) (which the JDK reports as the jdk.FileForce event), never FileDescriptor.sync().

  • Method Details

    • writeForced

      public static void writeForced(Path tmp, byte[] bytes) throws IOException
      Writes bytes to the (new, empty) temporary file tmp and forces them to disk; the caller then renames it onto its target and calls forceDirectory(java.nio.file.Path).
      Throws:
      IOException
    • forceDirectory

      public static void forceDirectory(Path dir)
      Forces the directory entries of dir (a rename into it, a file created in it) to disk. Windows cannot open a directory as a channel, so it is skipped there, as core's AtomicFileWriter does; anywhere else a refusal is logged and does not fail the write, which has already taken effect.