From 49433ae7ae5b2969869bc91dafb20b9502005657 Mon Sep 17 00:00:00 2001 From: Chris Vest Date: Thu, 21 Apr 2016 10:47:37 +0200 Subject: [PATCH] Only check for custom IO compatibility with online backup, if online backup is actaully enabled --- .../backup/OnlineBackupExtensionFactory.java | 4 ---- .../backup/OnlineBackupKernelExtension.java | 4 ++++ .../backup/PlatformConstraintBackupTest.java | 19 ++++++++++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/enterprise/backup/src/main/java/org/neo4j/backup/OnlineBackupExtensionFactory.java b/enterprise/backup/src/main/java/org/neo4j/backup/OnlineBackupExtensionFactory.java index dd982f09c3af..75870e8ad29d 100644 --- a/enterprise/backup/src/main/java/org/neo4j/backup/OnlineBackupExtensionFactory.java +++ b/enterprise/backup/src/main/java/org/neo4j/backup/OnlineBackupExtensionFactory.java @@ -32,7 +32,6 @@ import org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore; import org.neo4j.kernel.impl.transaction.log.TransactionIdStore; import org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer; -import org.neo4j.kernel.impl.util.CustomIOConfigValidator; import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.kernel.lifecycle.Lifecycle; import org.neo4j.kernel.monitoring.Monitors; @@ -41,7 +40,6 @@ public class OnlineBackupExtensionFactory extends KernelExtensionFactory { static final String KEY = "online backup"; - static final String CUSTOM_IO_EXCEPTION_MESSAGE = "Online Backup not allowed with custom IO integration"; public interface Dependencies { @@ -80,8 +78,6 @@ public Class getSettingsClass() @Override public Lifecycle newInstance( KernelContext context, Dependencies dependencies ) throws Throwable { - CustomIOConfigValidator.assertCustomIOConfigNotUsed( dependencies.getConfig(), CUSTOM_IO_EXCEPTION_MESSAGE ); - return new OnlineBackupKernelExtension( dependencies.getConfig(), dependencies.getGraphDatabaseAPI(), dependencies.logService().getInternalLogProvider(), dependencies.monitors(), dependencies.neoStoreDataSource(), diff --git a/enterprise/backup/src/main/java/org/neo4j/backup/OnlineBackupKernelExtension.java b/enterprise/backup/src/main/java/org/neo4j/backup/OnlineBackupKernelExtension.java index 18bb528397e6..777f583613d6 100644 --- a/enterprise/backup/src/main/java/org/neo4j/backup/OnlineBackupKernelExtension.java +++ b/enterprise/backup/src/main/java/org/neo4j/backup/OnlineBackupKernelExtension.java @@ -34,6 +34,7 @@ import org.neo4j.com.monitor.RequestMonitor; import org.neo4j.com.storecopy.StoreCopyServer; import org.neo4j.io.fs.FileSystemAbstraction; +import org.neo4j.kernel.impl.util.CustomIOConfigValidator; import org.neo4j.kernel.internal.GraphDatabaseAPI; import org.neo4j.kernel.NeoStoreDataSource; import org.neo4j.kernel.configuration.Config; @@ -52,6 +53,7 @@ public class OnlineBackupKernelExtension implements Lifecycle { + static final String CUSTOM_IO_EXCEPTION_MESSAGE = "Online Backup not allowed with custom IO integration"; private Object startBindingListener; private Object bindingListener; @@ -121,6 +123,8 @@ public void start() throws Throwable { if ( config.get( OnlineBackupSettings.online_backup_enabled ) ) { + CustomIOConfigValidator.assertCustomIOConfigNotUsed( config, CUSTOM_IO_EXCEPTION_MESSAGE ); + try { server = new BackupServer( backupProvider.newBackup(), config.get( online_backup_server ), diff --git a/enterprise/backup/src/test/java/org/neo4j/backup/PlatformConstraintBackupTest.java b/enterprise/backup/src/test/java/org/neo4j/backup/PlatformConstraintBackupTest.java index 3aa350f3d2e0..6d63ba004a4e 100644 --- a/enterprise/backup/src/test/java/org/neo4j/backup/PlatformConstraintBackupTest.java +++ b/enterprise/backup/src/test/java/org/neo4j/backup/PlatformConstraintBackupTest.java @@ -26,6 +26,7 @@ import java.io.File; import org.neo4j.graphdb.GraphDatabaseService; +import org.neo4j.graphdb.factory.GraphDatabaseBuilder; import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.kernel.configuration.Settings; import org.neo4j.test.TargetDirectory; @@ -48,20 +49,32 @@ public void setup() } @Test - public void shouldFailToStartWithCustomIOConfigurationTest() + public void shouldFailToStartWithCustomIOConfiguration() { try { - createGraphDatabaseService(); + GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( workingDir ); + builder.setConfig( OnlineBackupSettings.online_backup_enabled, Settings.TRUE ); + builder.setConfig( GraphDatabaseSettings.pagecache_swapper, "custom" ); + builder.newGraphDatabase(); fail( "Should not have created database with custom IO configuration and online backup." ); } catch ( RuntimeException ex ) { - assertEquals( OnlineBackupExtensionFactory.CUSTOM_IO_EXCEPTION_MESSAGE, + assertEquals( OnlineBackupKernelExtension.CUSTOM_IO_EXCEPTION_MESSAGE, ex.getCause().getCause().getMessage() ); } } + @Test + public void shouldNotFailToStartWithCustomIOConfigurationWhenOnlineBackupIsDisabled() throws Exception + { + GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( workingDir ); + builder.setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ); + builder.setConfig( GraphDatabaseSettings.pagecache_swapper, "custom" ); + builder.newGraphDatabase().shutdown(); + } + private GraphDatabaseService createGraphDatabaseService() { return new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( workingDir )