public static Setting<Double> makeCRSRangeSetting( CoordinateReferenceSystem crs, int dim, String rangeKey ) { double defaultCartesianExtent = 1000000; double[] defaultGeographicExtents = new double[]{180, 90, defaultCartesianExtent}; String[] keyFields = new String[]{PREFIX, crs.getName().toLowerCase(), String.valueOf( COORDS[dim] ), rangeKey}; double defValue = crs.isGeographic() ? defaultGeographicExtents[dim] : defaultCartesianExtent; defValue = rangeKey.equals( "min" ) ? -1 * defValue : defValue; return setting( String.join( ".", keyFields ), DOUBLE, String.valueOf( defValue ) ); }
public Connector( String key, @SuppressWarnings( "UnusedParameters" ) String typeDefault ) { group = new GroupSettingSupport( Connector.class, key ); enabled = group.scope( setting( "enabled", BOOLEAN, FALSE ) ); type = group.scope( setting( "type", optionsObeyCase( ConnectorType.class ), NO_DEFAULT ) ); }
public BoltConnector( String key ) { super( key ); encryption_level = group.scope( Settings.setting( "tls_level", optionsObeyCase( EncryptionLevel.class ), OPTIONAL.name() ) ); Setting<ListenSocketAddress> legacyAddressSetting = listenAddress( "address", 7687 ); Setting<ListenSocketAddress> listenAddressSetting = legacyFallback( legacyAddressSetting, listenAddress( "listen_address", 7687 ) ); this.address = group.scope( legacyAddressSetting ); this.listen_address = group.scope( listenAddressSetting ); this.advertised_address = group.scope( advertisedAddress( "advertised_address", listenAddressSetting ) ); this.thread_pool_min_size = group.scope( setting( "thread_pool_min_size", INTEGER, String.valueOf( 5 ) ) ); this.thread_pool_max_size = group.scope( setting( "thread_pool_max_size", INTEGER, String.valueOf( 400 ) ) ); this.thread_pool_keep_alive = group.scope( setting( "thread_pool_keep_alive", DURATION, "5m" ) ); this.unsupported_thread_pool_queue_size = group.scope( setting( "unsupported_thread_pool_queue_size", INTEGER, String.valueOf( 0 ) ) ); }
defaultValue ) Setting<Encryption> s = setting( "dbms.connector." + name + ".encryption", optionsObeyCase( Encryption.class ), defaultValue.name() );
public SslPolicyConfig( String policyName ) { GroupSettingSupport group = new GroupSettingSupport( SslPolicyConfig.class, policyName ); this.base_directory = group.scope( pathSetting( "base_directory", NO_DEFAULT ) ); this.allow_key_generation = group.scope( setting( "allow_key_generation", BOOLEAN, FALSE ) ); this.trust_all = group.scope( setting( "trust_all", BOOLEAN, FALSE ) ); this.private_key = group.scope( derivedDefault( "private_key", base_directory, "private.key" ) ); this.public_certificate = group.scope( derivedDefault( "public_certificate", base_directory, "public.crt" ) ); this.trusted_dir = group.scope( derivedDefault( "trusted_dir", base_directory, "trusted" ) ); this.revoked_dir = group.scope( derivedDefault( "revoked_dir", base_directory, "revoked" ) ); this.private_key_password = group.scope( setting( "private_key_password", STRING, NO_DEFAULT ) ); this.client_auth = group.scope( setting( "client_auth", optionsIgnoreCase( ClientAuth.class ), ClientAuth.REQUIRE.name() ) ); this.tls_versions = group.scope( setting( "tls_versions", STRING_LIST, joinList( TLS_VERSION_DEFAULTS ) ) ); this.ciphers = group.scope( setting( "ciphers", STRING_LIST, joinList( CIPHER_SUITES_DEFAULTS ) ) ); this.verify_hostname = group.scope( setting( "verify_hostname", BOOLEAN, FALSE ) ); }
@Test void testNormalizedRelativeURI() { // Given Setting<URI> uri = setting( "mySetting", NORMALIZED_RELATIVE_URI, "http://localhost:7474///db///data///" ); // When && then assertThat( uri.apply( always -> null ).toString(), equalTo( "/db/data" ) ); }
setting = (BaseSetting) setting( settingName, BOOLEAN, "false" ); setting.setDescription( "Enable this connector." ); break; case "type": setting = (BaseSetting) setting( settingName, optionsObeyCase( Connector.ConnectorType.class ), NO_DEFAULT ); setting.setDeprecated( true ); setting.setDescription( "Connector type. This setting is deprecated and its value will instead be " + break; case "tls_level": setting = (BaseSetting) setting( settingName, optionsObeyCase( BoltConnector.EncryptionLevel.class ), OPTIONAL.name() ); setting.setDescription( "Encryption level to require this connector to use." ); break; case "thread_pool_min_size": setting = (BaseSetting) setting( settingName, INTEGER, NO_DEFAULT ); setting.setDescription( "The number of threads to keep in the thread pool bound to this connector, even if they are idle." ); break; case "thread_pool_max_size": setting = (BaseSetting) setting( settingName, INTEGER, NO_DEFAULT ); setting.setDescription( "The maximum number of threads allowed in the thread pool bound to this connector." ); break; case "thread_pool_keep_alive": setting = (BaseSetting) setting( settingName, DURATION, NO_DEFAULT ); setting.setDescription( "The maximum time an idle thread in the thread pool bound to this connector will wait for new tasks." ); break; case "unsupported_thread_pool_queue_size":
@Test void testDefault() { Setting<Integer> setting = setting( "foo", INTEGER, "3" ); // Ok assertThat( setting.apply( map( stringMap() ) ), equalTo( 3 ) ); }
@Test void testList() { Setting<List<Integer>> setting = setting( "foo", list( ",", INTEGER ), "1,2,3,4" ); assertThat( setting.apply( map( stringMap() ) ).toString(), equalTo( "[1, 2, 3, 4]" ) ); Setting<List<Integer>> setting2 = setting( "foo", list( ",", INTEGER ), "1,2,3,4," ); assertThat( setting2.apply( map( stringMap() ) ).toString(), equalTo( "[1, 2, 3, 4]" ) ); Setting<List<Integer>> setting3 = setting( "foo", list( ",", INTEGER ), "" ); assertThat( setting3.apply( map( stringMap() ) ).toString(), equalTo( "[]" ) ); Setting<List<Integer>> setting4 = setting( "foo", list( ",", INTEGER ), "1, 2,3, 4, 5 " ); assertThat( setting4.apply( map( stringMap() ) ).toString(), equalTo( "[1, 2, 3, 4, 5]" ) ); Setting<List<Integer>> setting5 = setting( "foo", list( ",", INTEGER ), "1, 2,3, 4, " ); assertThat( setting5.apply( map( stringMap() ) ).toString(), equalTo( "[1, 2, 3, 4]" ) ); }
@Test void testStringList() { Setting<List<String>> setting1 = setting( "apa", STRING_LIST, "foo,bar,baz" ); assertEquals( Arrays.asList( "foo", "bar", "baz" ), setting1.apply( map( stringMap() ) ) ); Setting<List<String>> setting2 = setting( "apa", STRING_LIST, "foo, bar, BAZ " ); assertEquals( Arrays.asList( "foo", "bar", "BAZ" ), setting2.apply( map( stringMap() ) ) ); Setting<List<String>> setting3 = setting( "apa", STRING_LIST, "" ); assertEquals( Collections.emptyList(), setting3.apply( map( stringMap() ) ) ); }
@Test void testInheritOneLevel() { Setting<Integer> root = setting( "root", INTEGER, "4" ); Setting<Integer> setting = buildSetting( "foo", INTEGER ).inherits( root ).build(); // Ok assertThat( setting.apply( map( stringMap( "foo", "1" ) ) ), equalTo( 1 ) ); assertThat( setting.apply( map( stringMap() ) ), equalTo( 4 ) ); }
setting = (BaseSetting) setting( settingName, BOOLEAN, "false" ); setting.setDescription( "Enable this connector." ); break; case "type": setting = (BaseSetting) setting( settingName, optionsObeyCase( Connector.ConnectorType.class ), NO_DEFAULT ); setting.setDeprecated( true ); setting.setDescription( "Connector type. This setting is deprecated and its value will instead be " +
public HttpConnector( String key, Encryption encryptionLevel ) { super( key ); this.encryptionLevel = encryptionLevel; encryption = group.scope( setting( "encryption", optionsObeyCase( HttpConnector.Encryption.class ), NO_DEFAULT ) ); Setting<ListenSocketAddress> legacyAddressSetting = listenAddress( "address", encryptionLevel.defaultPort ); Setting<ListenSocketAddress> listenAddressSetting = legacyFallback( legacyAddressSetting, listenAddress( "listen_address", encryptionLevel.defaultPort ) ); this.address = group.scope( legacyAddressSetting ); this.listen_address = group.scope( listenAddressSetting ); this.advertised_address = group.scope( advertisedAddress( "advertised_address", listenAddressSetting ) ); }
public BoltConnector( String key ) { super( key, null ); encryption_level = group.scope( setting( "tls_level", optionsObeyCase( EncryptionLevel.class ), EncryptionLevel.OPTIONAL.name() ) ); Setting<ListenSocketAddress> legacyAddressSetting = listenAddress( "address", 7687 ); Setting<ListenSocketAddress> listenAddressSetting = legacyFallback( legacyAddressSetting, listenAddress( "listen_address", 7687 ) ); this.address = group.scope( legacyAddressSetting ); this.listen_address = group.scope( listenAddressSetting ); this.advertised_address = group.scope( advertisedAddress( "advertised_address", listenAddressSetting ) ); }
@Test void testInteger() { Setting<Integer> setting = setting( "foo", INTEGER, "3" ); // Ok assertThat( setting.apply( map( stringMap( "foo", "4" ) ) ), equalTo( 4 ) ); // Bad assertThrows( InvalidSettingException.class, () -> setting.apply( map( stringMap( "foo", "bar" ) ) ) ); }
@Test void testInheritHierarchy() { // Test hierarchies Setting<String> a = setting( "A", STRING, "A" ); // A defaults to A Setting<String> b = buildSetting( "B", STRING, "B" ).inherits( a ).build(); // B defaults to B unless A is defined Setting<String> c = buildSetting( "C", STRING, "C" ).inherits( b ).build(); // C defaults to C unless B is defined Setting<String> d = buildSetting( "D", STRING ).inherits( b ).build(); // D defaults to B Setting<String> e = buildSetting( "E", STRING ).inherits( d ).build(); // E defaults to D (hence B) assertThat( c.apply( map( stringMap( "C", "X" ) ) ), equalTo( "X" ) ); assertThat( c.apply( map( stringMap( "B", "X" ) ) ), equalTo( "X" ) ); assertThat( c.apply( map( stringMap( "A", "X" ) ) ), equalTo( "X" ) ); assertThat( c.apply( map( stringMap( "A", "Y", "B", "X" ) ) ), equalTo( "X" ) ); assertThat( d.apply( map( stringMap() ) ), equalTo( "B" ) ); assertThat( e.apply( map( stringMap() ) ), equalTo( "B" ) ); }