Skip to content

Commit

Permalink
Remove remaining uses of empty Config constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
benbc committed Feb 29, 2016
1 parent baa6285 commit 3a5d8a1
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 61 deletions.
Expand Up @@ -80,9 +80,9 @@ public static Config defaults()
return new Config(); return new Config();
} }


public Config() private Config()
{ {
this( new HashMap<>(), Collections.<Class<?>>emptyList() ); this( new HashMap<>() );
} }


public Config( Map<String, String> inputParams ) public Config( Map<String, String> inputParams )
Expand Down
Expand Up @@ -19,13 +19,13 @@
*/ */
package org.neo4j.kernel.impl.pagecache; package org.neo4j.kernel.impl.pagecache;


import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

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


import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.io.pagecache.PageCache; import org.neo4j.io.pagecache.PageCache;
import org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory; import org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory;
Expand All @@ -37,6 +37,7 @@
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;

import static org.neo4j.graphdb.factory.GraphDatabaseSettings.mapped_memory_page_size; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.mapped_memory_page_size;
import static org.neo4j.graphdb.factory.GraphDatabaseSettings.pagecache_memory; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.pagecache_memory;
import static org.neo4j.graphdb.factory.GraphDatabaseSettings.pagecache_swapper; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.pagecache_swapper;
Expand All @@ -62,8 +63,7 @@ public void shouldUseConfiguredPageSizeAndFitAsManyPagesAsItCan() throws Throwab
// Given // Given
final int pageSize = 4096; final int pageSize = 4096;
final int maxPages = 60; final int maxPages = 60;
Config config = new Config(); Config config = new Config( stringMap(
config.applyChanges( stringMap(
mapped_memory_page_size.name(), "" + pageSize, mapped_memory_page_size.name(), "" + pageSize,
pagecache_memory.name(), Integer.toString( pageSize * maxPages ) ) ); pagecache_memory.name(), Integer.toString( pageSize * maxPages ) ) );


Expand All @@ -83,8 +83,7 @@ public void shouldUseConfiguredPageSizeAndFitAsManyPagesAsItCan() throws Throwab
public void mustUseConfiguredPageSwapper() throws Exception public void mustUseConfiguredPageSwapper() throws Exception
{ {
// Given // Given
Config config = new Config(); Config config = new Config( stringMap(
config.applyChanges( stringMap(
pagecache_memory.name(), "8m", pagecache_memory.name(), "8m",
pagecache_swapper.name(), "test" ) ); pagecache_swapper.name(), "test" ) );


Expand All @@ -102,8 +101,7 @@ public void mustUsePageSwapperCachePageSizeHintAsDefault() throws Exception
// Given // Given
int cachePageSizeHint = 16 * 1024; int cachePageSizeHint = 16 * 1024;
PageSwapperFactoryForTesting.cachePageSizeHint.set( cachePageSizeHint ); PageSwapperFactoryForTesting.cachePageSizeHint.set( cachePageSizeHint );
Config config = new Config(); Config config = new Config( stringMap(
config.applyChanges( stringMap(
GraphDatabaseSettings.pagecache_swapper.name(), "test" ) ); GraphDatabaseSettings.pagecache_swapper.name(), "test" ) );


// When // When
Expand All @@ -124,8 +122,7 @@ public void mustIgnoreExplicitlySpecifiedCachePageSizeIfPageSwapperHintIsStrict(
int cachePageSizeHint = 16 * 1024; int cachePageSizeHint = 16 * 1024;
PageSwapperFactoryForTesting.cachePageSizeHint.set( cachePageSizeHint ); PageSwapperFactoryForTesting.cachePageSizeHint.set( cachePageSizeHint );
PageSwapperFactoryForTesting.cachePageSizeHintIsStrict.set( true ); PageSwapperFactoryForTesting.cachePageSizeHintIsStrict.set( true );
Config config = new Config(); Config config = new Config( stringMap(
config.applyChanges( stringMap(
GraphDatabaseSettings.mapped_memory_page_size.name(), "4096", GraphDatabaseSettings.mapped_memory_page_size.name(), "4096",
GraphDatabaseSettings.pagecache_swapper.name(), "test" ) ); GraphDatabaseSettings.pagecache_swapper.name(), "test" ) );


Expand Down
Expand Up @@ -33,6 +33,8 @@
import org.neo4j.shell.ShellSettings; import org.neo4j.shell.ShellSettings;


import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static java.util.Collections.emptyMap;

import static org.neo4j.kernel.configuration.Settings.TRUE; import static org.neo4j.kernel.configuration.Settings.TRUE;


public class BaseServerConfigLoader public class BaseServerConfigLoader
Expand All @@ -44,7 +46,7 @@ public Config loadConfig( File configFile, File legacyConfigFile, Log log, Pair<
throw new IllegalArgumentException( "log cannot be null "); throw new IllegalArgumentException( "log cannot be null ");
} }


Config config = new Config(); Config config = new Config( emptyMap(), asList( ServerSettings.class, GraphDatabaseSettings.class ) );
config.setLogger( log ); config.setLogger( log );


// For now, don't print warnings if this file is not specified // For now, don't print warnings if this file is not specified
Expand All @@ -58,8 +60,6 @@ public Config loadConfig( File configFile, File legacyConfigFile, Log log, Pair<
overrideEmbeddedDefaults( config ); overrideEmbeddedDefaults( config );
applyUserOverrides( config, configOverrides ); applyUserOverrides( config, configOverrides );


config.registerSettingsClasses( asList( ServerSettings.class, GraphDatabaseSettings.class ) );

return config; return config;
} }


Expand Down

0 comments on commit 3a5d8a1

Please sign in to comment.