private void dispatchConfig(Config config, ConfigCallback callback) { for (Map.Entry<String, ConfigValue> entry : config.root().entrySet()) { final String id = entry.getKey(); try { final Config entryConfig = ((ConfigObject) entry.getValue()).toConfig(); final String type = entryConfig.getString("type"); if (Strings.isNullOrEmpty(type)) { errors.add(new ConfigurationError("Missing type field for " + id + " (" + entryConfig + ")")); continue; } callback.call(type, id, entryConfig); } catch (ConfigException e) { errors.add(new ConfigurationError("[" + id + "] " + e.getMessage())); } } }
KeyValue(Map.Entry<String, ConfigValue> keyValue) { key = keyValue.getKey(); description = createDescription(keyValue.getValue()); try { if (keyValue.getValue().valueType() == ConfigValueType.NULL) { valueType = "N/A (null)"; defaultValue = "null"; } else { valueType = keyValue.getValue().valueType().name().toLowerCase(); defaultValue = render(keyValue.getValue()); } } catch (ConfigException.NotResolved e) { valueType = "N/A (unresolved)"; defaultValue = keyValue.getValue().render(); } }
public RelationExtractionRunner(Config config) { // load boolean values this.exploitCore = config.getBoolean("exploit-core"); this.exploitContexts = config.getBoolean("exploit-contexts"); this.separateNounBased = config.getBoolean("separate-noun-based"); this.separatePurposes = config.getBoolean("separate-purposes"); this.separateAttributions = config.getBoolean("separate-attributions"); // instantiate extractor String extractorClassName = config.getString("relation-extractor"); try { Class<?> extractorClass = Class.forName(extractorClassName); Constructor<?> extractorConst = extractorClass.getConstructor(); this.extractor = (RelationExtractor) extractorConst.newInstance(); } catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException | ClassNotFoundException e) { logger.error("Failed to create instance of {}", extractorClassName); throw new ConfigException.BadValue("relation-extractor." + extractorClassName, "Failed to create instance."); } this.elementCoreExtractionMap = new LinkedHashMap<>(); }
private BitcoinValidatorFactory createBitcoinValidatorFactory(Config config) { String chain = config.getString("blockchain.chain"); if ("testnet3".equals(chain)) { return new BitcoinValidatorFactory(new BitcoinTestnetValidatorConfig()); } else if ("regtest".equals(chain)) { BitcoinRegtestValidatorConfig bitcoinConfig = new BitcoinRegtestValidatorConfig(); if (config.hasPath("feature") && config.getBoolean("feature.native-assets")) return new BitcoinValidatorFactory(bitcoinConfig, new NativeAssetValidator(bitcoinConfig)); else return new BitcoinValidatorFactory(bitcoinConfig); } else if ("production".equals(chain)) { return new BitcoinValidatorFactory(new BitcoinProductionValidatorConfig()); } else if ("signedregtest".equals(chain)) { return new BitcoinValidatorFactory(new SignedRegtestValidatorConfig()); } else { throw new ConfigException.BadValue(config.origin(), "blockchain.chain", "Invalid chain: " + chain); } }
public MiningSettingsFactory(Config config) { String minerAddress = null; try { Config c = config.getConfig("mining"); if (c != null) { boolean enabled = c.getBoolean("enabled"); if (!c.hasPath("minerAddress")) { throw new ConfigException.Missing("mining.minerAddress"); } minerAddress = c.getString("minerAddress"); if (enabled) { int delayBetweenMiningBlocksSecs = c.getInt("delayBetweenMiningBlocksSecs"); miningConfig = new MiningConfig(true, minerAddress, delayBetweenMiningBlocksSecs); } else { miningConfig = new MiningConfig(false, minerAddress, 0); } } else { miningConfig = MiningConfig.DISABLED; } } catch (HyperLedgerException e) { throw new ConfigException.BadValue(config.origin(), "mining.minerAddress", "Cannot decode the minerAddress: " + minerAddress); } }
private int toPix(final Config c, final String key) { try { return c.getInt(key); } catch (ConfigException.WrongType e) { final String valueStr = c.getString(key); final Matcher matcher = NUMBER.matcher(valueStr); if (matcher.matches()) { float factor = 0; if ("mm".equals(matcher.group(2))) { factor = MM_TO_PIXEL; } else if ("cm".equals(matcher.group(2))) { factor = CM_TO_PIXEL; } else if ("pt".equals(matcher.group(2))) { factor = PT_TO_PIXEL; } return Math.round(factor * Float.parseFloat(matcher.group(1))); } else { throw new RuntimeException("Exclusion can't be read. String not parsable to a number: " + valueStr); } } }
@Test public void testWithTextFile(TestContext tc) { Async async = tc.async(); retriever = ConfigurationRetriever.create(vertx, new ConfigurationRetrieverOptions().addStore( new ConfigurationStoreOptions() .setType("file") .setFormat("hocon") .setConfig(new JsonObject().put("path", "src/test/resources/some-text.txt")))); retriever.getConfiguration(ar -> { assertThat(ar.failed()).isTrue(); assertThat(ar.cause()).isNotNull().isInstanceOf(ConfigException.class); async.complete(); }); }
/** * Validates that the passed in config object contains a valid storage account types section by * checking that the param is: * - not absent, null, or wrong type * - not an empty list * - contains only valid Storage Accounts * * @param instanceSection the instance section of the Azure Plugin config * @throws IllegalArgumentException if the list is empty or a storage account type in the list is * not valid * @throws ConfigException if the storage account type list config section is missing or the wrong * type */ static void validateStorageAccountType(Config instanceSection) throws IllegalArgumentException, ConfigException { List<String> storageAccountTypes = instanceSection .getStringList(Configurations.AZURE_CONFIG_INSTANCE_STORAGE_ACCOUNT_TYPES); if (storageAccountTypes.size() == 0) { throw new IllegalArgumentException(String.format( "The list of Storage Accounts to validate is empty. Valid types: %s.", Arrays.asList(SkuName.values()))); } for (String storageAccountType : storageAccountTypes) { storageAccountType = Configurations.convertStorageAccountTypeString(storageAccountType); if (SkuName.fromString(storageAccountType) == null) { throw new IllegalArgumentException(String.format("Storage Account Type '%s' is not " + "valid. Valid types: %s, valid deprecated types: %s.", storageAccountType, Arrays.asList(SkuName.values()), Configurations.DEPRECATED_STORAGE_ACCOUNT_TYPES.keySet())); } } }
@FXML protected void handleStartAction(ActionEvent event) { try { clientExecutor.setListeners(Arrays.asList(new ProgressBarUpdater(), new RunButtonUpdater())); clientExecutor.setConfig(configMap); clientExecutor.run(); } catch (IllegalArgumentException | NullPointerException | ConfigException e) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.initModality(Modality.APPLICATION_MODAL); alert.initStyle(StageStyle.UTILITY); alert.setTitle("Ошибка"); alert.setHeaderText("Произошла ошибка"); alert.setContentText(e.getMessage()); alert.showAndWait(); } }
/** * Validates given config, returns it on success or throws exception on error * * @param config Config to validate * @return Validated config * @throws ConfigException.Generic If validation of field fails */ public static Config checkValid(Config config) { ConfigValidator validator = new ConfigValidator(config); try { checkNotNull(config); validator.checkLogLevel(); validator.checkAuth(); validator.checkMode(); validator.checkList(); validator.checkDocumentSourceTypes(); validator.checkComparators(); validator.checkUserAgent(); validator.checkYearDeviation(); validator.checkTimeout(); validator.checkDataBase(); } catch (NullPointerException | IllegalArgumentException e) { throw new ConfigException.Generic(e.getMessage(), e); } return config; }
@Test public void checkList() throws Exception { checkValid(parseMap(configMap)); configMap.replace("list", ""); assertThatThrownBy(() -> checkValid(parseMap(configMap))) .isInstanceOf(ConfigException.class); configMap.replace("list", "ls"); assertThatThrownBy(() -> checkValid(parseMap(configMap))) .isInstanceOf(ConfigException.class); configMap.replace("list", "0123456"); assertThatThrownBy(() -> checkValid(parseMap(configMap))) .isInstanceOf(ConfigException.class); configMap.replace("list", ""); configMap.replace("mode", MovieHandler.Type.SET_RATING.toString()); checkValid(parseMap(configMap)); configMap.remove("list"); assertThatThrownBy(() -> checkValid(parseMap(configMap))) .isInstanceOf(ConfigException.class); }
@Test public void checkComparators() throws Exception { checkValid(parseMap(configMap)); configMap.replace("comparators", Arrays.asList( MovieComparator.Type.YEAR_EQUALS.toString(), MovieComparator.Type.TITLE_EQUALS.toString() )); checkValid(parseMap(configMap)); configMap.replace("comparators", Collections.singletonList("not existing comparator")); assertThatThrownBy(() -> checkValid(parseMap(configMap))) .isInstanceOf(ConfigException.class); configMap.remove("comparators"); assertThatThrownBy(() -> checkValid(parseMap(configMap))) .isInstanceOf(ConfigException.class); }
@Test public void testWithTextFile(TestContext tc) { Async async = tc.async(); retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore( new ConfigStoreOptions() .setType("file") .setFormat("hocon") .setConfig(new JsonObject().put("path", "src/test/resources/some-text.txt")))); retriever.getConfig(ar -> { assertThat(ar.failed()).isTrue(); assertThat(ar.cause()).isNotNull().isInstanceOf(ConfigException.class); async.complete(); }); }
/** * Returns a map view of the data associated with the specified key. If the key corresponds * to a string list, each element of the list will be mapped to itself. If the key corresponds * to a nested configuration, the map will contain those entries of the nested configuration which * have string values (but not, for example, further nested configurations). If the key * corresponds to some other type, throws an exception from the underlying typesafe config * implementation. * * @param config the configuration * @param key the key * @return a map view of the data associated with the specified key */ public static Map<String, String> getStringMap(Config config, String key) { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); try { for (String value : config.getStringList(key)) { builder.put(value, value); } } catch (ConfigException.WrongType e) { Config nestedConfig = config.getConfig(key); for (Map.Entry<String, ConfigValue> entry : nestedConfig.root().entrySet()) { String nestedKey = entry.getKey(); String quotelessKey = stripQuotes(nestedKey); try { builder.put(quotelessKey, nestedConfig.getString(nestedKey)); } catch (ConfigException.WrongType ignore) { LOG.warn("Ignoring non-string-valued key: '{}'", quotelessKey); } } } return builder.build(); }
@Override public <T extends SkillData> void loadSkillData(T skillData, SkillTree context, SkillLoadingErrors errors, Config c) { CharacterAttributeSkillData data = (CharacterAttributeSkillData) skillData; try { List<? extends Config> attributes = c.getConfigList("attributes"); for (Config subc : attributes) { String attribute = subc.getString("attribute"); int level = subc.getInt("skill-level"); int val = subc.getInt("attribute-value"); Wrapper wrapper = new Wrapper(NtRpgPlugin.GlobalScope.propertyService.getAttribute(attribute), level, val); if (wrapper.characterAttribute == null) { errors.log("Unknown attribute %s in %s", attribute, context.getId()); } else { data.wrappers.add(wrapper); } } } catch (ConfigException ex) { } }
@Override protected HoconTreeTraversingParser _createParser( Reader r, IOContext ctxt ) throws IOException { ConfigParseOptions options = ConfigParseOptions.defaults(); Config config = ConfigFactory.parseReader( r, options ); final Config unresolvedConfig = additinal .withFallback( config ) .withFallback( ConfigFactory.systemProperties() ); // log.trace( unresolvedConfig.root().render() ); try { Config resolvedConfig = unresolvedConfig.resolve(); return new HoconTreeTraversingParser( resolvedConfig.root(), _objectCodec ); } catch( ConfigException e ) { log.error( unresolvedConfig.root().render() ); throw e; } }
/** * Loads, parses, binds, and validates a configuration object. * * @param provider the provider to to use for reading configuration files * @param path the path of the configuration file * @return a validated configuration object * @throws IOException if there is an error reading the file * @throws ConfigurationException if there is an error parsing or validating the file */ public T build(ConfigurationSourceProvider provider, String path) throws IOException, ConfigurationException { try (InputStream input = provider.open(checkNotNull(path))) { final JsonNode node = mapper.readTree(hoconFactory.createParser(input)); return build(node, path); } catch (ConfigException e) { ConfigurationParsingException.Builder builder = ConfigurationParsingException .builder("Malformed HOCON") .setCause(e) .setDetail(e.getMessage()); ConfigOrigin origin = e.origin(); if (origin != null) { builder.setLocation(origin.lineNumber(), 0); } throw builder.build(path); } }
public Config getServer(String server) { try { return config.getConfig("servers").getConfig(server); } catch (ConfigException e) { String servers = config .getConfig("servers") .root() .entrySet() .stream() .map(i -> i.getKey()) .collect(java.util.stream.Collectors.joining(", ")); log.error("Invalid server '{}', available servers: {}", server, servers); throw e; } }
@Override public void preInit() { File configFile = new File(Minecraft.getMinecraft().mcDataDir, "config/farrago.conf"); if (!configFile.exists()) { saveDefaultConfig(configFile); } FarragoMod.config = ConfigFactory.parseFile(configFile); try { FarragoMod.brand = FarragoMod.config.getString("modpack.brand"); } catch (ConfigException.Null ex) { FarragoMod.brand = null; } FarragoMod.showBrand = FarragoMod.config.getBoolean("modpack.showBrand"); if (!FarragoMod.config.getBoolean("modified")) { saveDefaultConfig(configFile); FarragoMod.config = ConfigFactory.parseFile(configFile); } }
/** * Gets env base url based on the queried channel. * * @param channel the channel to query * @param secure whether to serve SSL protocol (if available for configured Environment) or not. * * @return the env base url (no trailing slash) */ public String getBaseUrl(Channels channel, boolean secure) { Config envConf = getEnvironmentConfiguration( getEnvironment() ); String protocol = secure ? envConf.getString( channel + ".protocol" ) : "http"; String host = getEnvHost( channel ); String port = ""; try { port = ":" + envConf.getString( channel + ".port" ); } catch ( ConfigException.Missing e ) { // Silent fail, default service port will be used } return protocol + "://" + host + port; }
@Override public void onReceive(Object msg) throws Exception { if(msg instanceof TransactionCreated) { log.debug("transaction created"); try { databaseScheme = databaseConfig.getString("scheme"); } catch(ConfigException.Missing cem) { databaseScheme = "SDE"; } log.debug("database scheme before calling get fetch table: " + databaseScheme); transaction = ((TransactionCreated)msg).getActor(); transaction.tell(SDEUtils.getFetchTable(SDEUtils.getItemsFilter(), databaseScheme), getSelf()); getContext().become(onReceiveStreaming()); } else if(msg instanceof ReceiveTimeout) { log.error("timeout received"); getContext().stop(getSelf()); } else { unhandled(msg); } }
private Config neo4j(final Config conf, final String db) { Config result = conf.hasPath("com.graphaware") ? ConfigFactory.empty().withValue("com.graphaware", conf.getConfig("com.graphaware").root()) : ConfigFactory.empty(); String[] paths = {"neo4j", db, "neo4j." + db }; for (String path : paths) { try { if (conf.hasPath(path)) { Config it = conf.getConfig(path); result = it.withFallback(result); } } catch (ConfigException x) { // Skip/ignore bad path } } return result; }
private void tryOption(final Object source, final Config config, final Method option) { Try.run(() -> { String optionName = option.getName().replace("set", ""); Object optionValue = config.getAnyRef(optionName); Class<?> optionType = Primitives.wrap(option.getParameterTypes()[0]); if (Number.class.isAssignableFrom(optionType) && optionValue instanceof String) { // either a byte or time unit try { optionValue = config.getBytes(optionName); } catch (ConfigException.BadValue ex) { optionValue = config.getDuration(optionName, TimeUnit.MILLISECONDS); } if (optionType == Integer.class) { // to int optionValue = ((Number) optionValue).intValue(); } } log.debug("{}.{}({})", source.getClass().getSimpleName(), option.getName(), optionValue); option.invoke(source, optionValue); }).unwrap(InvocationTargetException.class) .throwException(); }
@Test public void shouldBuildIntervalJob() throws Exception { new MockUnit(Config.class) .expect(unit -> { Config config = unit.get(Config.class); expect(config.getString("5s")).andThrow(new ConfigException.BadPath("5s", "5s")); }) .run(unit -> { Entry<JobDetail, Trigger> entry = JobExpander .jobs(unit.get(Config.class), Arrays.asList(IntervalJob.class)).entrySet() .iterator().next(); JobDetail job = entry.getKey(); assertEquals(ReflectiveJob.class, job.getJobClass()); assertEquals(IntervalJob.class.getPackage().getName(), job.getKey().getGroup()); assertEquals("JobBeanExpanderTest$IntervalJob.runAt", job.getKey().getName()); SimpleTrigger trigger = (SimpleTrigger) entry.getValue(); assertEquals(5000L, trigger.getRepeatInterval()); assertEquals(IntervalJob.class.getPackage().getName(), trigger.getKey().getGroup()); assertEquals("JobBeanExpanderTest$IntervalJob.runAt", trigger.getKey().getName()); }); }
@Test public void shouldBuildCronJob() throws Exception { new MockUnit(Config.class) .expect( unit -> { Config config = unit.get(Config.class); expect(config.getString("0/3 * * * * ?")).andThrow( new ConfigException.BadPath("0/3 * * * * ?", "0/3 * * * * ?")); }) .run(unit -> { Entry<JobDetail, Trigger> entry = JobExpander .jobs(unit.get(Config.class), Arrays.asList(CronJob.class)).entrySet() .iterator().next(); JobDetail job = entry.getKey(); assertEquals(ReflectiveJob.class, job.getJobClass()); assertEquals(CronJob.class.getPackage().getName(), job.getKey().getGroup()); assertEquals("JobBeanExpanderTest$CronJob.doWork", job.getKey().getName()); CronTrigger trigger = (CronTrigger) entry.getValue(); assertEquals("0/3 * * * * ?", trigger.getCronExpression()); assertEquals(CronJob.class.getPackage().getName(), trigger.getKey().getGroup()); assertEquals("JobBeanExpanderTest$CronJob.doWork", trigger.getKey().getName()); }); }
@Test(expected = IllegalArgumentException.class) public void shouldBuildIntervalJobUnknownAttribute() throws Exception { long date = 1429984623207L; new MockUnit(Config.class) .expect(unit -> { Config config = unit.get(Config.class); expect(config.getString("5s; x= 1")).andThrow(new ConfigException.BadPath("5s", "5s")); }) .expect(unit -> { unit.mockStatic(System.class); expect(System.currentTimeMillis()).andReturn(date); }) .run(unit -> { Entry<JobDetail, Trigger> entry = JobExpander .jobs(unit.get(Config.class), Arrays.asList(IntervalJobUnknownAttribute.class)) .entrySet() .iterator().next(); SimpleTrigger trigger = (SimpleTrigger) entry.getValue(); assertEquals(5000L, trigger.getRepeatInterval()); assertEquals(new Date(date), trigger.getStartTime()); assertEquals(-1, trigger.getRepeatCount()); }); }
@Test public void shouldBuildCronJob() throws Exception { new MockUnit(Config.class) .expect( unit -> { Config config = unit.get(Config.class); expect(config.getString("0/3 * * * * ?")).andThrow( new ConfigException.BadPath("0/3 * * * * ?", "0/3 * * * * ?")); }) .run(unit -> { Entry<JobDetail, Trigger> entry = JobExpander .jobs(unit.get(Config.class), Arrays.asList(CronJob.class)).entrySet() .iterator().next(); JobDetail job = entry.getKey(); assertEquals(CronJob.class, job.getJobClass()); assertEquals(CronJob.class.getPackage().getName(), job.getKey().getGroup()); assertEquals(CronJob.class.getSimpleName(), job.getKey().getName()); CronTrigger trigger = (CronTrigger) entry.getValue(); assertEquals("0/3 * * * * ?", trigger.getCronExpression()); assertEquals(CronJob.class.getPackage().getName(), trigger.getKey().getGroup()); assertEquals(CronJob.class.getSimpleName(), trigger.getKey().getName()); }); }
/** * Instantiate an object without a compile time expected type. This expects a config of the * form "{plugin-category: {...}}". ie. there should be exactly one top level key and that * key should be a valid, loaded, plug-in category. */ public <T> T decodeObject(Config config) throws JsonProcessingException, IOException { if (config.root().size() != 1) { throw new ConfigException.Parse(config.root().origin(), "config root must have exactly one key"); } String category = config.root().keySet().iterator().next(); PluginMap pluginMap = pluginRegistry.asMap().get(category); if (pluginMap == null) { throw new ConfigException.BadValue(config.root().get(category).origin(), category, "top level key must be a valid category"); } ConfigValue configValue = config.root().get(category); return (T) decodeObject(pluginMap.baseClass(), configValue); }
public static void main(String[] args) { try { final Config config = ConfigFactory.load().getConfig("billow"); try { System.setProperty("aws.accessKeyId", config.getString("aws.accessKeyId")); System.setProperty("aws.secretKey", config.getString("aws.secretKeyId")); } catch (ConfigException.Missing _) { System.clearProperty("aws.accessKeyId"); System.clearProperty("aws.secretKey"); } Main.log.debug("Loaded config: {}", config); new Main(config); } catch (Throwable t) { Main.log.error("Failure in main thread, getting out!", t); System.exit(1); } }
@Test public void testIsTrue() throws Exception { System.setProperty("MY_VARIABLE", "true"); morphline = createMorphline("test-morphlines/isTrue"); Record record = new Record(); record.put("isTooYoung", "true"); processAndVerifySuccess(record, record); System.setProperty("MY_VARIABLE", "false"); morphline = createMorphline("test-morphlines/isTrue"); processAndVerifyFailure(createBasicRecord()); System.clearProperty("MY_VARIABLE"); try { morphline = createMorphline("test-morphlines/isTrue"); fail(); } catch (ConfigException.UnresolvedSubstitution e) { ; } }
private Set<Entry<String, ConfigValue>> buildProperties(BeanDefinitionBuilder beanDefinition) { Set<String> paths = beanDefinitions.keySet(); Set<Entry<String, ConfigValue>> entries = new HashSet<>(); try { for (Entry<String, ConfigValue> entry : config.getConfig(path).root().entrySet()) { String fullPath = path.concat(".").concat(entry.getKey()); if (paths.contains(fullPath)) { beanDefinition.addPropertyReference(entry.getKey(), beanDefinitions.get(fullPath).getId()); } else { entries.add(entry); } } } catch (ConfigException.Missing e) { this.log.debug(format("No configuration found on path %s", path)); } return entries; }
/** * Retrieves the values as a list of String, the format is: key=[myval1,myval2]. * * @param key the key the key used in the configuration file. * @return an list containing the values of that key or empty if not found. */ @Override public List<String> getList(final String key) { return retrieve(new Callable<List<String>>() { @Override public List<String> call() throws Exception { try { return configuration.getStringList(key); } catch (ConfigException.WrongType e) { // Not a list. String s = get(key); if (s != null) { return ImmutableList.of(s); } else { throw new IllegalArgumentException("Cannot create a list for the key '" + key + "'", e); } } } }, Collections.<String>emptyList()); }
private static Config parseConfig(@NotNull final String jsonConfig) throws ValidationException { try { return ConfigFactory.parseString(jsonConfig, Constants.CONFIG_PARSE_OPTIONS); } catch (ConfigException e) { throw ValidationException.create("Configuration error", e); } }
private static Config parseClusterConfig(@NotNull final String jsonConfig) throws ValidationException { try { return ConfigFactory.parseString(jsonConfig, Constants.CONFIG_PARSE_OPTIONS); } catch (ConfigException e) { throw ValidationException.create("Cluster configuration error for " + jsonConfig, e); } }
@Inject public ConfigurationRegistry(Config config, Map<String, InputConfiguration.Factory<? extends InputConfiguration>> inputConfigs, Map<String, OutputConfiguration.Factory<? extends OutputConfiguration>> outputConfigs) { this.inputConfigFactories = inputConfigs; this.outputConfigFactories = outputConfigs; this.validator = new ConfigurationValidator(); try { processConfig(config); } catch (ConfigException e) { errors.add(new ConfigurationError(e.getMessage())); } }
private static Set<Map.Entry<String, ConfigValue>> nullValues(ConfigObject config) { Set<Map.Entry<String, ConfigValue>> result = new HashSet<>(); for (Map.Entry<String, ConfigValue> entry : config.entrySet()) { try { if (entry.getValue().valueType() == ConfigValueType.NULL) { result.add(entry); } else if (entry.getValue().valueType() == ConfigValueType.OBJECT) { result.addAll(nullValues((ConfigObject) entry.getValue())); } } catch (ConfigException.NotResolved e) { // unresolved substitutions are handled elsewhere, here we just ignore them } } return result; }
@Override public void setup(final FragmentContext context, final BufferAllocator allocator, final SelectionVector4 vector4, final VectorContainer hyperBatch) throws SchemaChangeException{ // we pass in the local hyperBatch since that is where we'll be reading data. Preconditions.checkNotNull(vector4); this.vector4 = vector4.createNewWrapperCurrent(); this.context = context; vector4.clear(); doSetup(context, hyperBatch, null); runStarts.add(0); int batch = 0; final int totalCount = this.vector4.getTotalCount(); for (int i = 0; i < totalCount; i++) { final int newBatch = this.vector4.get(i) >>> 16; if (newBatch == batch) { continue; } else if (newBatch == batch + 1) { runStarts.add(i); batch = newBatch; } else { throw new UnsupportedOperationException("Missing batch"); } } final DrillBuf drillBuf = allocator.buffer(4 * totalCount); try { desiredRecordBatchCount = context.getConfig().getInt(ExecConstants.EXTERNAL_SORT_MSORT_MAX_BATCHSIZE); } catch(ConfigException.Missing e) { // value not found, use default value instead desiredRecordBatchCount = Character.MAX_VALUE; } aux = new SelectionVector4(drillBuf, totalCount, desiredRecordBatchCount); }
@SuppressWarnings("unchecked") public PStoreProvider newPStoreProvider() throws ExecutionSetupException { try { String storeProviderClassName = config.getString(ExecConstants.SYS_STORE_PROVIDER_CLASS); logger.info("Using the configured PStoreProvider class: '{}'.", storeProviderClassName); Class<? extends PStoreProvider> storeProviderClass = (Class<? extends PStoreProvider>) Class.forName(storeProviderClassName); Constructor<? extends PStoreProvider> c = storeProviderClass.getConstructor(PStoreRegistry.class); return new CachingStoreProvider(c.newInstance(this)); } catch (ConfigException.Missing | ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { logger.error(e.getMessage(), e); throw new ExecutionSetupException("A System Table provider was either not specified or could not be found or instantiated", e); } }
public static String getConfString(String key) { log.debug("getConfString(" + key + ")"); String confString = ""; try { confString = conf.getString(key); } catch(ConfigException.Missing cfeMissing) { log.error("Ignoring: " + cfeMissing.toString()); } return confString; }