本文整理了Java中com.typesafe.config.Config.withFallback()
方法的一些代码示例,展示了Config.withFallback()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.withFallback()
方法的具体详情如下:
包路径:com.typesafe.config.Config
类名称:Config
方法名:withFallback
暂无
代码示例来源:origin: apache/incubator-gobblin
@Override
protected Config getLocallyResolvedConfig(Config userConfig) {
return userConfig.withFallback(this.rawConfig);
}
}
代码示例来源:origin: ben-manes/caffeine
Configurator(Config config, String cacheName) {
this.root = requireNonNull(config);
this.configuration = new CaffeineConfiguration<>();
this.customized = root.getConfig("caffeine.jcache." + cacheName);
this.merged = customized.withFallback(root.getConfig("caffeine.jcache.default"));
}
代码示例来源:origin: mpusher/mpush
static Config load() {
Config config = ConfigFactory.load();//扫描加载所有可用的配置文件
String custom_conf = "mp.conf";//加载自定义配置, 值来自jvm启动参数指定-Dmp.conf
if (config.hasPath(custom_conf)) {
File file = new File(config.getString(custom_conf));
if (file.exists()) {
Config custom = ConfigFactory.parseFile(file);
config = custom.withFallback(config);
}
}
return config;
}
代码示例来源:origin: ethereum/ethereumj
/**
* Puts a new config atop of existing stack making the options
* in the supplied config overriding existing options
* Once put this config can't be removed
*
* @param overrideOptions - atop config
*/
public void overrideParams(Config overrideOptions) {
config = overrideOptions.withFallback(config);
validateConfig();
}
代码示例来源:origin: apache/incubator-gobblin
public QuartzJobSpecScheduler(Optional<Logger> log, Config cfg, Optional<SchedulerService> scheduler) {
super(log);
_scheduler = scheduler.isPresent() ? scheduler.get() : createDefaultSchedulerService(cfg);
_cfg = new StandardServiceConfig(cfg.withFallback(DEFAULT_CFG));
}
代码示例来源:origin: apache/incubator-gobblin
public ApacheHttpClient(HttpClientBuilder builder, Config config, SharedResourcesBroker<GobblinScopeTypes> broker) {
super (broker, HttpUtils.createApacheHttpClientLimiterKey(config));
config = config.withFallback(FALLBACK);
RequestConfig requestConfig = RequestConfig.copy(RequestConfig.DEFAULT)
.setSocketTimeout(config.getInt(REQUEST_TIME_OUT_MS_KEY))
.setConnectTimeout(config.getInt(CONNECTION_TIME_OUT_MS_KEY))
.setConnectionRequestTimeout(config.getInt(CONNECTION_TIME_OUT_MS_KEY))
.build();
builder.disableCookieManagement().useSystemProperties().setDefaultRequestConfig(requestConfig);
builder.setConnectionManager(getHttpConnManager(config));
client = builder.build();
}
代码示例来源:origin: apache/incubator-gobblin
private Config loadHoconConfigWithFallback(Path path, Config fallback) throws IOException {
try (InputStream is = fs.open(path);
Reader reader = new InputStreamReader(is, Charsets.UTF_8)) {
return ConfigFactory.parseMap(ImmutableMap.of(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY,
PathUtils.getPathWithoutSchemeAndAuthority(path).toString()))
.withFallback(ConfigFactory.parseReader(reader, ConfigParseOptions.defaults().setSyntax(ConfigSyntax.CONF)))
.withFallback(fallback);
}
}
代码示例来源:origin: OryxProject/oryx
/**
* @param serialized serialized form of configuration as JSON-like data
* @return {@link Config} from the serialized config
*/
public static Config deserialize(String serialized) {
return ConfigFactory.parseString(serialized).resolve().withFallback(DEFAULT_CONFIG);
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public JobSpecMonitor forJobCatalog(GobblinInstanceDriver instanceDriver, MutableJobCatalog jobCatalog)
throws IOException {
Config config = instanceDriver.getSysConfig().getConfig().getConfig(CONFIG_PREFIX).withFallback(DEFAULTS);
return forConfig(config, jobCatalog);
}
代码示例来源:origin: apache/incubator-gobblin
private Config loadHoconConfigAtPath(Path path) throws IOException {
try (InputStream is = fs.open(path);
Reader reader = new InputStreamReader(is, Charsets.UTF_8)) {
return ConfigFactory.parseMap(ImmutableMap.of(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY,
PathUtils.getPathWithoutSchemeAndAuthority(path).toString()))
.withFallback(ConfigFactory.parseReader(reader, ConfigParseOptions.defaults().setSyntax(ConfigSyntax.CONF)));
}
}
代码示例来源:origin: apache/incubator-gobblin
@Override
protected Map<String, Config> overrideJobConfigs(Config rawJobConfig) {
Config newConfig = ConfigFactory.parseMap(ImmutableMap.of(
GobblinClusterConfigurationKeys.DISTRIBUTED_JOB_LAUNCHER_ENABLED, true,
GobblinClusterConfigurationKeys.DISTRIBUTED_JOB_LAUNCHER_BUILDER, "TestDistributedExecutionLauncherBuilder"))
.withFallback(rawJobConfig);
return ImmutableMap.of("HelloWorldJob", newConfig);
}
代码示例来源:origin: apache/incubator-gobblin
@Override
protected Map<String, Config> overrideJobConfigs(Config rawJobConfig) {
Config newConfig = ConfigFactory.parseMap(ImmutableMap.of(
ConfigurationKeys.SOURCE_CLASS_KEY, "org.apache.gobblin.cluster.SleepingCustomTaskSource",
ConfigurationKeys.JOB_ID_KEY, JOB_ID,
GobblinClusterConfigurationKeys.HELIX_JOB_TIMEOUT_ENABLED_KEY, Boolean.TRUE,
GobblinClusterConfigurationKeys.HELIX_JOB_TIMEOUT_SECONDS, 10L))
.withFallback(rawJobConfig);
return ImmutableMap.of("HelloWorldJob", newConfig);
}
代码示例来源:origin: apache/incubator-gobblin
public static Config setAutoScopeLevel(Config config, GobblinScopeTypes level) {
return ConfigFactory.parseMap(ImmutableMap.of(
JOINER.join(BrokerConstants.GOBBLIN_BROKER_CONFIG_PREFIX, NAME, AUTOSCOPE_AT), level.name()))
.withFallback(config);
}
代码示例来源:origin: apache/incubator-gobblin
@Override
protected Config getLocallyResolvedConfig(Config userConfig) throws TemplateException {
for (String required : this.required) {
if (!userConfig.hasPath(required)) {
throw new TemplateException("Missing required property " + required);
}
}
return userConfig.withFallback(getLocalRawTemplate());
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public Collection<Config> getWorkerConfigs() {
Config rawConfig = super.getWorkerConfigs().iterator().next();
Config workerConfig = ConfigFactory.parseMap(ImmutableMap.of(GobblinClusterConfigurationKeys.TASK_RUNNER_SUITE_BUILDER, "TestJobFactorySuiteBuilder"))
.withFallback(rawConfig);
return Lists.newArrayList(workerConfig);
}
代码示例来源:origin: apache/incubator-gobblin
protected Collection<Config> getWorkerConfigs() {
// worker config initialization
URL url = Resources.getResource("BasicWorker.conf");
Config workerConfig = ConfigFactory.parseURL(url);
workerConfig = workerConfig.withFallback(getClusterConfig());
return Lists.newArrayList(workerConfig.resolve());
}
代码示例来源:origin: apache/incubator-gobblin
@Override
protected Collection<Config> getTaskDriverConfigs() {
// task driver config initialization
URL url = Resources.getResource("BasicTaskDriver.conf");
Config taskDriverConfig = ConfigFactory.parseURL(url);
taskDriverConfig = taskDriverConfig.withFallback(getClusterConfig());
Config taskDriver1 = addInstanceName(taskDriverConfig, "TaskDriver1");
return ImmutableList.of(taskDriver1);
}
代码示例来源:origin: ben-manes/caffeine
public Indicator(Config config) {
this.sketch = new PeriodicResetCountMin4(
ConfigFactory.parseString("maximum-size = 5000").withFallback(config));
IndicatorSettings settings = new IndicatorSettings(config);
this.sample = 0;
this.k = settings.k();
this.ssSize = settings.ssSize();
this.estSkew = new EstSkew();
this.hinter = new Hinter();
}
代码示例来源:origin: apache/incubator-gobblin
public Config getManagerConfig() {
// manager config initialization
URL url = Resources.getResource("BasicManager.conf");
Config managerConfig = ConfigFactory.parseURL(url);
managerConfig = managerConfig.withFallback(getClusterConfig());
return managerConfig.resolve();
}
代码示例来源:origin: ben-manes/caffeine
public MiniSimClimber(Config config) {
MiniSimSettings settings = new MiniSimSettings(config);
R = (settings.maximumSize() / 1000) > 100 ? 1000 : (settings.maximumSize() / 100);
WindowTinyLfuSettings simulationSettings = new WindowTinyLfuSettings(ConfigFactory
.parseString("maximum-size = " + settings.maximumSize() / R)
.withFallback(config));
this.prevPercent = 1 - settings.percentMain().get(0);
this.cacheSize = settings.maximumSize();
this.period = settings.minisimPeriod();
this.minis = new WindowTinyLfuPolicy[101];
this.prevMisses = new long[101];
for (int i = 0; i < minis.length; i++) {
double percentMain = 1.0 - (i / 100.0);
minis[i] = new WindowTinyLfuPolicy(percentMain, simulationSettings);
}
}
内容来源于网络,如有侵权,请联系作者删除!