/** * The total number of input plus output connections that a file system for the given scheme may open. * Unlimited be default. */ public static ConfigOption<Integer> fileSystemConnectionLimit(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.total").defaultValue(-1); }
/** * The total number of output connections that a file system for the given scheme may open. * Unlimited be default. */ public static ConfigOption<Integer> fileSystemConnectionLimitOut(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.output").defaultValue(-1); }
/** * The total number of input connections that a file system for the given scheme may open. * Unlimited be default. */ public static ConfigOption<Integer> fileSystemConnectionLimitIn(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.input").defaultValue(-1); }
/** * If any connection limit is configured, this option can be optionally set to define after * which time (in milliseconds) stream opening fails with a timeout exception, if no stream * connection becomes available. Unlimited timeout be default. */ public static ConfigOption<Long> fileSystemConnectionLimitTimeout(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.timeout").defaultValue(0L); }
/** * If any connection limit is configured, this option can be optionally set to define after * which time (in milliseconds) inactive streams are reclaimed. This option can help to prevent * that inactive streams make up the full pool of limited connections, and no further connections * can be established. Unlimited timeout be default. */ public static ConfigOption<Long> fileSystemConnectionLimitStreamInactivityTimeout(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.stream-timeout").defaultValue(0L); } }
try { @SuppressWarnings("rawtypes") final ConfigOption rawOption = ConfigOptions.key("testkey").defaultValue("value");
@Test public void testRemove(){ Configuration cfg = new Configuration(); cfg.setInteger("a", 1); cfg.setInteger("b", 2); ConfigOption<Integer> validOption = ConfigOptions .key("a") .defaultValue(-1); ConfigOption<Integer> deprecatedOption = ConfigOptions .key("c") .defaultValue(-1) .withDeprecatedKeys("d", "b"); ConfigOption<Integer> unexistedOption = ConfigOptions .key("e") .defaultValue(-1) .withDeprecatedKeys("f", "g", "j"); assertEquals("Wrong expectation about size", cfg.keySet().size(), 2); assertTrue("Expected 'validOption' is removed", cfg.removeConfig(validOption)); assertEquals("Wrong expectation about size", cfg.keySet().size(), 1); assertTrue("Expected 'existedOption' is removed", cfg.removeConfig(deprecatedOption)); assertEquals("Wrong expectation about size", cfg.keySet().size(), 0); assertFalse("Expected 'unexistedOption' is not removed", cfg.removeConfig(unexistedOption)); } }
@Test public void testDeprecatedKeys() { Configuration cfg = new Configuration(); cfg.setInteger("the-key", 11); cfg.setInteger("old-key", 12); cfg.setInteger("older-key", 13); ConfigOption<Integer> matchesFirst = ConfigOptions .key("the-key") .defaultValue(-1) .withDeprecatedKeys("old-key", "older-key"); ConfigOption<Integer> matchesSecond = ConfigOptions .key("does-not-exist") .defaultValue(-1) .withDeprecatedKeys("old-key", "older-key"); ConfigOption<Integer> matchesThird = ConfigOptions .key("does-not-exist") .defaultValue(-1) .withDeprecatedKeys("foo", "older-key"); ConfigOption<Integer> notContained = ConfigOptions .key("does-not-exist") .defaultValue(-1) .withDeprecatedKeys("not-there", "also-not-there"); assertEquals(11, cfg.getInteger(matchesFirst)); assertEquals(12, cfg.getInteger(matchesSecond)); assertEquals(13, cfg.getInteger(matchesThird)); assertEquals(-1, cfg.getInteger(notContained)); }
@Test public void testFallbackKeys() { Configuration cfg = new Configuration(); cfg.setInteger("the-key", 11); cfg.setInteger("old-key", 12); cfg.setInteger("older-key", 13); ConfigOption<Integer> matchesFirst = ConfigOptions .key("the-key") .defaultValue(-1) .withFallbackKeys("old-key", "older-key"); ConfigOption<Integer> matchesSecond = ConfigOptions .key("does-not-exist") .defaultValue(-1) .withFallbackKeys("old-key", "older-key"); ConfigOption<Integer> matchesThird = ConfigOptions .key("does-not-exist") .defaultValue(-1) .withFallbackKeys("foo", "older-key"); ConfigOption<Integer> notContained = ConfigOptions .key("does-not-exist") .defaultValue(-1) .withFallbackKeys("not-there", "also-not-there"); assertEquals(11, cfg.getInteger(matchesFirst)); assertEquals(12, cfg.getInteger(matchesSecond)); assertEquals(13, cfg.getInteger(matchesThird)); assertEquals(-1, cfg.getInteger(notContained)); }
@Test public void testOptionWithDefault() { Configuration cfg = new Configuration(); cfg.setInteger("int-key", 11); cfg.setString("string-key", "abc"); ConfigOption<String> presentStringOption = ConfigOptions.key("string-key").defaultValue("my-beautiful-default"); ConfigOption<Integer> presentIntOption = ConfigOptions.key("int-key").defaultValue(87); assertEquals("abc", cfg.getString(presentStringOption)); assertEquals("abc", cfg.getValue(presentStringOption)); assertEquals(11, cfg.getInteger(presentIntOption)); assertEquals("11", cfg.getValue(presentIntOption)); // test getting default when no value is present ConfigOption<String> stringOption = ConfigOptions.key("test").defaultValue("my-beautiful-default"); ConfigOption<Integer> intOption = ConfigOptions.key("test2").defaultValue(87); // getting strings with default value should work assertEquals("my-beautiful-default", cfg.getValue(stringOption)); assertEquals("my-beautiful-default", cfg.getString(stringOption)); // overriding the default should work assertEquals("override", cfg.getString(stringOption, "override")); // getting a primitive with a default value should work assertEquals(87, cfg.getInteger(intOption)); assertEquals("87", cfg.getValue(intOption)); }
@Test public void testOptionWithNoDefault() { Configuration cfg = new Configuration(); cfg.setInteger("int-key", 11); cfg.setString("string-key", "abc"); ConfigOption<String> presentStringOption = ConfigOptions.key("string-key").noDefaultValue(); assertEquals("abc", cfg.getString(presentStringOption)); assertEquals("abc", cfg.getValue(presentStringOption)); // test getting default when no value is present ConfigOption<String> stringOption = ConfigOptions.key("test").noDefaultValue(); // getting strings for null should work assertNull(cfg.getValue(stringOption)); assertNull(cfg.getString(stringOption)); // overriding the null default should work assertEquals("override", cfg.getString(stringOption, "override")); }
/** * The total number of output connections that a file system for the given scheme may open. * Unlimited be default. */ public static ConfigOption<Integer> fileSystemConnectionLimitOut(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.output").defaultValue(-1); }
/** * If any connection limit is configured, this option can be optionally set to define after * which time (in milliseconds) stream opening fails with a timeout exception, if no stream * connection becomes available. Unlimited timeout be default. */ public static ConfigOption<Long> fileSystemConnectionLimitTimeout(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.timeout").defaultValue(0L); }
/** * The total number of input connections that a file system for the given scheme may open. * Unlimited be default. */ public static ConfigOption<Integer> fileSystemConnectionLimitIn(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.input").defaultValue(-1); }
/** * The total number of output connections that a file system for the given scheme may open. * Unlimited be default. */ public static ConfigOption<Integer> fileSystemConnectionLimitOut(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.output").defaultValue(-1); }
/** * The total number of input plus output connections that a file system for the given scheme may open. * Unlimited be default. */ public static ConfigOption<Integer> fileSystemConnectionLimit(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.total").defaultValue(-1); }
/** * The total number of input connections that a file system for the given scheme may open. * Unlimited be default. */ public static ConfigOption<Integer> fileSystemConnectionLimitIn(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.input").defaultValue(-1); }
/** * If any connection limit is configured, this option can be optionally set to define after * which time (in milliseconds) inactive streams are reclaimed. This option can help to prevent * that inactive streams make up the full pool of limited connections, and no further connections * can be established. Unlimited timeout be default. */ public static ConfigOption<Long> fileSystemConnectionLimitStreamInactivityTimeout(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.stream-timeout").defaultValue(0L); }
/** * If any connection limit is configured, this option can be optionally set to define after * which time (in milliseconds) inactive streams are reclaimed. This option can help to prevent * that inactive streams make up the full pool of limited connections, and no further connections * can be established. Unlimited timeout be default. */ public static ConfigOption<Long> fileSystemConnectionLimitStreamInactivityTimeout(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.stream-timeout").defaultValue(0L); } }
/** * The total number of input plus output connections that a file system for the given scheme may open. * Unlimited be default. */ public static ConfigOption<Integer> fileSystemConnectionLimit(String scheme) { return ConfigOptions.key("fs." + scheme + ".limit.total").defaultValue(-1); }