Suppose I want to get several file properties (owner, size, permissions, time) returned by the lstat () system call. One way to do this in Java is to create a java.io.File object and call it calls such as length (), lastModified (), etc. So far I have two problems:
Each of these calls causes a call to stat (), and for my purposes, stat () s is considered expensive: I try to scan billions of files in parallel on hundreds of hosts and (until the first approximation), the only way to access these files is through NFS, often against filter clusters, where stat () under load can take half a second.
The call is not lstat (), it is usually stat () (which follows symbolic links) or fstat64 () (which opens a file and can initiate a write operation to record access time).
Is there a βrightβ way to do this, so that I end up making only one call to lstat () and accessing the members of the struct stat? What I have found so far from Googling:
JDK 7 will have the PosixFileAttributes interface in the java.nio.file with everything I want (but I would prefer not to be quick nightly builds of my JDK if I can avoid it).
I can minimize my own interface with JNI or JNA (but I would prefer not to have an existing one).
A previous similar question got a couple of proposed JNI / JNA implementations. One of them disappeared, and the other is doubtfully supported (for example, no downloads, only the hg repository).
Are there any better options out there?
source
share