本文整理了Java中org.neo4j.kernel.configuration.Config.builder()
方法的一些代码示例,展示了Config.builder()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.builder()
方法的具体详情如下:
包路径:org.neo4j.kernel.configuration.Config
类名称:Config
方法名:builder
暂无
代码示例来源:origin: neo4j/neo4j
/**
* Convenient method for starting building from a file.
*/
@Nonnull
public static Builder fromFile( @Nullable final File configFile )
{
return builder().withFile( configFile );
}
代码示例来源:origin: neo4j/neo4j
/**
* Convenient method for starting building from a file.
*/
@Nonnull
public static Builder fromFile( @Nonnull final Path configFile )
{
return builder().withFile( configFile );
}
代码示例来源:origin: neo4j/neo4j
/**
* Convenient method for starting building from initial settings.
*/
@Nonnull
public static Builder fromSettings( final Map<String,String> initialSettings )
{
return builder().withSettings( initialSettings );
}
代码示例来源:origin: neo4j/neo4j
/**
* @return a configuration with default values.
*/
@Nonnull
public static Config defaults()
{
return builder().build();
}
代码示例来源:origin: neo4j/neo4j
/**
* Constructs a <code>Config</code> with default values and sets the supplied <code>setting</code> to the <code>value</code>.
* @param setting The initial setting to use.
* @param value The initial value to give the setting.
*/
@Nonnull
public static Config defaults( @Nonnull final Setting<?> setting, final String value )
{
return builder().withSetting( setting, value ).build();
}
代码示例来源:origin: neo4j/neo4j
/**
* @param initialSettings a map with settings to be present in the config.
* @return a configuration with default values augmented with the provided <code>initialSettings</code>.
*/
@Nonnull
public static Config defaults( @Nonnull final Map<String,String> initialSettings )
{
return builder().withSettings( initialSettings ).build();
}
代码示例来源:origin: neo4j/neo4j
@Test
public void configValuesContainsConnectors()
{
Config config = Config.builder().withServerDefaults().build();
List<String> connectorSettings = config.getConfigValues().entrySet().stream()
.map( Entry::getKey )
.filter( c -> c.startsWith( "dbms.connector" ) )
.filter( c -> c.endsWith( ".enabled" ) )
.collect( toList() );
assertThat( connectorSettings, containsInAnyOrder( "dbms.connector.http.enabled",
"dbms.connector.https.enabled",
"dbms.connector.bolt.enabled" ) );
}
代码示例来源:origin: neo4j/neo4j
@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 );
}
代码示例来源:origin: neo4j/neo4j
public Config config( LoadableConfig settingsClasses )
{
return Config.builder().withSettings( configuration ).withConfigClasses(
Collections.singletonList( settingsClasses ) ).build();
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldBeFoundInServerDefaults()
{
// given
Config serverDefaultConfig = Config.builder().withServerDefaults().build();
// when
Stream<ConfigValue> cvStream = serverDefaultConfig.getConfigValues().values().stream();
// then
assertEquals( 1, cvStream.filter( c -> c.name().equals( certificates_directory.name() ) ).count() );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void connectorSettingHasItsOwnValues()
{
Config config = Config.builder().withServerDefaults()
.withSetting( new HttpConnector( "http" ).address, "localhost:123" ).build();
ConfigValue address = config.getConfigValues().entrySet().stream()
.filter( c -> c.getKey().equals( "dbms.connector.http.address" ) )
.map( Entry::getValue )
.findAny()
.orElseThrow( () -> new RuntimeException( "Setting not present!" ) );
assertTrue( address.deprecated() );
assertEquals( Optional.of( "dbms.connector.http.listen_address" ), address.replacement() );
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldOmitBoltIfNoConnectorConfigured() throws Exception
{
DiscoverableURIs uris = communityDiscoverableURIs( Config.builder().build(), null );
assertFalse( toMap( uris ).containsKey( "bolt" ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void updateDynamicShouldInformRegisteredListeners()
{
Config config = Config.builder().withConfigClasses( singletonList( new MyDynamicSettings() ) ).build();
AtomicInteger counter = new AtomicInteger( 0 );
config.registerDynamicUpdateListener( MyDynamicSettings.boolSetting, ( previous, update ) ->
{
counter.getAndIncrement();
assertTrue( previous );
assertFalse( update );
} );
config.updateDynamicSetting( MyDynamicSettings.boolSetting.name(), "false", ORIGIN );
assertThat( counter.get(), is( 1 ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void updateDynamicShouldThrowIfSettingIsNotDynamic()
{
Config config = Config.builder().withConfigClasses( singletonList( mySettingsWithDefaults ) ).build();
expect.expect( IllegalArgumentException.class );
config.updateDynamicSetting( MySettingsWithDefaults.hello.name(), "hello", ORIGIN );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void registeringUpdateListenerOnNonDynamicSettingMustThrow()
{
Config config = Config.builder().withConfigClasses( singletonList( mySettingsWithDefaults ) ).build();
expect.expect( IllegalArgumentException.class );
config.registerDynamicUpdateListener( MySettingsWithDefaults.hello, ( a, b ) -> fail( "never called" ) );
}
代码示例来源:origin: neo4j/neo4j
@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 );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void updateDynamicShouldNotAllowInvalidSettings()
{
Config config = Config.builder().withConfigClasses( singletonList( new MyDynamicSettings() ) ).build();
expect.expect( InvalidSettingException.class );
config.updateDynamicSetting( MyDynamicSettings.boolSetting.name(), "this is not a boolean", ORIGIN );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldSetInternalParameter()
{
// Given
Config config = Config.builder()
.withSetting( MySettingsWithDefaults.secretSetting, "false" )
.withSetting( MySettingsWithDefaults.hello, "ABC" )
.withConfigClasses( Arrays.asList( mySettingsWithDefaults, myMigratingSettings ) )
.build();
// Then
assertTrue( config.getConfigValues().get( MySettingsWithDefaults.secretSetting.name() ).internal() );
assertFalse( config.getConfigValues().get( MySettingsWithDefaults.hello.name() ).internal() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldLookupBoltPortInRegisterIfConfiguredTo0() throws Exception
{
BoltConnector bolt = new BoltConnector( "honestJakesBoltConnector" );
ConnectorPortRegister register = new ConnectorPortRegister();
register.register( bolt.key(), new InetSocketAddress( 1337 ) );
DiscoverableURIs uris = communityDiscoverableURIs(
Config.builder()
.withSetting( bolt.advertised_address, "apple.com:0" )
.withSetting( bolt.enabled, "true" )
.withSetting( bolt.type, BoltConnector.ConnectorType.BOLT.name() )
.build(), register );
assertEquals( "bolt://apple.com:1337", toMap(uris).get("bolt") );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void withConnectorsDisabled()
{
Connector httpConnector = new HttpConnector();
Connector boltConnector = new BoltConnector();
Config config = Config.builder()
.withSetting( httpConnector.enabled, "true" )
.withSetting( httpConnector.type, Connector.ConnectorType.HTTP.name() )
.withSetting( boltConnector.enabled, "true" )
.withSetting( boltConnector.type, Connector.ConnectorType.BOLT.name() )
.withConnectorsDisabled().build();
assertFalse( config.get( httpConnector.enabled ) );
assertFalse( config.get( boltConnector.enabled ) );
}
内容来源于网络,如有侵权,请联系作者删除!