diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/GBPTreeFileUtil.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/GBPTreeFileUtil.java
deleted file mode 100644
index 7abe7699df1df..0000000000000
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/GBPTreeFileUtil.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2002-2018 "Neo Technology,"
- * Network Engine for Objects in Lund AB [http://neotechnology.com]
- *
- * This file is part of Neo4j.
- *
- * Neo4j is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package org.neo4j.kernel.impl.index;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.NoSuchFileException;
-
-import org.neo4j.index.internal.gbptree.GBPTree;
-
-/**
- * Utilities for common operations around a {@link GBPTree}.
- */
-public interface GBPTreeFileUtil
-{
- /**
- * Deletes store file backing a {@link GBPTree}.
- * Undefined behaviour if storeFile is a directory.
- *
- * @param storeFile the {@link File} to delete.
- * @throws NoSuchFileException if the {@code storeFile} doesn't exist according to the {@code pageCache}.
- * @throws IOException on failure to delete existing {@code storeFile}.
- */
- void deleteFile( File storeFile ) throws IOException;
-
- /**
- * Deletes store file backing a {@link GBPTree}, if it exists according to the {@code pageCache}.
- * Undefined behaviour if storeFile is a directory.
- *
- * @param storeFile the {@link File} to delete.
- * @throws IOException on failure to delete existing {@code storeFile}.
- */
- void deleteFileIfPresent( File storeFile ) throws IOException;
-
- /**
- * Checks whether or not {@code storeFile} exists according to {@code pageCache}.
- * Undefined behaviour if storeFile is a directory.
- *
- * @param storeFile the {@link File} to check for existence.
- * @return {@code true} if {@code storeFile} exists according to {@code pageCache}, otherwise {@code false}.
- */
- boolean storeFileExists( File storeFile );
-
- /**
- * Creates the directory named by this abstract pathname, including any
- * necessary but nonexistent parent directories.
- *
- * @param dir the directory path to create
- * @throws IOException on failure to create directories.
- */
- void mkdirs( File dir ) throws IOException;
-}
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/labelscan/NativeLabelScanStore.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/labelscan/NativeLabelScanStore.java
index 341fc70ffbf5b..c8405984c0769 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/labelscan/NativeLabelScanStore.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/labelscan/NativeLabelScanStore.java
@@ -44,8 +44,6 @@
import org.neo4j.kernel.api.labelscan.LabelScanStore;
import org.neo4j.kernel.api.labelscan.LabelScanWriter;
import org.neo4j.kernel.impl.api.scan.FullStoreChangeStream;
-import org.neo4j.kernel.impl.index.GBPTreeFileUtil;
-import org.neo4j.kernel.impl.index.schema.GBPTreeFileSystemFileUtil;
import org.neo4j.kernel.impl.store.UnderlyingStorageException;
import org.neo4j.kernel.monitoring.Monitors;
import org.neo4j.storageengine.api.schema.LabelScanReader;
@@ -135,7 +133,7 @@ public class NativeLabelScanStore implements LabelScanStore
/**
* Used for all file operations on the gbpTree file.
*/
- private final GBPTreeFileUtil gbpTreeUtil;
+ private final FileSystemAbstraction fileSystem;
/**
* The index which backs this label scan store. Instantiated in {@link #init()} and considered
@@ -193,7 +191,7 @@ public NativeLabelScanStore( PageCache pageCache, File storeDir, FileSystemAbstr
this.monitors = monitors;
this.monitor = monitors.newMonitor( Monitor.class );
this.recoveryCleanupWorkCollector = recoveryCleanupWorkCollector;
- this.gbpTreeUtil = new GBPTreeFileSystemFileUtil( fs );
+ this.fileSystem = fs;
}
/**
@@ -352,7 +350,7 @@ public void init() throws IOException
@Override
public boolean hasStore()
{
- return gbpTreeUtil.storeFileExists( storeFile );
+ return fileSystem.fileExists( storeFile );
}
@Override
@@ -412,7 +410,7 @@ private void dropStrict() throws IOException
index.close();
index = null;
}
- gbpTreeUtil.deleteFile( storeFile );
+ fileSystem.deleteFileOrThrow( storeFile );
}
/**
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/GBPTreeFileSystemFileUtil.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/GBPTreeFileSystemFileUtil.java
deleted file mode 100644
index d2b67b22d1b84..0000000000000
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/GBPTreeFileSystemFileUtil.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2002-2018 "Neo Technology,"
- * Network Engine for Objects in Lund AB [http://neotechnology.com]
- *
- * This file is part of Neo4j.
- *
- * Neo4j is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package org.neo4j.kernel.impl.index.schema;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.NoSuchFileException;
-
-import org.neo4j.io.fs.FileSystemAbstraction;
-import org.neo4j.kernel.impl.index.GBPTreeFileUtil;
-
-public class GBPTreeFileSystemFileUtil implements GBPTreeFileUtil
-{
- private final FileSystemAbstraction fs;
-
- public GBPTreeFileSystemFileUtil( FileSystemAbstraction fs )
- {
- this.fs = fs;
- }
-
- @Override
- public void deleteFile( File storeFile ) throws IOException
- {
- fs.deleteFileOrThrow( storeFile );
- }
-
- @Override
- public void deleteFileIfPresent( File storeFile ) throws IOException
- {
- try
- {
- deleteFile( storeFile );
- }
- catch ( NoSuchFileException e )
- {
- // File does not exist, we don't need to delete
- }
- }
-
- @Override
- public boolean storeFileExists( File storeFile )
- {
- return fs.fileExists( storeFile );
- }
-
- @Override
- public void mkdirs( File dir ) throws IOException
- {
- fs.mkdirs( dir );
- }
-}
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndex.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndex.java
index cd8ebaded1253..472d297d4978b 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndex.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndex.java
@@ -32,7 +32,6 @@
import org.neo4j.io.pagecache.PageCursor;
import org.neo4j.kernel.api.index.IndexProvider;
import org.neo4j.kernel.api.schema.index.SchemaIndexDescriptor;
-import org.neo4j.kernel.impl.index.GBPTreeFileUtil;
import static org.neo4j.helpers.Format.duration;
import static org.neo4j.helpers.collection.MapUtil.map;
@@ -43,7 +42,7 @@ abstract class NativeSchemaIndex, VALUE extends
final PageCache pageCache;
final File storeFile;
final Layout layout;
- final GBPTreeFileUtil gbpTreeFileUtil;
+ final FileSystemAbstraction fileSystem;
final SchemaIndexDescriptor descriptor;
private final long indexId;
private final IndexProvider.Monitor monitor;
@@ -56,7 +55,7 @@ abstract class NativeSchemaIndex, VALUE extends
this.pageCache = pageCache;
this.storeFile = storeFile;
this.layout = layout;
- this.gbpTreeFileUtil = new GBPTreeFileSystemFileUtil( fs );
+ this.fileSystem = fs;
this.descriptor = descriptor;
this.indexId = indexId;
this.monitor = monitor;
@@ -87,7 +86,7 @@ public void cleanupFinished( long numberOfPagesVisited, long numberOfCleanedCras
private void ensureDirectoryExist() throws IOException
{
- gbpTreeFileUtil.mkdirs( storeFile.getParentFile() );
+ fileSystem.mkdirs( storeFile.getParentFile() );
}
void closeTree() throws IOException
@@ -95,7 +94,7 @@ void closeTree() throws IOException
tree = closeIfPresent( tree );
}
- T closeIfPresent( T closeable ) throws IOException
+ private T closeIfPresent( T closeable ) throws IOException
{
if ( closeable != null )
{
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndexAccessor.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndexAccessor.java
index 5abf2c71e2703..5f746808baac0 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndexAccessor.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndexAccessor.java
@@ -69,7 +69,7 @@ public abstract class NativeSchemaIndexAccessor
public void drop() throws IOException
{
closeTree();
- gbpTreeFileUtil.deleteFile( storeFile );
+ fileSystem.deleteFileOrThrow( storeFile );
}
@Override
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndexPopulator.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndexPopulator.java
index 69382c8d8de75..00a5b571933d2 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndexPopulator.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/NativeSchemaIndexPopulator.java
@@ -23,6 +23,7 @@
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
+import java.nio.file.NoSuchFileException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.ExecutionException;
@@ -106,7 +107,7 @@ public abstract class NativeSchemaIndexPopulator headerWriter ) throws I
assertNotDropped();
assertNotClosed();
- gbpTreeFileUtil.deleteFileIfPresent( storeFile );
+ deleteFileIfPresent( fileSystem, storeFile );
instantiateTree( RecoveryCleanupWorkCollector.IMMEDIATE, headerWriter );
// true: tree uniqueness is (value,entityId)
@@ -139,7 +140,7 @@ public synchronized void drop()
try
{
closeTree();
- gbpTreeFileUtil.deleteFileIfPresent( storeFile );
+ deleteFileIfPresent( fileSystem, storeFile );
}
catch ( IOException e )
{
@@ -390,4 +391,16 @@ public IndexSample sampleResult()
throw new IllegalArgumentException( "Unexpected index type " + descriptor.type() );
}
}
+
+ private static void deleteFileIfPresent( FileSystemAbstraction fs, File storeFile ) throws IOException
+ {
+ try
+ {
+ fs.deleteFileOrThrow( storeFile );
+ }
+ catch ( NoSuchFileException e )
+ {
+ // File does not exist, we don't need to delete
+ }
+ }
}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/AbstractGBPTreeFileUtilTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/AbstractGBPTreeFileUtilTest.java
deleted file mode 100644
index 1aac07bee69bc..0000000000000
--- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/AbstractGBPTreeFileUtilTest.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 2002-2018 "Neo Technology,"
- * Network Engine for Objects in Lund AB [http://neotechnology.com]
- *
- * This file is part of Neo4j.
- *
- * Neo4j is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package org.neo4j.kernel.impl.index;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.NoSuchFileException;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public abstract class AbstractGBPTreeFileUtilTest
-{
- private GBPTreeFileUtil fileUtil;
- private File existingFile;
- private File nonExistingFile;
- private File nonExistingDirectory;
-
- @Before
- public void setup() throws IOException
- {
- this.fileUtil = getGBPTreeFileUtil();
- this.existingFile = existingFile( "existing_file" );
- this.nonExistingFile = nonExistingFile( "non_existing_file" );
- this.nonExistingDirectory = nonExistingDirectory( "non_existing_directory" );
- }
-
- @After
- public void cleanUp()
- {
- }
-
- protected abstract GBPTreeFileUtil getGBPTreeFileUtil();
-
- protected abstract File existingFile( String fileName ) throws IOException;
-
- protected abstract File nonExistingFile( String fileName );
-
- protected abstract File nonExistingDirectory( String directoryName );
-
- protected abstract void assertFileDoesNotExist( File file );
-
- protected abstract void assertDirectoryExist( File directory );
-
- /* deleteFile( File storeFile ) */
-
- @Test
- public void fileMustNotExistAfterDeleteFile() throws Exception
- {
- // given
- // when
- fileUtil.deleteFile( existingFile );
-
- // then
- assertFileDoesNotExist( existingFile );
- }
-
- @Test
- public void deleteFileMustThrowIfFileIsMissing() throws Exception
- {
- // given
- // when
- try
- {
- fileUtil.deleteFile( nonExistingFile );
- fail( "Should have failed" );
- }
- catch ( NoSuchFileException e )
- {
- // then
- }
- }
-
- /* deleteIfPresent( File storeFile ) */
-
- @Test
- public void deleteFileIfPresentMustDeleteFileIfPresent() throws Exception
- {
- // given
- // when
- fileUtil.deleteFileIfPresent( existingFile );
-
- // then
- assertFileDoesNotExist( existingFile );
- }
-
- @Test
- public void deleteFileIfPresentMustNotThrowIfFileIsMissing() throws Exception
- {
- // given
- // when
- fileUtil.deleteFileIfPresent( nonExistingFile );
-
- // then
- // this should be fine
- }
-
- /* boolean storeFileExists( File storeFile ) */
-
- @Test
- public void storeFileExistsMustReturnTrueForExistingFile()
- {
- assertTrue( fileUtil.storeFileExists( existingFile ) );
- }
-
- @Test
- public void storeFileExistsMustReturnFalseForNonExistingFile()
- {
- assertFalse( fileUtil.storeFileExists( nonExistingFile ) );
- }
-
- /* mkdirs( File dir ) */
-
- @Test
- public void directoryMustExistAfterMkdirs() throws Exception
- {
- // given
- // when
- fileUtil.mkdirs( nonExistingDirectory );
-
- // then
- assertDirectoryExist( nonExistingDirectory );
- }
-}
diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/GBPTreeFileUtilTest.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/GBPTreeFileUtilTest.java
deleted file mode 100644
index 155ee791d1b5b..0000000000000
--- a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/GBPTreeFileUtilTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2002-2018 "Neo Technology,"
- * Network Engine for Objects in Lund AB [http://neotechnology.com]
- *
- * This file is part of Neo4j.
- *
- * Neo4j is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package org.neo4j.kernel.impl.index;
-
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.neo4j.io.fs.FileSystemAbstraction;
-import org.neo4j.kernel.impl.index.schema.GBPTreeFileSystemFileUtil;
-import org.neo4j.test.rule.PageCacheAndDependenciesRule;
-import org.neo4j.test.rule.TestDirectory;
-import org.neo4j.test.rule.fs.DefaultFileSystemRule;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-@RunWith( Parameterized.class )
-public class GBPTreeFileUtilTest extends AbstractGBPTreeFileUtilTest
-{
- @ClassRule
- public static PageCacheAndDependenciesRule pageCacheAndDependenciesRule = new PageCacheAndDependenciesRule(
- DefaultFileSystemRule::new, GBPTreeFileUtilTest.class
- );
-
- private static FileSystemAbstraction fs;
- private static TestDirectory directory;
-
- @BeforeClass
- public static void extractFileSystem()
- {
- fs = pageCacheAndDependenciesRule.fileSystem();
- directory = pageCacheAndDependenciesRule.directory();
- }
-
- @Parameterized.Parameters( name = "{0}" )
- public static Collection fileUtils()
- {
- return Arrays.asList( new GBPTreeFileSystemFileUtil( pageCacheAndDependenciesRule.fileSystem() ) );
- }
-
- @Parameterized.Parameter
- public GBPTreeFileUtil gbpTreeFileUtil;
-
- @Override
- protected GBPTreeFileUtil getGBPTreeFileUtil()
- {
- return gbpTreeFileUtil;
- }
-
- @Override
- protected File existingFile( String fileName ) throws IOException
- {
- File file = directory.file( fileName );
- fs.create( file ).close();
- return file;
- }
-
- @Override
- protected File nonExistingFile( String fileName )
- {
- return directory.file( fileName );
- }
-
- @Override
- protected File nonExistingDirectory( String directoryName )
- {
- return new File( directory.absolutePath(), directoryName );
- }
-
- @Override
- protected void assertFileDoesNotExist( File file )
- {
- assertFalse( fs.fileExists( file ) );
- }
-
- @Override
- protected void assertDirectoryExist( File directory )
- {
- assertTrue( fs.fileExists( directory ) );
- assertTrue( fs.isDirectory( directory ) );
- }
-}