Refine search
Config loadNeo4jConfig() { return Config.fromFile( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ).toFile() ) .withHome( homeDir.toFile() ) .withNoThrowOnFileLoadFailure() .withConnectorsDisabled().build(); } }
private Config buildConfig( String databaseName ) { return Config.fromFile( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ) ) .withHome( homeDir ) .withConnectorsDisabled() .withNoThrowOnFileLoadFailure() .withSetting( GraphDatabaseSettings.active_database, databaseName ) .build(); }
/** * Convenient method for starting building from initial settings. */ @Nonnull public static Builder fromSettings( final Map<String,String> initialSettings ) { return builder().withSettings( initialSettings ); }
Path configDir = homeDir.resolve( "conf" ); configDir.toFile().mkdirs(); Path configFile = configDir.resolve( DEFAULT_CONFIG_FILE_NAME ); String databaseName = "mydb"; store( stringMap( data_directory.name(), homeDir.toString() ), configFile.toFile() ); File databaseDirectory = fromFile( configFile ).withHome( homeDir ).withSetting( active_database, databaseName ).build().get( database_path ); createDatabaseWithNativeIndexes( databaseDirectory ); OutsideWorld outsideWorld = new OutputCaptureOutsideWorld( output ); assertThat( stringMap.get( initialHeapSize.name() ), is( heap ) ); assertThat( stringMap.get( maxHeapSize.name() ), is( heap ) ); assertThat( stringMap.get( pagecache_memory.name() ), is( pagecache ) );
address, folder, name, selectedBackupProtocol, fallbackToFull, doConsistencyCheck, timeout, reportDir ); Path configFile = configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ); Config.Builder builder = Config.fromFile( configFile ); Path logPath = requiredArguments.getResolvedLocationFromName(); Config config = builder.withHome( homeDir ) .withSetting( logical_logs_location, logPath.toString() ) .withConnectorsDisabled() .build(); additionalConfig.map( this::loadAdditionalConfigFile ).ifPresent( config::augment ); config.augment( pagecache_memory, pagecacheMemory ); config.augment( "metrics.prometheus.enabled", Settings.FALSE );
private static Config loadNeo4jConfig( Path homeDir, Path configDir, String databaseName, Config additionalConfig ) { Config config = Config.fromFile( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ) ) .withHome( homeDir ) .withConnectorsDisabled() .withNoThrowOnFileLoadFailure() .build(); config.augment( additionalConfig ); config.augment( GraphDatabaseSettings.active_database, databaseName ); return config; }
@Test public void shouldFindThirdPartyJaxRsPackages() throws IOException { // given File file = ServerTestUtils.createTempConfigFile( folder.getRoot() ); try ( BufferedWriter out = new BufferedWriter( new FileWriter( file, true ) ) ) { out.write( ServerSettings.third_party_packages.name() ); out.write( "=" ); out.write( "com.foo.bar=\"mount/point/foo\"," ); out.write( "com.foo.baz=\"/bar\"," ); out.write( "com.foo.foobarbaz=\"/\"" ); out.write( System.lineSeparator() ); } // when Config config = Config.fromFile( file ).withHome( folder.getRoot() ).build(); // then List<ThirdPartyJaxRsPackage> thirdpartyJaxRsPackages = config.get( ServerSettings.third_party_packages ); assertNotNull( thirdpartyJaxRsPackages ); assertEquals( 3, thirdpartyJaxRsPackages.size() ); }
@Test public void shouldDefaultToCorrectValueForAuthStoreLocation() { File configFile = ConfigFileBuilder .builder( folder.getRoot() ) .withoutSetting( GraphDatabaseSettings.data_directory ) .build(); Config config = Config.fromFile( configFile ).withHome( folder.getRoot() ).build(); assertThat( config.get( DatabaseManagementSystemSettings.auth_store_directory ), is( new File( folder.getRoot(), "data/dbms" ).getAbsoluteFile() ) ); }
@Test( expected = UncheckedIOException.class ) public void shouldThrowWhenSpecifiedConfigFileDoesNotExist() { // Given File nonExistentConfigFile = new File( "/tmp/" + System.currentTimeMillis() ); // When Config config = Config.fromFile( nonExistentConfigFile ).withHome( folder.getRoot() ).build(); // Then assertNotNull( config ); }
@Test public void shouldSetSecretParameter() { // Given Config config = Config.builder() .withSetting( MySettingsWithDefaults.password, "this should not be visible" ) .withSetting( MySettingsWithDefaults.hello, "ABC" ) .withConfigClasses( Arrays.asList( mySettingsWithDefaults, myMigratingSettings ) ) .build(); // Then assertTrue( config.getConfigValues().get( MySettingsWithDefaults.password.name() ).secret() ); assertFalse( config.getConfigValues().get( MySettingsWithDefaults.hello.name() ).secret() ); String configText = config.toString(); assertTrue( configText.contains( Secret.OBSFUCATED ) ); assertFalse( configText.contains( "this should not be visible" ) ); assertFalse( configText.contains( config.get( MySettingsWithDefaults.password ) ) ); }
@Test public void updateDynamicShouldLogExceptionsFromUpdateListeners() { Config config = Config.builder().withConfigClasses( singletonList( new MyDynamicSettings() ) ).build(); IllegalStateException exception = new IllegalStateException( "Boo" ); config.registerDynamicUpdateListener( MyDynamicSettings.boolSetting, ( a, b ) -> { throw exception; } ); Log log = mock( Log.class ); config.setLogger( log ); String settingName = MyDynamicSettings.boolSetting.name(); config.updateDynamicSetting( settingName, "", ORIGIN ); verify( log ).error( "Failure when notifying listeners after dynamic setting change; " + "new setting might not have taken effect: Boo", exception ); }
@Test public void webServerThreadCountDefaultShouldBeDocumented() { Config config = Config.builder().withServerDefaults().build(); String documentedDefaultValue = config.getConfigValues().entrySet().stream() .filter( c -> c.getKey().equals( ServerSettings.webserver_max_threads.name() ) ) .map( Entry::getValue ) .findAny() .orElseThrow( () -> new RuntimeException( "Setting not present!" ) ) .documentedDefaultValue() .orElseThrow( () -> new RuntimeException( "Default value not present!" ) ); assertEquals( "Number of available processors, or 500 for machines which have more than 500 processors.", documentedDefaultValue ); }
Config config = Config.builder() .withFile( configFile ) .withSettings( configOverrides ) .withHome(homeDir) .withValidators( configurationValidators() ) .withNoThrowOnFileLoadFailure() // TODO 4.0: Remove this, and require a neo4j.conf file to be present? .withServerDefaults().build(); config.setLogger( log ); serverAddress = config.httpConnectors().stream() .filter( c -> Encryption.NONE.equals( c.encryptionLevel() ) ) .findFirst()
@Test public void mustNotWarnAboutDuplicateJvmAdditionalSettings() throws Exception { Log log = mock( Log.class ); File confFile = testDirectory.createFile( "test.conf" ); Files.write( confFile.toPath(), Arrays.asList( ExternalSettings.additionalJvm.name() + "=-Dsysprop=val", ExternalSettings.additionalJvm.name() + "=-XX:+UseG1GC", ExternalSettings.additionalJvm.name() + "=-XX:+AlwaysPreTouch" ) ); Config config = Config.fromFile( confFile ).build(); config.setLogger( log ); // The ExternalSettings.additionalJvm setting is allowed to be specified more than once. verifyNoMoreInteractions( log ); }
@Test void shouldEnableBoltByDefault() { // given Config config = Config.builder().withServerDefaults().build(); // when BoltConnector boltConnector = config.boltConnectors().get( 0 ); ListenSocketAddress listenSocketAddress = config.get( boltConnector.listen_address ); // then assertEquals( new ListenSocketAddress( "127.0.0.1", 7687 ), listenSocketAddress ); }
private Config customisedConfig( Config original, boolean keepTxLogsInStoreDir, boolean forceTransactionRotations ) { Config config = Config.builder() .build(); if ( !keepTxLogsInStoreDir ) { original.getRaw( GraphDatabaseSettings.logical_logs_location.name() ) .ifPresent( v -> config.augment( GraphDatabaseSettings.logical_logs_location, v ) ); } if ( forceTransactionRotations ) { original.getRaw( GraphDatabaseSettings.logical_log_rotation_threshold.name() ) .ifPresent( v -> config.augment( GraphDatabaseSettings.logical_log_rotation_threshold, v ) ); } return config; }
@Test void testServerDefaultSettings() { // given Config config = Config.builder().withServerDefaults().build(); // when List<HttpConnector> connectors = config.httpConnectors(); // then assertEquals( 2, connectors.size() ); if ( connectors.get( 0 ).encryptionLevel().equals( TLS ) ) { assertEquals( new ListenSocketAddress( "localhost", 7474 ), config.get( connectors.get( 1 ).listen_address ) ); assertEquals( new ListenSocketAddress( "localhost", 7473 ), config.get( connectors.get( 0 ).listen_address ) ); } else { assertEquals( new ListenSocketAddress( "127.0.0.1", 7474 ), config.get( connectors.get( 0 ).listen_address ) ); assertEquals( new ListenSocketAddress( "127.0.0.1", 7473 ), config.get( connectors.get( 1 ).listen_address ) ); } }
@Test void shouldDeriveListenAddressFromDefaultListenAddress() { // given Config config = Config.fromSettings( stringMap( "dbms.connector.https.enabled", "true", "dbms.connector.http.enabled", "true", "dbms.connectors.default_listen_address", "0.0.0.0" ) ).withServerDefaults().build(); // then assertEquals( 2, config.enabledHttpConnectors().size() ); config.enabledHttpConnectors().forEach( c -> assertEquals( "0.0.0.0", config.get( c.listen_address ).getHostname() ) ); }
@Test public void updateDynamicShouldThrowIfSettingIsNotDynamic() { Config config = Config.builder().withConfigClasses( singletonList( mySettingsWithDefaults ) ).build(); expect.expect( IllegalArgumentException.class ); config.updateDynamicSetting( MySettingsWithDefaults.hello.name(), "hello", ORIGIN ); }