improving fallocate check on libaio
This commit is contained in:
parent
b2a8cb22d0
commit
30a3bfb2a4
|
@ -22,7 +22,7 @@ import java.nio.ByteBuffer;
|
||||||
/**
|
/**
|
||||||
* This is an extension to use libaio.
|
* 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;
|
protected boolean open;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,6 +46,28 @@ public class LibaioTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void testAIO() {
|
public static void testAIO() {
|
||||||
Assume.assumeTrue(LibaioContext.isLoaded());
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue