public ConfigObject include(ConfigIncludeContext context, String what) { File file = new File(what); // Attempt to locate the file if (!file.exists()) { file = new File("profiles", what); } return ConfigFactory.parseFileAnySyntax(file).root(); }
public ConfigObject include(ConfigIncludeContext context, String what) { return ConfigFactory.parseFileAnySyntax(new File(what)).root(); }
@Override public Set<Entry<String, Object>> propertySet(final Object context) { if (context instanceof Config) { return ((Config) context).root().unwrapped().entrySet(); } return Collections.emptySet(); }
public ConfigObject include(ConfigIncludeContext context, String what) { return ConfigFactory.parseFileAnySyntax(new File(what)).root(); }
static boolean init() { if (logInit) return true; System.setProperty("log.home", CC.mp.log_dir); System.setProperty("log.root.level", CC.mp.log_level); System.setProperty("logback.configurationFile", CC.mp.log_conf_path); LoggerFactory .getLogger("console") .info(CC.mp.cfg.root().render(ConfigRenderOptions.concise().setFormatted(true))); return true; }
static List<String> buildPropertiesLines() { ConfigObject config = (ConfigObject) ConfigUtils.getDefault().root().get("oryx"); Map<String,String> keyValueMap = new TreeMap<>(); add(config, "oryx", keyValueMap); return keyValueMap.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.toList()); }
private Iterable<String> names(final Config conf) { Set<String> result = new LinkedHashSet<>(); conf.root().forEach((k, v) -> result.add(ConfigUtil.splitPath(k).get(0))); return result; }
@Test public void testLoad2() { Map<String, String> map = new HashMap<>(); System.out.println("public interface mp {"); System.out.printf(" Config cfg = ConfigManager.I.mp().toConfig();%n%n"); CC.mp.cfg.root().forEach((s, configValue) -> print2(s, configValue, "mp", 1)); System.out.println("}"); }
@SuppressWarnings("unchecked") private VersionSelectionPolicy<T> createSelectionPolicy(String className, Config config, Properties jobProps) { try { this.log.debug(String.format("Configuring selection policy %s for %s with %s", className, this.datasetRoot, config.root().render(ConfigRenderOptions.concise()))); return (VersionSelectionPolicy<T>) GobblinConstructorUtils.invokeFirstConstructor(Class.forName(className), ImmutableList.<Object> of(config), ImmutableList.<Object> of(config, jobProps), ImmutableList.<Object> of(jobProps)); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) { throw new IllegalArgumentException(e); } } }
static Config flyway(Config conf) { Config flyway = conf.root().entrySet().stream() .filter(it -> isFlywayProperty(it.getKey())) .reduce(empty(), (seed, entry) -> seed.withValue(entry.getKey(), entry.getValue()), Config::withFallback); return flyway; }
@Override public MultiAccessControlAction createRetentionAction(Config config, FileSystem fs, Config jobConfig) { Preconditions.checkArgument(this.canCreateWithConfig(config), "Can not create MultiAccessControlAction with config " + config.root().render(ConfigRenderOptions.concise())); if (config.hasPath(LEGACY_ACCESS_CONTROL_KEY)) { return new MultiAccessControlAction(config.getConfig(LEGACY_ACCESS_CONTROL_KEY), fs, jobConfig); } else if (config.hasPath(ACCESS_CONTROL_KEY)) { return new MultiAccessControlAction(config.getConfig(ACCESS_CONTROL_KEY), fs, jobConfig); } throw new IllegalStateException( "RetentionActionFactory.canCreateWithConfig returned true but could not create MultiAccessControlAction"); }
public void saveConfigToFile(final Config config, final Path destPath) throws IOException { final String configAsHoconString = config.root().render(); this.fileUtils.saveToFile(configAsHoconString, destPath); }
@VisibleForTesting public DrillConfig(Config config) { super(config); logger.debug("Setting up DrillConfig object."); // we need to exclude sun.java.command config node while logging, because // it contains user password along with other parameters logger.trace("Given Config object is:\n{}", config.withoutPath("password").withoutPath("sun.java.command") .root().render(ConfigRenderOptions.defaults())); RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean(); this.startupArguments = ImmutableList.copyOf(bean.getInputArguments()); logger.debug("DrillConfig object initialized."); }
/** * @param config {@link Config} to print * @return pretty-printed version of config values, excluding those * inherited from the local JVM environment */ public static String prettyPrint(Config config) { return redact(config.root().withOnlyKey("oryx").render(RENDER_OPTS)); }
/** * @param config {@link Config} to serialize to a String * @return JSON-like representation of properties in the configuration, excluding those * inherited from the local JVM environment */ public static String serialize(Config config) { return config.root().withOnlyKey("oryx").render(ConfigRenderOptions.concise()); }
public String dump() { return config.root().render(ConfigRenderOptions.defaults().setComments(false)); }
private void writeJobConf(String jobName, Config jobConfig) throws IOException { String targetPath = this.jobConfigPath + "/" + jobName + ".conf"; String renderedConfig = jobConfig.root().render(ConfigRenderOptions.defaults()); try (DataOutputStream os = new DataOutputStream(new FileOutputStream(targetPath)); Writer writer = new OutputStreamWriter(os, Charsets.UTF_8)) { writer.write(renderedConfig); } }
@Override public synchronized Model.LoadedConfig loadedConfig() { return new LoadedConfigBuilder() .spNode(filteredConfig().root()) .build(); }
@Override public void run(String[] args) throws Exception { CliObjectFactory<Command> factory = new ConstructorAndPublicMethodsCliObjectFactory<>(Command.class); Command command = factory.buildObject(args, 1, true, args[0]); ConfigClient configClient = ConfigClient.createConfigClient(VersionStabilityPolicy.READ_FRESHEST); if (command.resolvedConfig) { Config resolvedConfig = configClient.getConfig(command.uri); System.out.println(resolvedConfig.root().render(ConfigRenderOptions.defaults())); } }
public static <T> String serializeToString(T object) { Config config = ConfigFactory.parseMap(serialize(object).toJavaMap()); return config.root().render(ConfigRenderOptions.defaults().setJson(false).setOriginComments(false)); }