List of usage examples for org.apache.commons.configuration Configuration subset
Configuration subset(String prefix);
From source file:ai.grakn.graql.internal.analytics.CommonOLAP.java
/** * Store <code>persistentProperties</code> and any hard coded fields in an apache config object for propagation to * spark executors.//from ww w . ja v a2 s.co m * * @param configuration the apache config object that will be propagated */ public void storeState(final Configuration configuration) { // clear properties from vertex program Set<String> oldKeys = new HashSet<>(); configuration.subset(PREFIX_SELECTED_TYPE_KEY).getKeys() .forEachRemaining(key -> oldKeys.add(PREFIX_SELECTED_TYPE_KEY + "." + key)); oldKeys.forEach(configuration::clearProperty); // store selectedTypes selectedTypes.forEach(typeId -> configuration.addProperty(PREFIX_SELECTED_TYPE_KEY + "." + typeId, typeId)); // store user specified properties persistentProperties.forEach( (key, value) -> configuration.addProperty(PREFIX_PERSISTENT_PROPERTIES + "." + key, value)); }
From source file:com.github.anba.test262.BaseTest262.java
protected BaseTest262(Configuration configuration, String testsuite, String sourceName, String path) { Configuration c = configuration.subset(testsuite); this.testsuite = testsuite; this.sourceName = sourceName; this.path = path; this.strictSupported = c.getBoolean("strict", false); this.encoding = c.getString("encoding", "UTF-8"); }
From source file:com.linkedin.pinot.transport.config.ConnectionPoolConfig.java
public void init(Configuration cfg) { if (cfg.containsKey(THREAD_POOL_KEY)) { _threadPool.init(cfg.subset(THREAD_POOL_KEY)); }//from w w w.j ava 2 s . c o m if (cfg.containsKey(IDLE_TIMEOUT_MS_KEY)) { _idleTimeoutMs = cfg.getLong(IDLE_TIMEOUT_MS_KEY); } if (cfg.containsKey(MIN_CONNECTIONS_PER_SERVER_KEY)) { _minConnectionsPerServer = cfg.getInt(MIN_CONNECTIONS_PER_SERVER_KEY); } if (cfg.containsKey(MAX_CONNECTIONS_PER_SERVER_KEY)) { _maxConnectionsPerServer = cfg.getInt(MAX_CONNECTIONS_PER_SERVER_KEY); } if (cfg.containsKey(MAX_BACKLOG_PER_SERVER_KEY)) { _maxBacklogPerServer = cfg.getInt(MAX_BACKLOG_PER_SERVER_KEY); } if (_minConnectionsPerServer > _maxConnectionsPerServer || _maxConnectionsPerServer <= 0 || _minConnectionsPerServer < 1) { LOGGER.warn( "Invalid values for " + MIN_CONNECTIONS_PER_SERVER_KEY + "({}) and " + MAX_CONNECTIONS_PER_SERVER_KEY + "({}). Resetting to defaults:", _minConnectionsPerServer, _maxConnectionsPerServer); _minConnectionsPerServer = DEFAULT_MIN_CONNECTIONS_PER_SERVER; _maxConnectionsPerServer = DEFAULT_MAX_CONNECTIONS_PER_SERVER; } if (_idleTimeoutMs < 0) { LOGGER.warn("Invalid value for " + IDLE_TIMEOUT_MS_KEY + "({}). Resetting to default."); _idleTimeoutMs = DEFAULT_IDLE_TIMEOUT_MS; } if (_maxBacklogPerServer < 0) { LOGGER.warn("Invalid value for " + MAX_BACKLOG_PER_SERVER_KEY + "({}). Resetting to default."); _maxBacklogPerServer = DEFAULT_MAX_BACKLOG_PER_SERVER; } LOGGER.info(toString()); }
From source file:com.opensoc.tagging.TelemetryTaggerBolt.java
/** * @param config/* w ww. j a va2 s. c o m*/ * A class for generating custom metrics into graphite * @return Instance of this class */ public TelemetryTaggerBolt withMetricConfiguration(Configuration config) { this.metricConfiguration = JSONEncoderHelper.getJSON(config.subset("com.opensoc.metrics")); return this; }
From source file:com.comcast.viper.flume2storm.location.DynamicLocationServiceFactory.java
/** * @see com.comcast.viper.flume2storm.location.LocationServiceFactory#create(org.apache.commons.configuration.Configuration, * com.comcast.viper.flume2storm.location.ServiceProviderSerialization) *//*from w w w.j a va 2s . co m*/ @Override public LocationService<SP> create(Configuration config, ServiceProviderSerialization<SP> serviceProviderSerialization) throws F2SConfigurationException { return new DynamicLocationService<SP>( DynamicLocationServiceConfiguration.from(config.subset(CONFIG_BASE_NAME)), serviceProviderSerialization); }
From source file:com.opensoc.parsing.TelemetryParserBolt.java
/** * @param config//from w w w . j a va 2 s . co m * A class for generating custom metrics into graphite * @return Instance of this class */ public TelemetryParserBolt withMetricConfig(Configuration config) { this.metricConfiguration = JSONEncoderHelper.getJSON(config.subset("com.opensoc.metrics")); return this; }
From source file:es.udc.gii.common.eaf.plugin.parameter.LogAnnealing.java
@Override public void configure(Configuration conf) { try {/* ww w . jav a 2s . c om*/ if (conf.containsKey("Counter.Class")) { this.counter = (StopTestPlugin) Class.forName(conf.getString("Counter.Class")).newInstance(); this.counter.configure(conf.subset("Counter")); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.boozallen.cognition.ingest.storm.bolt.starter.CsvHdfsBolt.java
void configureHadoop(Configuration conf) throws ConfigurationException { hadoopConfDirectory = conf.getString(HADOOP_CONF_DIRECTORY); Configuration hadoopConfigSubset = conf.subset(HADOOP_CONFIG); for (Iterator itr = hadoopConfigSubset.getKeys(); itr.hasNext();) { String key = (String) itr.next(); String value = hadoopConfigSubset.getString(key); _hadoopConfig.put(key, value);/*from w w w . j a v a2s . c o m*/ } if (isBlank(hadoopConfDirectory) && _hadoopConfig.isEmpty()) { throw new ConfigurationException( String.format("Missing Hadoop configuration. Configure with either %s or %s.", HADOOP_CONFIG, HADOOP_CONF_DIRECTORY)); } }
From source file:com.rapid7.diskstorage.dynamodb.TestGraphUtil.java
public Configuration createTestGraphConfig(BackendDataModel backendDataModel) { String dataModelName = backendDataModel.name(); final Configuration properties = loadProperties(); final Configuration dynamodb = properties.subset("storage").subset("dynamodb"); dynamodb.setProperty("prefix", dataModelName); dynamodb.setProperty("control-plane-rate", controlPlaneRate); final Configuration stores = dynamodb.subset("stores"); final int tps = getTps(); for (String store : Constants.REQUIRED_BACKEND_STORES) { final Configuration storeNs = stores.subset(store); configureStore(dataModelName, tps, storeNs, unlimitedIops); }//from w w w . j a v a2s. com return properties; }
From source file:com.linkedin.pinot.common.metrics.MetricsHelperTest.java
@Test public void testMetricsHelperRegistration() { listenerOneOkay = false;//from w w w . ja v a 2s . c o m listenerTwoOkay = false; Map<String, String> configKeys = new HashMap<String, String>(); configKeys.put("pinot.broker.metrics.metricsRegistryRegistrationListeners", ListenerOne.class.getName() + "," + ListenerTwo.class.getName()); Configuration configuration = new MapConfiguration(configKeys); MetricsRegistry registry = new MetricsRegistry(); // Initialize the MetricsHelper and create a new timer MetricsHelper.initializeMetrics(configuration.subset("pinot.broker.metrics")); MetricsHelper.registerMetricsRegistry(registry); MetricsHelper.newTimer(registry, new MetricName(MetricsHelperTest.class, "dummy"), TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS); // Check that the two listeners fired assertTrue(listenerOneOkay); assertTrue(listenerTwoOkay); }