提交 51a00e71 authored 作者: Thomas Mueller's avatar Thomas Mueller

Improved compatibility with the Java 7 FileSystem abstraction.

上级 bd00e7d3
......@@ -431,7 +431,7 @@ public class FileStore {
*/
public void sync() {
try {
file.sync();
file.force(true);
} catch (IOException e) {
throw DbException.convertIOException(e, name);
}
......
......@@ -58,9 +58,11 @@ public interface FileObject {
long position() throws IOException;
/**
* Force changes to the physical location.
* Force changes to the physical location (sync).
*
* @param metaData whether the file metadata should be written as well
*/
void sync() throws IOException;
void force(boolean metaData) throws IOException;
/**
* Change the length of the file.
......
......@@ -25,7 +25,7 @@ public class FileObjectDisk implements FileObject {
this.name = fileName;
}
public void sync() throws IOException {
public void force(boolean metaData) throws IOException {
String m = SysProperties.SYNC_METHOD;
if ("".equals(m)) {
// do nothing
......
......@@ -57,7 +57,7 @@ public class FileObjectMem implements FileObject {
pos = 0;
}
public void sync() {
public void force(boolean metaData) throws IOException {
// do nothing
}
......
......@@ -78,8 +78,8 @@ public class FileObjectNio implements FileObject {
length = newLength;
}
public void sync() throws IOException {
channel.force(true);
public void force(boolean metaData) throws IOException {
channel.force(metaData);
}
public void write(byte[] b, int off, int len) throws IOException {
......
......@@ -186,7 +186,7 @@ public class FileObjectNioMapped implements FileObject {
pos = (int) Math.min(newLength, oldPos);
}
public synchronized void sync() throws IOException {
public void force(boolean metaData) throws IOException {
mapped.force();
file.getFD().sync();
}
......
......@@ -49,8 +49,8 @@ public class FileObjectRec implements FileObject {
file.truncate(newLength);
}
public void sync() throws IOException {
file.sync();
public void force(boolean metaData) throws IOException {
file.force(metaData);
}
public void write(byte[] b, int off, int len) throws IOException {
......
......@@ -114,9 +114,9 @@ public class FileObjectSplit implements FileObject {
this.length = newLength;
}
public void sync() throws IOException {
public void force(boolean metaData) throws IOException {
for (FileObject f : list) {
f.sync();
f.force(metaData);
}
}
......
......@@ -96,7 +96,7 @@ public class FileObjectZip implements FileObject {
throw new IOException("File is read-only");
}
public void sync() {
public void force(boolean metaData) throws IOException {
// nothing to do
}
......
......@@ -316,7 +316,7 @@ public class TestFileSystem extends TestBase {
FileUtils.delete(s);
FileObject f = FileUtils.openFileObject(s, "rw");
assertThrows(EOFException.class, f).readFully(new byte[1], 0, 1);
f.sync();
f.force(true);
Random random = new Random(seed);
int size = getSize(100, 500);
try {
......
......@@ -56,9 +56,9 @@ public class FileDebug implements FileObject {
file.truncate(newLength);
}
public void sync() throws IOException {
debug("sync");
file.sync();
public void force(boolean metaData) throws IOException {
debug("force");
file.force(metaData);
}
public void write(byte[] b, int off, int len) throws IOException {
......
......@@ -85,8 +85,8 @@ public class FileObjectCrypt implements FileObject {
file.position(pos + HEADER_LENGTH);
}
public void sync() throws IOException {
file.sync();
public void force(boolean metaData) throws IOException {
file.force(metaData);
}
public FileLock tryLock() throws IOException {
......
......@@ -102,7 +102,7 @@ public class FileObjectZip2 implements FileObject {
throw new IOException("File is read-only");
}
public void sync() {
public void force(boolean metaData) throws IOException {
// nothing to do
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论