improving fallocate check on libaio

This commit is contained in:
Clebert Suconic 2016-08-01 17:12:08 -04:00
parent b2a8cb22d0
commit 30a3bfb2a4
2 changed files with 23 additions and 1 deletions

View File

@ -22,7 +22,7 @@ import java.nio.ByteBuffer;
/**
* This is an extension to use libaio.
*/
public final class LibaioFile<Callback extends SubmitInfo> {
public final class LibaioFile<Callback extends SubmitInfo> implements AutoCloseable {
protected boolean open;
/**

View File

@ -46,6 +46,28 @@ public class LibaioTest {
@BeforeClass
public static void testAIO() {
Assume.assumeTrue(LibaioContext.isLoaded());
File parent = new File("./target");
File file = new File(parent, "testFile");
try {
parent.mkdirs();
boolean failed = false;
try (LibaioContext control = new LibaioContext<>(1, true); LibaioFile fileDescriptor = control.openFile(file, true)) {
fileDescriptor.fallocate(4 * 1024);
}
catch (Exception e) {
e.printStackTrace();
failed = true;
}
Assume.assumeFalse("There is not enough support to libaio", failed);
}
finally {
file.delete();
}
}
/**