Example usage for org.apache.commons.configuration Configuration subset

List of usage examples for org.apache.commons.configuration Configuration subset

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration subset.

Prototype

Configuration subset(String prefix);

Source Link

Document

Return a decorator Configuration containing every key from the current Configuration that starts with the specified prefix.

Usage

From source file:com.amazon.janusgraph.TestGraphUtil.java

private Configuration createTestConfig(final BackendDataModel backendDataModel) {
    final Configuration properties = loadProperties();
    final Configuration dynamodb = properties.subset("storage").subset("dynamodb");
    dynamodb.setProperty(Constants.DYNAMODB_TABLE_PREFIX.getName(), backendDataModel.name() /*prefix*/);
    dynamodb.setProperty(Constants.DYNAMODB_CONTROL_PLANE_RATE.getName(), controlPlaneRate);
    return properties;
}

From source file:com.opensoc.indexing.TelemetryIndexingBolt.java

/**
 * /*w  w w .j  a v  a  2 s .c  o  m*/
 * @param config
 *            - configuration for pushing metrics into graphite
 * @return instance of bolt
 */
public TelemetryIndexingBolt withMetricConfiguration(Configuration config) {
    this.metricConfiguration = JSONEncoderHelper.getJSON(config.subset("com.opensoc.metrics"));
    return this;
}

From source file:com.opensoc.alerts.TelemetryAlertsBolt.java

/**
 * @param config/* w  ww.  j  av a2  s .  c o m*/
 *            A class for generating custom metrics into graphite
 * @return Instance of this class
 */

public TelemetryAlertsBolt withMetricConfiguration(Configuration config) {
    this.metricConfiguration = JSONEncoderHelper.getJSON(config.subset("com.opensoc.metrics"));
    return this;
}

From source file:com.kixeye.chassis.support.eureka.MetadataCollector.java

/**
 * Get metadata from configuration data that does not change.
 *
 * @return Map of static meta data//from   w w  w .ja v  a 2s. c  o  m
 */
public Map<String, String> getStaticMetadataMap() {
    if (staticMetaDataCache == null) {
        // add eureka.metadata.* properties
        staticMetaDataCache = new LinkedHashMap<>();
        Configuration config = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource();
        for (Iterator<String> iter = config.subset("eureka.metadata").getKeys(); iter.hasNext();) {
            String key = iter.next();
            String value = config.getString("eureka.metadata." + key);
            staticMetaDataCache.put(key, value);
        }

        // add WebSocket port to meta data if available
        if (DynamicPropertyFactory.getInstance().getBooleanProperty("websocket.enabled", false).get()) {
            int port = DynamicPropertyFactory.getInstance().getIntProperty("websocket.port", -1).get();
            if (port > 0) {
                staticMetaDataCache.put("websocketPort", "" + port);
            }
        }

        // add secure WebSocket port to meta data if available
        if (DynamicPropertyFactory.getInstance().getBooleanProperty("secureWebsocket.enabled", false).get()) {
            int port = DynamicPropertyFactory.getInstance().getIntProperty("secureWebsocket.port", -1).get();
            if (port > 0) {
                staticMetaDataCache.put("secureWebsocketPort", "" + port);
            }
        }
    }
    return staticMetaDataCache;
}

From source file:com.rapid7.diskstorage.dynamodb.TestGraphUtil.java

public CommonsConfiguration getWriteConfiguration(BackendDataModel model, List<String> extraStoreNames,
        int partitions) {
    Preconditions.checkArgument(partitions > 0);
    Configuration config = TestGraphUtil.instance().createTestGraphConfig(model);
    Configuration cache = config.subset("cache");
    if (model == BackendDataModel.SINGLE) { //TODO refactor
        //default: 20000, testEdgesExceedCacheSize fails at 16792, passes at 16791
        //this is the maximum number of edges supported for a vertex with no vertex partitioning.
        cache.setProperty("tx-cache-size", 16791);
    }/*from   w  w w  . j  a  v a2s  .  c o m*/
    //necessary for simpleLogTest, simpleLogTestWithFailure
    for (String extraStoreName : extraStoreNames) {
        final int tps = TestGraphUtil.instance().getTps();
        final Configuration stores = config.subset("storage").subset("dynamodb").subset("stores");
        final Configuration ulog_test = stores.subset(extraStoreName);
        TestGraphUtil.configureStore(model.name(), tps, ulog_test, TestGraphUtil.instance().isUnlimitedIops());
    }
    if (partitions > 1) {
        final Configuration cluster = config.subset("cluster");
        cluster.addProperty("partition", "true");
        cluster.addProperty("max-partitions", Integer.toString(partitions));
    }
    CommonsConfiguration cc = new CommonsConfiguration(config);
    return cc;
}

From source file:es.udc.gii.common.eaf.algorithm.operator.reproduction.mutation.de.crossover.CrossOverScheme.java

@Override
public void configure(Configuration conf) {

    try {// w ww .  java2 s  .c om
        if (conf.containsKey("CR.Class")) {
            this.CR_plugin = (Parameter) Class.forName(conf.getString("CR.Class")).newInstance();
            this.CR_plugin.configure(conf.subset("CR"));
        }

    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
        throw new ConfigurationException(this.getClass(), ex);
    }
}

From source file:com.opensoc.enrichment.common.GenericEnrichmentBolt.java

/**
 * @param config/*from   w  w w . j a  v a2s.c  o  m*/
 *            A class for generating custom metrics into graphite
 * @return Instance of this class
 */

public GenericEnrichmentBolt withMetricConfiguration(Configuration config) {
    this.metricConfiguration = JSONEncoderHelper.getJSON(config.subset("com.opensoc.metrics"));
    return this;
}

From source file:com.linkedin.pinot.transport.conf.TransportClientConf.java

public void init(Configuration cfg) throws ConfigurationException {
    if (cfg.containsKey(ROUTING_MODE_KEY)) {
        _routingMode = RoutingMode.valueOf(cfg.getString(ROUTING_MODE_KEY));
    }/*from  w ww  .jav a2 s  .co m*/
    if ((_routingMode == RoutingMode.CONFIG)) {
        _cfgBasedRouting.init(cfg.subset(CFG_BASED_ROUTING));
    }

    Configuration connPoolCfg = cfg.subset(CONNECTION_POOL_CONFIG);
    if (connPoolCfg != null) {
        _connPool.init(connPoolCfg);
    }
}

From source file:grakn.core.graql.analytics.MedianVertexProgram.java

@Override
public void loadState(final Graph graph, final Configuration configuration) {
    super.loadState(graph, configuration);
    configuration.subset(RESOURCE_TYPE).getKeys().forEachRemaining(key -> statisticsResourceLabelIds
            .add((LabelId) configuration.getProperty(RESOURCE_TYPE + "." + key)));
}

From source file:ai.grakn.graql.internal.analytics.MedianVertexProgram.java

@Override
public void loadState(final Graph graph, final Configuration configuration) {
    super.loadState(graph, configuration);
    configuration.subset(RESOURCE_TYPE).getKeys().forEachRemaining(
            key -> statisticsResourceTypeIds.add(TypeId.of(configuration.getInt(RESOURCE_TYPE + "." + key))));

    degreePropertyKey = (String) this.persistentProperties.get(DegreeVertexProgram.DEGREE);
    labelKey = (String) this.persistentProperties.get(LABEL);
}