Skip to content

Commit

Permalink
Removed hard coded config filenames in favor of constant in Config.
Browse files Browse the repository at this point in the history
Renamed setting to buildSetting when additional parameters are needed to make it clear that a builder is returned.
Refactored identifiersFromPrefix to to use the original annotation Group, that got lost in previous refactoring.
  • Loading branch information
klaren committed Aug 15, 2017
1 parent 4d692d4 commit fde16a0
Show file tree
Hide file tree
Showing 55 changed files with 456 additions and 436 deletions.
Expand Up @@ -86,7 +86,7 @@ public class BoltKernelExtension extends KernelExtensionFactory<BoltKernelExtens
public static class Settings implements LoadableConfig
{
@Description( "SSL policy to use" )
public static Setting<String> ssl_policy = setting( "bolt.ssl_policy", STRING, LEGACY_POLICY_NAME ).build();
public static Setting<String> ssl_policy = setting( "bolt.ssl_policy", STRING, LEGACY_POLICY_NAME );
}

public interface Dependencies
Expand Down
Expand Up @@ -40,25 +40,25 @@ public class ConsistencyCheckSettings implements LoadableConfig
"However, the check is very expensive in time and memory, so it is skipped by default." )
@Deprecated
public static final Setting<Boolean> consistency_check_property_owners =
setting( "tools.consistency_checker.check_property_owners", BOOLEAN, FALSE ).build();
setting( "tools.consistency_checker.check_property_owners", BOOLEAN, FALSE );

@Description( "This setting is deprecated. See commandline arguments for neoj4-admin check-consistency " +
"instead. Perform checks on the label scan store. Checking this store is more expensive than " +
"checking the native stores, so it may be useful to turn off this check for very large databases." )
@Deprecated
public static final Setting<Boolean> consistency_check_label_scan_store =
setting( "tools.consistency_checker.check_label_scan_store", BOOLEAN, TRUE ).build();
setting( "tools.consistency_checker.check_label_scan_store", BOOLEAN, TRUE );

@Description( "This setting is deprecated. See commandline arguments for neoj4-admin check-consistency " +
"instead. Perform checks on indexes. Checking indexes is more expensive than " +
"checking the native stores, so it may be useful to turn off this check for very large databases." )
@Deprecated
public static final Setting<Boolean> consistency_check_indexes =
setting( "tools.consistency_checker.check_indexes", BOOLEAN, TRUE ).build();
setting( "tools.consistency_checker.check_indexes", BOOLEAN, TRUE );

@Description( "This setting is deprecated. See commandline arguments for neoj4-admin check-consistency " +
"instead. Perform checks between nodes, relationships, properties, types and tokens." )
@Deprecated
public static final Setting<Boolean> consistency_check_graph =
setting( "tools.consistency_checker.check_graph", BOOLEAN, TRUE ).build();
setting( "tools.consistency_checker.check_graph", BOOLEAN, TRUE );
}
Expand Up @@ -108,7 +108,7 @@ public void passesOnConfigurationIfProvided() throws Exception
{
// given
File storeDir = storeDirectory.directory();
File configFile = storeDirectory.file( "neo4j.conf" );
File configFile = storeDirectory.file( Config.DEFAULT_CONFIG_FILE_NAME );
Properties properties = new Properties();
properties.setProperty( ConsistencyCheckSettings.consistency_check_property_owners.name(), "true" );
properties.store( new FileWriter( configFile ), null );
Expand Down
Expand Up @@ -99,7 +99,7 @@ public void execute( String[] args ) throws IncorrectUsage, CommandFailed

private Path toDatabaseDirectory( String databaseName )
{
return Config.fromFile( configDir.resolve( "neo4j.conf" ) )
return Config.fromFile( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ) )
.withHome( homeDir )
.withConnectorsDisabled()
.withSetting( DatabaseManagementSystemSettings.active_database, databaseName )
Expand Down
Expand Up @@ -286,7 +286,7 @@ private Map<String,String> loadAdditionalConfig( Optional<Path> additionalConfig
private static Config loadNeo4jConfig( Path homeDir, Path configDir, String databaseName,
Map<String,String> additionalConfig )
{
return Config.fromFile( configDir.resolve( "neo4j.conf" ) )
return Config.fromFile( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ) )
.withHome( homeDir )
.withSetting( DatabaseManagementSystemSettings.active_database, databaseName )
.withSettings( additionalConfig )
Expand Down
Expand Up @@ -35,7 +35,7 @@
public class DatabaseManagementSystemSettings implements LoadableConfig
{
@Description( "Name of the database to load" )
public static final Setting<String> active_database = setting( "dbms.active_database", STRING, "graph.db" ).build();
public static final Setting<String> active_database = setting( "dbms.active_database", STRING, "graph.db" );

@Description( "Path of the data directory. You must not configure more than one Neo4j installation to use the " +
"same data directory." )
Expand Down
Expand Up @@ -19,6 +19,12 @@
*/
package org.neo4j.commandline.dbms;

import org.apache.commons.lang3.SystemUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
Expand All @@ -32,19 +38,14 @@
import java.nio.file.Paths;
import java.util.function.Predicate;

import org.apache.commons.lang3.SystemUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import org.neo4j.commandline.admin.CommandFailed;
import org.neo4j.commandline.admin.CommandLocator;
import org.neo4j.commandline.admin.IncorrectUsage;
import org.neo4j.commandline.admin.Usage;
import org.neo4j.dbms.archive.Dumper;
import org.neo4j.io.fs.DefaultFileSystemAbstraction;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.store.MetaDataStore;
import org.neo4j.kernel.impl.storemigration.StoreFileType;
import org.neo4j.kernel.internal.locker.StoreLocker;
Expand All @@ -53,7 +54,6 @@
import static java.lang.String.format;
import static java.util.Arrays.asList;
import static java.util.Collections.emptySet;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
Expand All @@ -66,7 +66,6 @@
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import static org.neo4j.dbms.DatabaseManagementSystemSettings.data_directory;
import static org.neo4j.dbms.archive.TestUtils.withPermissions;

Expand Down Expand Up @@ -107,7 +106,7 @@ public void shouldCalculateTheDatabaseDirectoryFromConfig() throws Exception
Path dataDir = testDirectory.directory( "some-other-path" ).toPath();
Path databaseDir = dataDir.resolve( "databases/foo.db" );
putStoreInDirectory( databaseDir );
Files.write( configDir.resolve( "neo4j.conf" ),
Files.write( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ),
asList( format( "%s=%s", data_directory.name(), dataDir.toString().replace( '\\', '/' ) ) ) );

execute( "foo.db" );
Expand All @@ -129,7 +128,7 @@ public void shouldHandleDatabaseSymlink() throws Exception
Files.createDirectories( dataDir.resolve( "databases" ) );

Files.createSymbolicLink( databaseDir, realDatabaseDir );
Files.write( configDir.resolve( "neo4j.conf" ),
Files.write( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ),
asList( format( "%s=%s", data_directory.name(), dataDir.toString().replace( '\\', '/' ) ) ) );

execute( "foo.db" );
Expand Down Expand Up @@ -265,7 +264,7 @@ public void shouldDefaultToGraphDB() throws Exception
Path dataDir = testDirectory.directory( "some-other-path" ).toPath();
Path databaseDir = dataDir.resolve( "databases/graph.db" );
putStoreInDirectory( databaseDir );
Files.write( configDir.resolve( "neo4j.conf" ),
Files.write( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ),
asList( format( "%s=%s", data_directory.name(), dataDir.toString().replace( '\\', '/' ) ) ) );

new DumpCommand( homeDir, configDir, dumper ).execute( new String[]{"--to=" + archive} );
Expand Down
Expand Up @@ -45,6 +45,7 @@
import org.neo4j.helpers.ArrayUtil;
import org.neo4j.io.fs.DefaultFileSystemAbstraction;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.internal.locker.StoreLocker;
import org.neo4j.test.rule.TestDirectory;

Expand Down Expand Up @@ -96,7 +97,7 @@ public void shouldCalculateTheDatabaseDirectoryFromConfig()
Path dataDir = testDirectory.directory( "some-other-path" ).toPath();
Path databaseDir = dataDir.resolve( "databases/foo.db" );
Files.createDirectories( databaseDir );
Files.write( configDir.resolve( "neo4j.conf" ),
Files.write( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ),
asList( format( "%s=%s", data_directory.name(), dataDir.toString().replace( '\\', '/' ) ) ) );

execute( "foo.db" );
Expand All @@ -119,7 +120,7 @@ public void shouldHandleSymlinkToDatabaseDir() throws IOException, CommandFailed

Files.createSymbolicLink( databaseDir, realDatabaseDir );

Files.write( configDir.resolve( "neo4j.conf" ),
Files.write( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ),
asList( format( "%s=%s", data_directory.name(), dataDir.toString().replace( '\\', '/' ) ) ) );

execute( "foo.db" );
Expand All @@ -132,7 +133,7 @@ public void shouldMakeFromCanonical() throws IOException, CommandFailed, Incorre
Path dataDir = testDirectory.directory( "some-other-path" ).toPath();
Path databaseDir = dataDir.resolve( "databases/foo.db" );
Files.createDirectories( databaseDir );
Files.write( configDir.resolve( "neo4j.conf" ),
Files.write( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ),
asList( format( "%s=%s", data_directory.name(), dataDir.toString().replace( '\\', '/' ) ) ) );

new LoadCommand( homeDir, configDir, loader )
Expand Down
Expand Up @@ -216,10 +216,10 @@ enum Options
+ "Skipped columns will be logged, containing at most number of entities specified by "
+ BAD_TOLERANCE.key() + ", unless "
+ "otherwise specified by " + SKIP_BAD_ENTRIES_LOGGING.key() + "option." ),
DATABASE_CONFIG( "db-config", null, "<path/to/neo4j.conf>",
DATABASE_CONFIG( "db-config", null, "<path/to/" + Config.DEFAULT_CONFIG_FILE_NAME + ">",
"(advanced) Option is deprecated and replaced by 'additional-config'. " ),
ADDITIONAL_CONFIG( "additional-config", null,
"<path/to/neo4j.conf>",
"<path/to/" + Config.DEFAULT_CONFIG_FILE_NAME + ">",
"(advanced) File specifying database-specific configuration. For more information consult "
+ "manual about available configuration options for a neo4j configuration file. "
+ "Only configuration affecting store at time of creation will be read. "
Expand Down
Expand Up @@ -103,7 +103,7 @@ public GraphDatabaseService newDatabase( Map<String,String> config )
@Override
public GraphDatabaseService newDatabase( @Nonnull Config config )
{
config.augment( "unsupported.dbms.ephemeral", "false" );
config.augment( GraphDatabaseFacadeFactory.Configuration.ephemeral, "false" );
return GraphDatabaseFactory.this.newEmbeddedDatabase( storeDir, config, state.databaseDependencies() );
}
};
Expand Down

0 comments on commit fde16a0

Please sign in to comment.