Hi,
XADisk looks like a very promising library for atomic file system transactions. Better than Apache Transactions in any case.
We are using directories with many file already and copy large parts of one directory to the next to archive the state.
To save disk space we use hard links (Java code example below) when copying.
I understand that XADisk allows to create safe-points and restore state to them later - the same we crudely can do by copying the directories back.
So we might not need the hard-linked directories at all.
But the hard-linked directories provide the additional benefit of being easily inspectable on disk for maintenance.
So my real question is this:
**Would it be difficult to extend XADisk with atomic hard-link creation?**
I tried to understand how e.g. copy() works, but got lost in writing change records to journal streams deep in the internals.
But it should be easy to do this atomically as hard-linking requires no data IO and the OS call is already atomic I believe.
What do you think?
Gunnar
hard-link code example:
if (Misc.isLinux()) {
LinuxFunctions.hardlink(src, dest);
return;
} else if (Misc.isWindows()) {
WindowsFunctions.hardlink(src, dest);
return;
}
throw ...
where
public static void hardlink(final File src, final File dest) throws IOException {
if (LibC.LIBC.link(src.toString(), dest.toString()) != 0) {
throw ...
}
and using JNA for libc (and Win Kernel32) calls.