Skip to content

Commit

Permalink
Checks if custom IO configurations conflict with other options.
Browse files Browse the repository at this point in the history
Custom IO configurations are now supported in single instance mode.
Store copy operations are not supported, and that therefore excludes
using custom IO configurations in HA, online backup, and store migration.
Determining if you violate these restrictions is most easily done by
inspecting config options. This restriction is expected to be short lived and
can be removed once store copy is supported with custom IO configurations.
  • Loading branch information
Max Sumrall committed Apr 12, 2016
1 parent a8f3d37 commit eb83262
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public NeoStoreDataSource(
RecordFormats formats )
{
this.storeDir = storeDir;
this.config = config;
this.config = validateSettingsForPageSwapper( config );
this.tokenNameLookup = tokenNameLookup;
this.dependencyResolver = dependencyResolver;
this.scheduler = scheduler;
Expand Down Expand Up @@ -398,6 +398,36 @@ public Iterable<IndexImplementation> all()
this.pageCache = pageCache;
}

/**
* Custom IO integrations are partially supported, but the features below are not functional yet.
* When those features are available, this check can be removed entirely.
* This will allow us to ship the custom IO integration for experimental use, and protect users from
* using it with the currently unsupported features. i.e using custom IO integration in HA mode.
*/
private Config validateSettingsForPageSwapper( Config config )
{
if ( config.get( GraphDatabaseSettings.pagecache_swapper ) != null )
{
if ( config.get( GraphDatabaseSettings.allow_store_upgrade ) )
{
throw new IllegalArgumentException( "Store upgrade not allowed with custom IO integrations" );
}
String onlineBackup = config.getParams().get( "dbms.backup.enabled" );
if ( onlineBackup != null && !onlineBackup.equals( "false" ) )
{
throw new IllegalArgumentException( "Online Backup not allowed with custom IO integration" );
}
for ( String configKey : config.getParams().keySet() )
{
if ( configKey.contains( "ha." ) )
{
throw new IllegalArgumentException( "HA mode not allowed with custom IO integrations" );
}
}
}
return config;
}

@Override
public void init()
{ // We do our own internal life management:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2002-2016 "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 <http://www.gnu.org/licenses/>.
*/
package upgrade;

import org.junit.Rule;
import org.junit.Test;

import org.neo4j.graphdb.factory.GraphDatabaseBuilder;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.kernel.configuration.Settings;
import org.neo4j.test.TargetDirectory;
import org.neo4j.test.TestGraphDatabaseFactory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

public class PlatformConstraintStoreUpgradeTest
{
@Rule
public TargetDirectory.TestDirectory storeDir = TargetDirectory.testDirForTest( getClass() );

@Test
public void shouldFailToStartIfConfiguredForCAPIDeviceTest()
{
GraphDatabaseBuilder gdBuilder =
new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( storeDir.graphDbDir() );
gdBuilder.setConfig( GraphDatabaseSettings.allow_store_upgrade, Settings.TRUE )
.setConfig( GraphDatabaseSettings.pagecache_swapper, "custom" );
try
{
gdBuilder.newGraphDatabase();
fail( "Should not have created database with custom IO configuration and Store Upgrade." );
}
catch ( RuntimeException ex )
{
// good
assertEquals( "Store upgrade not allowed with custom IO integrations", ex.getMessage() );
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2002-2016 "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 Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.backup;

import org.junit.Rule;
import org.junit.Test;

import org.neo4j.cluster.ClusterSettings;
import org.neo4j.graphdb.factory.GraphDatabaseBuilder;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.kernel.configuration.Settings;
import org.neo4j.test.TargetDirectory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

public class PlatformConstraintBackupTest
{
@Rule
public TargetDirectory.TestDirectory storeDir = TargetDirectory.testDirForTest( getClass() );

@Test
public void shouldFailToStartIfConfiguredForCAPIDeviceTest()
{
GraphDatabaseFactory graphDatabaseFactory = new GraphDatabaseFactory();
GraphDatabaseBuilder gdBuilder = graphDatabaseFactory.newEmbeddedDatabaseBuilder( storeDir.graphDbDir() );
gdBuilder.setConfig( OnlineBackupSettings.online_backup_enabled, Settings.TRUE )
.setConfig( GraphDatabaseSettings.pagecache_swapper, "custom" );
try
{
gdBuilder.newGraphDatabase();
fail( "Should not have created database with custom IO configuration and Online Backup." );
}
catch ( RuntimeException ex )
{
// good
assertEquals( "Online Backup not allowed with custom IO integration", ex.getMessage() );
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2002-2016 "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 Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.graphdb.factory;

import org.junit.Rule;
import org.junit.Test;

import java.io.File;

import org.neo4j.cluster.ClusterSettings;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.kernel.api.index.PreexistingIndexEntryConflictException;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.ha.HaSettings;
import org.neo4j.kernel.ha.HighlyAvailableGraphDatabase;
import org.neo4j.test.TargetDirectory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

public class PlatformConstraintGraphDatabaseFactoryTest
{
@Rule
public TargetDirectory.TestDirectory storeDir = TargetDirectory.testDirForTest( getClass() );

@Test
public void shouldFailToStartIfConfiguredForCAPIDeviceTest()
{
GraphDatabaseBuilder graphDatabaseBuilder = new HighlyAvailableGraphDatabaseFactory().
newEmbeddedDatabaseBuilder( storeDir.graphDbDir() )
.setConfig( GraphDatabaseSettings.pagecache_swapper, "custom" )
.setConfig( ClusterSettings.initial_hosts, "127.0.0.1:5001" )
.setConfig( ClusterSettings.server_id, "1" );
try
{
graphDatabaseBuilder.newGraphDatabase();
fail( "Should not have created database with custom IO configuration and HA mode." );
}
catch ( RuntimeException ex )
{
// good
assertEquals( "HA mode not allowed with custom IO integrations", ex.getMessage() );
}
}
}

0 comments on commit eb83262

Please sign in to comment.