Java Code Examples for com.typesafe.config.Config#getDouble()
The following examples show how to use
com.typesafe.config.Config#getDouble() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerLimits.java From xio with Apache License 2.0 | 6 votes |
public ServerLimits(Config config) { maxConnections = config.getInt("maxConnections"); if (maxConnections > MAX_CONNECTION_LIMIT) { throw new RuntimeException( String.format("invalid configuration - maxConnections exceeds %d", MAX_CONNECTION_LIMIT)); } maxFrameSize = config.getInt("maxFrameSize"); maxReadIdleTime = config.getDuration("maxReadIdleTime"); maxWriteIdleTime = config.getDuration("maxWriteIdleTime"); maxAllIdleTime = config.getDuration("maxAllIdleTime"); globalHardReqPerSec = config.getDouble("globalHardReqPerSec"); globalSoftReqPerSec = config.getDouble("globalSoftReqPerSec"); rateLimiterPoolSize = config.getInt("rateLimiterPoolSize"); softReqPerSec = config.getDouble("softReqPerSec"); hardReqPerSec = config.getDouble("hardReqPerSec"); clientRateLimitOverride = createClientRateLimitOverride(config); }
Example 2
Source File: MLUpdate.java From oryx with Apache License 2.0 | 6 votes |
protected MLUpdate(Config config) { this.testFraction = config.getDouble("oryx.ml.eval.test-fraction"); int candidates = config.getInt("oryx.ml.eval.candidates"); this.evalParallelism = config.getInt("oryx.ml.eval.parallelism"); this.threshold = ConfigUtils.getOptionalDouble(config, "oryx.ml.eval.threshold"); this.maxMessageSize = config.getInt("oryx.update-topic.message.max-size"); Preconditions.checkArgument(testFraction >= 0.0 && testFraction <= 1.0); Preconditions.checkArgument(candidates > 0); Preconditions.checkArgument(evalParallelism > 0); Preconditions.checkArgument(maxMessageSize > 0); if (testFraction == 0.0 && candidates > 1) { log.info("Eval is disabled (test fraction = 0) so candidates is overridden to 1"); candidates = 1; } this.candidates = candidates; this.hyperParamSearch = config.getString("oryx.ml.eval.hyperparam-search"); }
Example 3
Source File: HyperParams.java From ytk-learn with MIT License | 6 votes |
public Hoag(Config config, String prefix) { init_step = config.getDouble(prefix + KEY + "init_step"); step_decr_factor = config.getDouble(prefix + KEY + "step_decr_factor"); test_loss_reduce_limit = config.getDouble(prefix + KEY + "test_loss_reduce_limit"); outer_iter = config.getInt(prefix + KEY + "outer_iter"); List<Double> l1List = config.getDoubleList(prefix + KEY + "l1"); List<Double> l2List = config.getDoubleList(prefix + KEY + "l2"); l1 = new double[l1List.size()]; l2 = new double[l2List.size()]; for (int i = 0; i < l2.length; i ++) { l1[i] = l1List.get(i); l2[i] = l2List.get(i); } CheckUtils.check(step_decr_factor < 1.0, "%sstep_decr_factor:%f must < 1.0", prefix + KEY, step_decr_factor); CheckUtils.check(l1.length == l2.length, "%sl1 lenght must be equal to %sl2 lenght", prefix + KEY, prefix + KEY); }
Example 4
Source File: SameTopologySlotStrategy.java From eagle with Apache License 2.0 | 6 votes |
public SameTopologySlotStrategy(IScheduleContext context, StreamGroup streamPartitionGroup, TopologyMgmtService mgmtService) { this.context = context; this.partitionGroup = streamPartitionGroup; this.mgmtService = mgmtService; Config config = ConfigFactory.load().getConfig(CoordinatorConstants.CONFIG_ITEM_COORDINATOR); numOfPoliciesBoundPerBolt = config.getInt(CoordinatorConstants.POLICIES_PER_BOLT); topoLoadUpbound = config.getDouble(CONFIG_ITEM_TOPOLOGY_LOAD_UPBOUND); if (config.hasPath(CoordinatorConstants.REUSE_BOLT_IN_STREAMS)) { reuseBoltInStreams = config.getBoolean(CoordinatorConstants.REUSE_BOLT_IN_STREAMS); } else { reuseBoltInStreams = false; } if (config.hasPath(CoordinatorConstants.STREAMS_PER_BOLT)) { streamsPerBolt = config.getInt(CoordinatorConstants.STREAMS_PER_BOLT); } else { streamsPerBolt = 1; } }
Example 5
Source File: SelfHealingEngine.java From healenium-web with Apache License 2.0 | 6 votes |
/** * @param delegate a delegate driver, not actually {@link SelfHealingDriver} instance. * @param config user-defined configuration */ public SelfHealingEngine(@NotNull WebDriver delegate, @NotNull Config config) { // merge given config with default values Config finalizedConfig = ConfigFactory.load(config).withFallback(DEFAULT_CONFIG); List<Set<SelectorComponent>> temp = new ArrayList<>(); temp.add(EnumSet.of(TAG, ID)); temp.add(EnumSet.of(TAG, CLASS)); temp.add(EnumSet.of(PARENT, TAG, ID, CLASS)); temp.add(EnumSet.of(PARENT, TAG, CLASS, POSITION)); temp.add(EnumSet.of(PARENT, TAG, ID, CLASS, ATTRIBUTES)); temp.add(EnumSet.of(PATH)); this.webDriver = delegate; this.config = finalizedConfig; this.recoveryTries = finalizedConfig.getInt("recovery-tries"); this.scoreCap = finalizedConfig.getDouble("score-cap"); this.selectorDetailLevels = Collections.unmodifiableList(temp); this.client = new RestClient(finalizedConfig); }
Example 6
Source File: DataInitializerFactory.java From adaptive-alerting with Apache License 2.0 | 5 votes |
private static ThrottleGate tryCreateThrottleGate(Config config) { try { val throttleGateLikelihood = config.getDouble(THROTTLE_GATE_LIKELIHOOD); return new RandomThrottleGate(throttleGateLikelihood); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Could not load '%s' from config.", THROTTLE_GATE_LIKELIHOOD)); } }
Example 7
Source File: Args.java From gsc-core with GNU Lesser General Public License v3.0 | 5 votes |
private static void initRocksDbSettings(Config config) { String prefix = "storage.dbSettings."; int levelNumber = config.hasPath(prefix + "levelNumber") ? config.getInt(prefix + "levelNumber") : 7; int compactThreads = config.hasPath(prefix + "compactThreads") ? config.getInt(prefix + "compactThreads") : max(Runtime.getRuntime().availableProcessors(), 1); int blocksize = config.hasPath(prefix + "blocksize") ? config.getInt(prefix + "blocksize") : 16; long maxBytesForLevelBase = config.hasPath(prefix + "maxBytesForLevelBase") ? config.getInt(prefix + "maxBytesForLevelBase") : 256; double maxBytesForLevelMultiplier = config.hasPath(prefix + "maxBytesForLevelMultiplier") ? config.getDouble(prefix + "maxBytesForLevelMultiplier") : 10; int level0FileNumCompactionTrigger = config.hasPath(prefix + "level0FileNumCompactionTrigger") ? config .getInt(prefix + "level0FileNumCompactionTrigger") : 2; long targetFileSizeBase = config.hasPath(prefix + "targetFileSizeBase") ? config .getLong(prefix + "targetFileSizeBase") : 64; int targetFileSizeMultiplier = config.hasPath(prefix + "targetFileSizeMultiplier") ? config .getInt(prefix + "targetFileSizeMultiplier") : 1; INSTANCE.rocksDBCustomSettings = RocksDbSettings .initCustomSettings(levelNumber, compactThreads, blocksize, maxBytesForLevelBase, maxBytesForLevelMultiplier, level0FileNumCompactionTrigger, targetFileSizeBase, targetFileSizeMultiplier); RocksDbSettings.loggingSettings(); }
Example 8
Source File: Configs.java From kite with Apache License 2.0 | 5 votes |
public double getDouble(Config config, String path, double defaults) { addRecognizedArgument(path); if (config.hasPath(path)) { return config.getDouble(path); } else { return defaults; } }
Example 9
Source File: RateBasedLimiter.java From incubator-gobblin with Apache License 2.0 | 5 votes |
@Override public Limiter buildLimiter(Config config) { if (!config.hasPath(QPS_KEY)) { throw new RuntimeException("Missing key " + QPS_KEY); } return new RateBasedLimiter(config.getDouble(QPS_KEY)); }
Example 10
Source File: CopyResourcePool.java From incubator-gobblin with Apache License 2.0 | 5 votes |
/** * Parse a {@link CopyResourcePool} from an input {@link Config}. */ public static CopyResourcePool fromConfig(Config limitedScopeConfig) { try { String sizeStr = limitedScopeConfig.hasPath(SIZE_KEY) ? limitedScopeConfig.getString(SIZE_KEY) : DEFAULT_MAX_SIZE; long maxSize = StringParsingUtils.humanReadableToByteCount(sizeStr); int maxEntities = limitedScopeConfig.hasPath(ENTITIES_KEY) ? limitedScopeConfig.getInt(ENTITIES_KEY) : DEFAULT_MAX_ENTITIES; double tolerance = limitedScopeConfig.hasPath(TOLERANCE_KEY) ? limitedScopeConfig.getDouble(TOLERANCE_KEY) : DEFAULT_TOLERANCE; return new CopyResourcePool(ImmutableMap.of(ENTITIES_DIMENSION, (double) maxEntities, BYTES_DIMENSION, (double) maxSize), ImmutableMap.of(ENTITIES_DIMENSION, tolerance, BYTES_DIMENSION, tolerance), ImmutableMap.<String, Double>of()); } catch (StringParsingUtils.FormatException fe) { throw new RuntimeException(fe); } }
Example 11
Source File: Simulator.java From parity-extras with Apache License 2.0 | 5 votes |
private static Model.Config modelConfig(Config config) { double n = config.getDouble("model.n"); double s = config.getDouble("model.s"); double mu = config.getDouble("model.mu"); double delta = config.getDouble("model.delta"); long sigma = config.getLong("model.sigma"); return new Model.Config(n, s, mu, delta, sigma); }
Example 12
Source File: ALSServingModelManager.java From oryx with Apache License 2.0 | 5 votes |
public ALSServingModelManager(Config config) { super(config); String rescorerProviderClass = ConfigUtils.getOptionalString(config, "oryx.als.rescorer-provider-class"); rescorerProvider = loadRescorerProviders(rescorerProviderClass); sampleRate = config.getDouble("oryx.als.sample-rate"); minModelLoadFraction = config.getDouble("oryx.serving.min-model-load-fraction"); Preconditions.checkArgument(sampleRate > 0.0 && sampleRate <= 1.0); Preconditions.checkArgument(minModelLoadFraction >= 0.0 && minModelLoadFraction <= 1.0); logRateLimit = new RateLimitCheck(1, TimeUnit.MINUTES); }
Example 13
Source File: RandomParams.java From ytk-learn with MIT License | 4 votes |
public Uniform(Config config, String prefix) { range_start = config.getDouble(prefix + KEY + "range_start"); range_end = config.getDouble(prefix + KEY + "range_end"); }
Example 14
Source File: ALSSpeedModelManager.java From oryx with Apache License 2.0 | 4 votes |
public ALSSpeedModelManager(Config config) { noKnownItems = config.getBoolean("oryx.als.no-known-items"); minModelLoadFraction = config.getDouble("oryx.speed.min-model-load-fraction"); Preconditions.checkArgument(minModelLoadFraction >= 0.0 && minModelLoadFraction <= 1.0); logRateLimit = new RateLimitCheck(1, TimeUnit.MINUTES); }
Example 15
Source File: ConfigBeanImpl.java From mpush with Apache License 2.0 | 4 votes |
private static Object getValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, Config config, String configPropName) { if (parameterClass == Boolean.class || parameterClass == boolean.class) { return config.getBoolean(configPropName); } else if (parameterClass == Integer.class || parameterClass == int.class) { return config.getInt(configPropName); } else if (parameterClass == Double.class || parameterClass == double.class) { return config.getDouble(configPropName); } else if (parameterClass == Long.class || parameterClass == long.class) { return config.getLong(configPropName); } else if (parameterClass == String.class) { return config.getString(configPropName); } else if (parameterClass == Duration.class) { return config.getDuration(configPropName); } else if (parameterClass == ConfigMemorySize.class) { return config.getMemorySize(configPropName); } else if (parameterClass == Object.class) { return config.getAnyRef(configPropName); } else if (parameterClass == List.class) { return getListValue(beanClass, parameterType, parameterClass, config, configPropName); } else if (parameterClass == Map.class) { // we could do better here, but right now we don't. Type[] typeArgs = ((ParameterizedType) parameterType).getActualTypeArguments(); if (typeArgs[0] != String.class || typeArgs[1] != Object.class) { throw new ConfigException.BadBean("Bean property '" + configPropName + "' of class " + beanClass.getName() + " has unsupported Map<" + typeArgs[0] + "," + typeArgs[1] + ">, only Map<String,Object> is supported right now"); } return config.getObject(configPropName).unwrapped(); } else if (parameterClass == Config.class) { return config.getConfig(configPropName); } else if (parameterClass == ConfigObject.class) { return config.getObject(configPropName); } else if (parameterClass == ConfigValue.class) { return config.getValue(configPropName); } else if (parameterClass == ConfigList.class) { return config.getList(configPropName); } else if (hasAtLeastOneBeanProperty(parameterClass)) { return createInternal(config.getConfig(configPropName), parameterClass); } else { throw new ConfigException.BadBean("Bean property " + configPropName + " of class " + beanClass.getName() + " has unsupported type " + parameterType); } }
Example 16
Source File: GBDTOptimizationParams.java From ytk-learn with MIT License | 4 votes |
public Regularization(Config config, String prefix) { l1 = config.getDouble(prefix + KEY + "l1"); l2 = config.getDouble(prefix + KEY + "l2"); learningRate = (float)config.getDouble(prefix + KEY + "learning_rate"); }
Example 17
Source File: TransformParams.java From ytk-learn with MIT License | 4 votes |
public ScaleRange(Config config, String prefix) { min = config.getDouble(prefix + KEY + "min"); max = config.getDouble(prefix + KEY + "max"); }
Example 18
Source File: LineSearchParams.java From ytk-learn with MIT License | 4 votes |
public Convergence(Config config, String prefix) { max_iter = config.getInt(prefix + KEY + "max_iter"); eps = config.getDouble(prefix + KEY + "eps"); }
Example 19
Source File: XConfig.java From xrpc with Apache License 2.0 | 4 votes |
/** * Construct a config object using the provided configuration, falling back on the default * configuration values <a * href="https://github.com/Nordstrom/xrpc/blob/master/src/main/resources/com/nordstrom/xrpc/xrpc.conf">here</a>. * * @throws RuntimeException if there is an error reading one of path_to_cert or path_to_key */ public XConfig(Config configOverrides) { Config defaultConfig = ConfigFactory.parseResources(this.getClass(), "xrpc.conf"); Config config = configOverrides.withFallback(defaultConfig); readerIdleTimeout = config.getInt("reader_idle_timeout_seconds"); writerIdleTimeout = config.getInt("writer_idle_timeout_seconds"); allIdleTimeout = config.getInt("all_idle_timeout_seconds"); workerNameFormat = config.getString("worker_name_format"); bossThreadCount = config.getInt("boss_thread_count"); workerThreadCount = config.getInt("worker_thread_count"); asyncHealthCheckThreadCount = config.getInt("async_health_check_thread_count"); long maxPayloadBytesLong = config.getBytes("max_payload_bytes"); Preconditions.checkArgument( maxPayloadBytesLong <= Integer.MAX_VALUE, String.format( "value %d for max_payload_bytes must be less than or equal to %d", maxPayloadBytesLong, Integer.MAX_VALUE)); maxPayloadBytes = (int) maxPayloadBytesLong; maxConnections = config.getInt("max_connections"); rateLimiterPoolSize = config.getInt("rate_limiter_pool_size"); softReqPerSec = config.getDouble("soft_req_per_sec"); hardReqPerSec = config.getDouble("hard_req_per_sec"); adminRoutesEnableInfo = config.getBoolean("admin_routes.enable_info"); adminRoutesEnableUnsafe = config.getBoolean("admin_routes.enable_unsafe"); defaultContentType = config.getString("default_content_type"); globalSoftReqPerSec = config.getDouble("global_soft_req_per_sec"); globalHardReqPerSec = config.getDouble("global_hard_req_per_sec"); port = config.getInt("server.port"); slf4jReporter = config.getBoolean("slf4j_reporter"); jmxReporter = config.getBoolean("jmx_reporter"); consoleReporter = config.getBoolean("console_reporter"); slf4jReporterPollingRate = config.getInt("slf4j_reporter_polling_rate"); consoleReporterPollingRate = config.getInt("console_reporter_polling_rate"); enableWhiteList = config.getBoolean("enable_white_list"); enableBlackList = config.getBoolean("enable_black_list"); ipBlackList = ImmutableSet.<String>builder().addAll(config.getStringList("ip_black_list")).build(); ipWhiteList = ImmutableSet.<String>builder().addAll(config.getStringList("ip_white_list")).build(); corsConfig = buildCorsConfig(config.getConfig("cors")); sslContext = SslContextFactory.buildServerContext(buildTlsConfig(config.getConfig("tls"))); populateClientOverrideList(config.getObjectList("req_per_second_override")); }
Example 20
Source File: ConfigUtils.java From incubator-gobblin with Apache License 2.0 | 3 votes |
/** * Return double value at <code>path</code> if <code>config</code> has path. If not return <code>def</code> * * @param config in which the path may be present * @param path key to look for in the config object * @return double value at <code>path</code> if <code>config</code> has path. If not return <code>def</code> */ public static double getDouble(Config config, String path, double def) { if (config.hasPath(path)) { return config.getDouble(path); } return def; }