diff --git a/community/io/src/main/java/org/neo4j/io/pagecache/PageSwapperFactory.java b/community/io/src/main/java/org/neo4j/io/pagecache/PageSwapperFactory.java index d5af98b684859..de4b066cb5a31 100644 --- a/community/io/src/main/java/org/neo4j/io/pagecache/PageSwapperFactory.java +++ b/community/io/src/main/java/org/neo4j/io/pagecache/PageSwapperFactory.java @@ -41,20 +41,11 @@ public interface PageSwapperFactory { /** - * Configure page swapper factory with filesystem and config + * Open page swapper factory with provided filesystem and config * @param fs file system to use in page swappers * @param config custom page swapper configuration */ - void configure( FileSystemAbstraction fs, Configuration config ); - - /** - * Configure swapper with filesystem to use. - * @param fs file system to use in page swappers - */ - default void configure( FileSystemAbstraction fs ) - { - this.configure( fs, Configuration.EMPTY ); - } + void open( FileSystemAbstraction fs, Configuration config ); /** * Get the name of this PageSwapperFactory implementation, for configuration purpose. diff --git a/community/io/src/main/java/org/neo4j/io/pagecache/impl/SingleFilePageSwapperFactory.java b/community/io/src/main/java/org/neo4j/io/pagecache/impl/SingleFilePageSwapperFactory.java index 4fd225e2cbdf3..9ba02720c2bb5 100644 --- a/community/io/src/main/java/org/neo4j/io/pagecache/impl/SingleFilePageSwapperFactory.java +++ b/community/io/src/main/java/org/neo4j/io/pagecache/impl/SingleFilePageSwapperFactory.java @@ -46,7 +46,7 @@ public class SingleFilePageSwapperFactory implements PageSwapperFactory private FileSystemAbstraction fs; @Override - public void configure( FileSystemAbstraction fs, Configuration config ) + public void open( FileSystemAbstraction fs, Configuration config ) { this.fs = fs; } diff --git a/community/io/src/main/java/org/neo4j/io/pagecache/impl/muninn/StandalonePageCacheFactory.java b/community/io/src/main/java/org/neo4j/io/pagecache/impl/muninn/StandalonePageCacheFactory.java index 45d4bc9c48bcd..a1c0fb61b2260 100644 --- a/community/io/src/main/java/org/neo4j/io/pagecache/impl/muninn/StandalonePageCacheFactory.java +++ b/community/io/src/main/java/org/neo4j/io/pagecache/impl/muninn/StandalonePageCacheFactory.java @@ -19,6 +19,7 @@ */ package org.neo4j.io.pagecache.impl.muninn; +import org.neo4j.graphdb.config.Configuration; import org.neo4j.io.ByteUnit; import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.pagecache.PageCache; @@ -54,7 +55,7 @@ public static PageCache createPageCache( FileSystemAbstraction fileSystem, Integ PageCacheTracer tracer, PageCursorTracerSupplier cursorTracerSupplier ) { SingleFilePageSwapperFactory factory = new SingleFilePageSwapperFactory(); - factory.configure( fileSystem ); + factory.open( fileSystem, Configuration.EMPTY ); int cachePageSize = pageSize != null ? pageSize : factory.getCachePageSizeHint(); long pageCacheMemory = ByteUnit.mebiBytes( 8 ); diff --git a/community/io/src/test/java/org/neo4j/io/pagecache/PageCacheTest.java b/community/io/src/test/java/org/neo4j/io/pagecache/PageCacheTest.java index 3f1310806013a..66f5e2b76d4e8 100644 --- a/community/io/src/test/java/org/neo4j/io/pagecache/PageCacheTest.java +++ b/community/io/src/test/java/org/neo4j/io/pagecache/PageCacheTest.java @@ -59,6 +59,7 @@ import org.neo4j.adversaries.pagecache.AdversarialPagedFile; import org.neo4j.concurrent.BinaryLatch; import org.neo4j.function.ThrowingConsumer; +import org.neo4j.graphdb.config.Configuration; import org.neo4j.graphdb.mockfs.DelegatingFileSystemAbstraction; import org.neo4j.graphdb.mockfs.DelegatingStoreChannel; import org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction; @@ -3744,7 +3745,7 @@ public void force() throws IOException }; } }; - factory.configure( fs ); + factory.open( fs, Configuration.EMPTY ); return factory; } diff --git a/community/io/src/test/java/org/neo4j/io/pagecache/PageCacheTestSupport.java b/community/io/src/test/java/org/neo4j/io/pagecache/PageCacheTestSupport.java index 92d29765f5b30..722637104f608 100644 --- a/community/io/src/test/java/org/neo4j/io/pagecache/PageCacheTestSupport.java +++ b/community/io/src/test/java/org/neo4j/io/pagecache/PageCacheTestSupport.java @@ -37,6 +37,7 @@ import java.util.function.Function; import java.util.function.Supplier; +import org.neo4j.graphdb.config.Configuration; import org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction; import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.fs.StoreChannel; @@ -117,7 +118,7 @@ protected T createPageCache( FileSystemAbstraction fs, int maxPages, int pageSiz PageCursorTracerSupplier cursorTracerSupplier ) { PageSwapperFactory swapperFactory = new SingleFilePageSwapperFactory(); - swapperFactory.configure( fs ); + swapperFactory.open( fs, Configuration.EMPTY ); return createPageCache( swapperFactory, maxPages, pageSize, tracer, cursorTracerSupplier ); } diff --git a/community/io/src/test/java/org/neo4j/io/pagecache/impl/SingleFilePageSwapperTest.java b/community/io/src/test/java/org/neo4j/io/pagecache/impl/SingleFilePageSwapperTest.java index 4121cbb0dd049..eede6ed08a9c7 100644 --- a/community/io/src/test/java/org/neo4j/io/pagecache/impl/SingleFilePageSwapperTest.java +++ b/community/io/src/test/java/org/neo4j/io/pagecache/impl/SingleFilePageSwapperTest.java @@ -82,7 +82,7 @@ public void tearDown() throws Exception protected PageSwapperFactory swapperFactory() { SingleFilePageSwapperFactory factory = new SingleFilePageSwapperFactory(); - factory.configure( getFs(), Configuration.EMPTY ); + factory.open( getFs(), Configuration.EMPTY ); return factory; } @@ -236,7 +236,7 @@ public void creatingSwapperForFileMustTakeLockOnFile() throws Exception assumeFalse( "No file locking on Windows", SystemUtils.IS_OS_WINDOWS ); PageSwapperFactory factory = createSwapperFactory(); - factory.configure( fileSystem ); + factory.open( fileSystem, Configuration.EMPTY ); File file = testDir.file( "file" ); fileSystem.create( file ).close(); @@ -260,7 +260,7 @@ public void creatingSwapperForInternallyLockedFileMustThrow() throws Exception assumeFalse( "No file locking on Windows", SystemUtils.IS_OS_WINDOWS ); // no file locking on Windows. PageSwapperFactory factory = createSwapperFactory(); - factory.configure( fileSystem ); + factory.open( fileSystem, Configuration.EMPTY ); File file = testDir.file( "file" ); StoreFileChannel channel = fileSystem.create( file ); @@ -279,7 +279,7 @@ public void creatingSwapperForExternallyLockedFileMustThrow() throws Exception assumeFalse( "No file locking on Windows", SystemUtils.IS_OS_WINDOWS ); // no file locking on Windows. PageSwapperFactory factory = createSwapperFactory(); - factory.configure( fileSystem ); + factory.open( fileSystem, Configuration.EMPTY ); File file = testDir.file( "file" ); fileSystem.create( file ).close(); @@ -313,7 +313,7 @@ public void mustUnlockFileWhenThePageSwapperIsClosed() throws Exception assumeFalse( "No file locking on Windows", SystemUtils.IS_OS_WINDOWS ); // no file locking on Windows. PageSwapperFactory factory = createSwapperFactory(); - factory.configure( fileSystem ); + factory.open( fileSystem, Configuration.EMPTY ); File file = testDir.file( "file" ); fileSystem.create( file ).close(); @@ -332,7 +332,7 @@ public void fileMustRemainLockedEvenIfChannelIsClosedByStrayInterrupt() throws E assumeFalse( "No file locking on Windows", SystemUtils.IS_OS_WINDOWS ); // no file locking on Windows. PageSwapperFactory factory = createSwapperFactory(); - factory.configure( fileSystem ); + factory.open( fileSystem, Configuration.EMPTY ); File file = testDir.file( "file" ); fileSystem.create( file ).close(); @@ -361,7 +361,7 @@ public void mustCloseFilesIfTakingFileLockThrows() throws Exception final AtomicInteger openFilesCounter = new AtomicInteger(); PageSwapperFactory factory = createSwapperFactory(); - factory.configure( new DelegatingFileSystemAbstraction( fileSystem ) + factory.open( new DelegatingFileSystemAbstraction( fileSystem ) { @Override public StoreChannel open( File fileName, String mode ) throws IOException @@ -377,7 +377,7 @@ public void close() throws IOException } }; } - } ); + }, Configuration.EMPTY ); File file = testDir.file( "file" ); try ( StoreChannel ch = fileSystem.create( file ); FileLock ignore = ch.tryLock() ) @@ -422,7 +422,7 @@ public void mustHandleMischiefInPositionedRead() throws Exception ThreadLocalRandom.current().nextBytes( data ); PageSwapperFactory factory = createSwapperFactory(); - factory.configure( getFs() ); + factory.open( getFs(), Configuration.EMPTY ); File file = getFile(); PageSwapper swapper = createSwapper( factory, file, bytesTotal, NO_CALLBACK, true ); try @@ -435,7 +435,7 @@ public void mustHandleMischiefInPositionedRead() throws Exception } RandomAdversary adversary = new RandomAdversary( 0.5, 0.0, 0.0 ); - factory.configure( new AdversarialFileSystemAbstraction( adversary, getFs() ) ); + factory.open( new AdversarialFileSystemAbstraction( adversary, getFs() ), Configuration.EMPTY ); swapper = createSwapper( factory, file, bytesTotal, NO_CALLBACK, false ); ByteBufferPage page = createPage( bytesTotal ); @@ -467,7 +467,7 @@ public void mustHandleMischiefInPositionedWrite() throws Exception File file = getFile(); PageSwapperFactory factory = createSwapperFactory(); RandomAdversary adversary = new RandomAdversary( 0.5, 0.0, 0.0 ); - factory.configure( new AdversarialFileSystemAbstraction( adversary, getFs() ) ); + factory.open( new AdversarialFileSystemAbstraction( adversary, getFs() ), Configuration.EMPTY ); PageSwapper swapper = createSwapper( factory, file, bytesTotal, NO_CALLBACK, true ); ByteBufferPage page = createPage( bytesTotal ); @@ -503,7 +503,7 @@ public void mustHandleMischiefInPositionedVectoredRead() throws Exception ThreadLocalRandom.current().nextBytes( data ); PageSwapperFactory factory = createSwapperFactory(); - factory.configure( getFs() ); + factory.open( getFs(), Configuration.EMPTY ); File file = getFile(); PageSwapper swapper = createSwapper( factory, file, bytesTotal, NO_CALLBACK, true ); try @@ -516,7 +516,7 @@ public void mustHandleMischiefInPositionedVectoredRead() throws Exception } RandomAdversary adversary = new RandomAdversary( 0.5, 0.0, 0.0 ); - factory.configure( new AdversarialFileSystemAbstraction( adversary, getFs() ) ); + factory.open( new AdversarialFileSystemAbstraction( adversary, getFs() ), Configuration.EMPTY ); swapper = createSwapper( factory, file, bytesPerPage, NO_CALLBACK, false ); ByteBufferPage[] pages = new ByteBufferPage[pageCount]; @@ -562,7 +562,7 @@ public void mustHandleMischiefInPositionedVectoredWrite() throws Exception File file = getFile(); PageSwapperFactory factory = createSwapperFactory(); RandomAdversary adversary = new RandomAdversary( 0.5, 0.0, 0.0 ); - factory.configure( new AdversarialFileSystemAbstraction( adversary, getFs() ) ); + factory.open( new AdversarialFileSystemAbstraction( adversary, getFs() ), Configuration.EMPTY ); PageSwapper swapper = createSwapper( factory, file, bytesPerPage, NO_CALLBACK, true ); ByteBufferPage[] writePages = new ByteBufferPage[pageCount]; diff --git a/community/io/src/test/java/org/neo4j/io/pagecache/randomharness/RandomPageCacheTestHarness.java b/community/io/src/test/java/org/neo4j/io/pagecache/randomharness/RandomPageCacheTestHarness.java index 7f024b7e09153..5a1636bda4237 100644 --- a/community/io/src/test/java/org/neo4j/io/pagecache/randomharness/RandomPageCacheTestHarness.java +++ b/community/io/src/test/java/org/neo4j/io/pagecache/randomharness/RandomPageCacheTestHarness.java @@ -37,6 +37,7 @@ import org.neo4j.adversaries.RandomAdversary; import org.neo4j.adversaries.fs.AdversarialFileSystemAbstraction; +import org.neo4j.graphdb.config.Configuration; import org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction; import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.pagecache.PageSwapperFactory; @@ -382,7 +383,7 @@ private void runIteration( long timeout, TimeUnit unit ) throws Exception } PageSwapperFactory swapperFactory = new SingleFilePageSwapperFactory(); - swapperFactory.configure( fs ); + swapperFactory.open( fs, Configuration.EMPTY ); MuninnPageCache cache = new MuninnPageCache( swapperFactory, cachePageCount, cachePageSize, tracer, cursorTracerSupplier ); cache.setPrintExceptionsOnClose( false ); diff --git a/community/io/src/test/java/org/neo4j/io/pagecache/stress/PageCacheStressTest.java b/community/io/src/test/java/org/neo4j/io/pagecache/stress/PageCacheStressTest.java index 0bece2a7cdf3d..d16d9753e1145 100644 --- a/community/io/src/test/java/org/neo4j/io/pagecache/stress/PageCacheStressTest.java +++ b/community/io/src/test/java/org/neo4j/io/pagecache/stress/PageCacheStressTest.java @@ -21,6 +21,7 @@ import java.io.File; +import org.neo4j.graphdb.config.Configuration; import org.neo4j.io.fs.DefaultFileSystemAbstraction; import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.pagecache.PageCache; @@ -87,7 +88,7 @@ public void run() throws Exception try ( FileSystemAbstraction fs = new DefaultFileSystemAbstraction() ) { PageSwapperFactory swapperFactory = new SingleFilePageSwapperFactory(); - swapperFactory.configure( fs ); + swapperFactory.open( fs, Configuration.EMPTY ); try ( PageCache pageCacheUnderTest = new MuninnPageCache( swapperFactory, numberOfCachePages, cachePageSize, tracer, pageCursorTracerSupplier ) ) diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/pagecache/ConfiguringPageCacheFactory.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/pagecache/ConfiguringPageCacheFactory.java index 45154dbb36093..10d7592683965 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/pagecache/ConfiguringPageCacheFactory.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/pagecache/ConfiguringPageCacheFactory.java @@ -196,7 +196,7 @@ public void dumpConfiguration() private static PageSwapperFactory createAndConfigureSwapperFactory( FileSystemAbstraction fs, Config config, Log log ) { PageSwapperFactory factory = getPageSwapperFactory( config, log ); - factory.configure( fs, config ); + factory.open( fs, config ); return factory; } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/pagecache/PageSwapperFactoryForTesting.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/pagecache/PageSwapperFactoryForTesting.java index 68d01dafb4d5e..5d59dbddc8add 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/impl/pagecache/PageSwapperFactoryForTesting.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/pagecache/PageSwapperFactoryForTesting.java @@ -81,9 +81,9 @@ public Stream streamFilesRecursive( File directory ) } @Override - public void configure( FileSystemAbstraction fs, Configuration configuration ) + public void open( FileSystemAbstraction fs, Configuration configuration ) { - super.configure( fs, configuration ); + super.open( fs, configuration ); configuredCounter.getAndIncrement(); } }