File system cache
@@ -49,6 +49,7 @@ import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
+import java.nio.file.FileStore;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -87,6 +88,8 @@ public class ODiskWriteAheadLog extends OAbstractWriteAheadLog {
private final Path walLocation;
private final FileChannel masterRecordLSNHolder;
+ private final ThreadLocal<FileStore> thFileStore;
+
/**
* If file of {@link OLogSegmentV2} will not be accessed inside of this interval (in seconds) it will be closed by timer.
*/
@@ -195,6 +198,19 @@ public class ODiskWriteAheadLog extends OAbstractWriteAheadLog {
try {
this.walLocation = calculateWalPath(this.storage, walPath);
+ thFileStore = new ThreadLocal<FileStore>() {
+ @Override
+ protected FileStore initialValue() {
+ try {
+ return Files.getFileStore(walLocation);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+ };
+
Stream<Path> walFiles;
final Locale locale = storage.getConfiguration().getLocaleInstance();
@@ -1160,7 +1176,7 @@ public class ODiskWriteAheadLog extends OAbstractWriteAheadLog {
}
public void checkFreeSpace() throws IOException {
- freeSpace = Files.getFileStore(walLocation).getUsableSpace();
+ freeSpace = thFileStore.get().getUsableSpace();
//system has unlimited amount of free space
if (freeSpace < 0)
