summaryrefslogtreecommitdiff
path: root/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/util/src/com/intellij/util/io/RandomAccessDataFile.java')
-rw-r--r--platform/util/src/com/intellij/util/io/RandomAccessDataFile.java29
1 files changed, 25 insertions, 4 deletions
diff --git a/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java b/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java
index 9a297bcef6d1..d4383a55d03e 100644
--- a/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java
+++ b/platform/util/src/com/intellij/util/io/RandomAccessDataFile.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,11 +47,11 @@ public class RandomAccessDataFile implements Forceable, Closeable {
private static final boolean DEBUG = false;
- public RandomAccessDataFile(final File file) throws IOException {
+ public RandomAccessDataFile(@NotNull File file) throws IOException {
this(file, PagePool.SHARED);
}
- public RandomAccessDataFile(final File file, final PagePool pool) throws IOException {
+ public RandomAccessDataFile(@NotNull File file, @NotNull PagePool pool) throws IOException {
myPool = pool;
myFile = file;
if (!file.exists()) {
@@ -201,6 +201,9 @@ public class RandomAccessDataFile implements Forceable, Closeable {
dispose();
}
+ /**
+ * Flushes dirty pages to underlying buffers
+ */
@Override
public void force() {
assertNotDisposed();
@@ -210,6 +213,23 @@ public class RandomAccessDataFile implements Forceable, Closeable {
}
}
+ /**
+ * Flushes dirty pages to buffers and saves them to disk
+ */
+ public void sync() {
+ force();
+ try {
+ RandomAccessFile file = getRandomAccessFile();
+ file.getChannel().force(true);
+ }
+ catch (IOException ignored) {
+
+ }
+ finally {
+ releaseFile();
+ }
+ }
+
public void flushSomePages(int maxPagesToFlush) {
assertNotDisposed();
if (isDirty()) {
@@ -229,7 +249,7 @@ public class RandomAccessDataFile implements Forceable, Closeable {
private void assertNotDisposed() {
if (myIsDisposed) {
- LOG.assertTrue(false, "storage file is disposed: " + myFile);
+ LOG.error("storage file is disposed: " + myFile);
}
}
@@ -316,6 +336,7 @@ public class RandomAccessDataFile implements Forceable, Closeable {
file.seek(fileOffset);
}
+ @Override
public int hashCode() {
return myCount;
}