Skip to content

Commit

Permalink
Only check for custom IO compatibility with online backup, if online …
Browse files Browse the repository at this point in the history
…backup is actaully enabled
  • Loading branch information
chrisvest committed Apr 21, 2016
1 parent 7fbb446 commit 49433ae
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Expand Up @@ -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;
Expand All @@ -41,7 +40,6 @@
public class OnlineBackupExtensionFactory extends KernelExtensionFactory<OnlineBackupExtensionFactory.Dependencies>
{
static final String KEY = "online backup";
static final String CUSTOM_IO_EXCEPTION_MESSAGE = "Online Backup not allowed with custom IO integration";

public interface Dependencies
{
Expand Down Expand Up @@ -80,8 +78,6 @@ public Class<OnlineBackupSettings> 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(),
Expand Down
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -121,6 +123,8 @@ public void start() throws Throwable
{
if ( config.<Boolean>get( OnlineBackupSettings.online_backup_enabled ) )
{
CustomIOConfigValidator.assertCustomIOConfigNotUsed( config, CUSTOM_IO_EXCEPTION_MESSAGE );

try
{
server = new BackupServer( backupProvider.newBackup(), config.get( online_backup_server ),
Expand Down
Expand Up @@ -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;
Expand All @@ -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 )
Expand Down

0 comments on commit 49433ae

Please sign in to comment.