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

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

Introduction

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

Prototype

void setProperty(String key, Object value);

Source Link

Document

Set a property, this will replace any previously set values.

Usage

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

@Override
public void storeState(final Configuration configuration) {
    super.storeState(configuration);

    // store class name for reflection on spark executor
    configuration.setProperty(MAP_REDUCE, this.getClass().getName());
}

From source file:com.wizecommerce.hecuba.hector.HectorConsistencyPolicyTest.java

private void checkOperationConfigurationLoading(Configuration configuration, String operationProperty,
        OperationType operationType) {//from w w w .j av  a  2  s.  c om
    HectorConsistencyPolicy policy;
    for (HConsistencyLevel consistencyLevel : HConsistencyLevel.values()) {
        configuration.setProperty(operationProperty, consistencyLevel.toString());
        policy = new HectorConsistencyPolicy("NoCF");
        assertEquals("Error handling consistency level " + consistencyLevel.toString()
                + " within HectorConsistencyPolicy.", consistencyLevel, policy.get(operationType));
    }
}

From source file:io.fluo.core.impl.AppConfigIT.java

@Test
public void testBasic() {
    Configuration uc = client.getAppConfiguration();
    Assert.assertEquals(50000, uc.getInt("myapp.sizeLimit"));
    uc.setProperty("myapp.sizeLimit", 3);
    uc = client.getAppConfiguration();// ww  w .j  ava  2 s  . c  o  m
    Assert.assertEquals(50000, uc.getInt("myapp.sizeLimit"));

    //update shared config
    Configuration appConfig = config.getAppConfiguration();
    appConfig.clear();
    appConfig.setProperty("myapp.sizeLimit", 40000);
    appConfig.setProperty("myapp.timeLimit", 30000);
    try (FluoAdmin admin = FluoFactory.newAdmin(config)) {
        admin.updateSharedConfig();
    }

    //set app config that differs from what was just put in zk
    appConfig.setProperty("myapp.sizeLimit", 6);
    appConfig.setProperty("myapp.timeLimit", 7);

    try (FluoClient client2 = FluoFactory.newClient(config)) {
        uc = client2.getAppConfiguration();
        Assert.assertEquals(40000, uc.getInt("myapp.sizeLimit"));
        Assert.assertEquals(30000, uc.getInt("myapp.timeLimit"));
    }

}

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  .c  o m

    return properties;
}

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:co.turnus.analysis.buffers.BoundedBufferScheduling.java

public BoundedBufferScheduling(TraceProject traceProject) {
    // unload trace if loaded and not sensitive to token dependencies
    if (traceProject.isTraceLoaded()) {
        if (!traceProject.getTrace().isSensitive(Kind.TOKENS)) {
            traceProject.unloadTrace();/*from  w  w  w  . j  a  v a 2s . c  o m*/
        }
    }

    if (!traceProject.isTraceLoaded()) {
        Configuration config = new BaseConfiguration();
        config.setProperty(SENS_FSM, false);
        config.setProperty(SENS_GUARD, false);
        config.setProperty(SENS_PORT, false);
        config.setProperty(SENS_STATEVAR, false);
        config.setProperty(SENS_TOKENS, true);
        traceProject.loadTrace(config);
    }

    this.traceProject = traceProject;
}

From source file:cz.cas.lib.proarc.common.process.GenericExternalProcessTest.java

@Test
public void testGetResultParameters() throws Exception {
    File confFile = temp.newFile("props.cfg");
    FileUtils.writeLines(confFile,/* w  ww .  j  av a  2s .  com*/
            Arrays.asList("processor.test.param.mime=image/jpeg", "processor.test.onExits=0, >10, 2\\,3, *",
                    "processor.test.onExit.0.param.file=ERR_0\\:$${input.file.name}",
                    "processor.test.onExit.>10.param.file=ERR_>10\\:$${input.file.name}",
                    "processor.test.onExit.>10.stop=false",
                    "processor.test.onExit.2,3.param.file=ERR_2\\,3\\:$${input.file.name}",
                    "processor.test.onExit.*.param.file=ERR_*\\:$${input.file.name}",
                    "processor.test.onSkip.param.file=SKIPPED\\:$${input.file.name}"));
    PropertiesConfiguration pconf = new PropertiesConfiguration(confFile);
    String processorId = "processor.test";
    Configuration conf = pconf.subset(processorId);
    conf.setProperty("id", processorId);
    GenericExternalProcess gep = new GenericExternalProcess(conf);
    gep.addInputFile(confFile);
    ProcessResult result = ProcessResult.getResultParameters(conf, gep.getParameters().getMap(), false, 0,
            null);
    assertEquals("image/jpeg", result.getParameters().get(processorId + ".param.mime"));
    assertEquals("ERR_0:props", result.getParameters().get(processorId + ".param.file"));
    assertEquals(Integer.valueOf(0), result.getExit().getExitCode());
    assertFalse(result.getExit().isStop());
    assertFalse(result.getExit().isSkip());

    result = ProcessResult.getResultParameters(conf, gep.getParameters().getMap(), false, 3, null);
    assertEquals("image/jpeg", result.getParameters().get(processorId + ".param.mime"));
    assertEquals("ERR_2,3:props", result.getParameters().get(processorId + ".param.file"));
    assertEquals(Integer.valueOf(3), result.getExit().getExitCode());
    assertTrue(result.getExit().isStop());
    assertFalse(result.getExit().isSkip());

    result = ProcessResult.getResultParameters(conf, gep.getParameters().getMap(), false, 11, null);
    assertEquals("image/jpeg", result.getParameters().get(processorId + ".param.mime"));
    assertEquals("ERR_>10:props", result.getParameters().get(processorId + ".param.file"));
    assertEquals(Integer.valueOf(11), result.getExit().getExitCode());
    assertFalse(result.getExit().isStop());
    assertFalse(result.getExit().isSkip());

    result = ProcessResult.getResultParameters(conf, gep.getParameters().getMap(), false, -1, null);
    assertEquals("image/jpeg", result.getParameters().get(processorId + ".param.mime"));
    assertEquals("ERR_*:props", result.getParameters().get(processorId + ".param.file"));
    assertEquals(Integer.valueOf(-1), result.getExit().getExitCode());
    assertTrue(result.getExit().isStop());
    assertFalse(result.getExit().isSkip());

    result = ProcessResult.getResultParameters(conf, gep.getParameters().getMap(), true, 0, null);
    assertEquals("image/jpeg", result.getParameters().get(processorId + ".param.mime"));
    assertEquals("SKIPPED:props", result.getParameters().get(processorId + ".param.file"));
    assertFalse(result.getExit().isStop());
    assertTrue(result.getExit().isSkip());
}

From source file:io.wcm.caravan.io.http.impl.ResilientHttpServiceConfig.java

/**
 * Writes OSGi configuration to archaius configuration.
 * @param serviceName Service name//from   w w w  . ja v  a  2  s  .  co  m
 * @param config OSGi config
 */
private void setArchiausProperties(String serviceName, Map<String, Object> config) {
    Configuration archaiusConfig = ArchaiusConfig.getConfiguration();

    // ribbon parameters
    archaiusConfig.setProperty(serviceName + RIBBON_PARAM_LISTOFSERVERS, StringUtils
            .join(PropertiesUtil.toStringArray(config.get(RIBBON_HOSTS_PROPERTY), new String[0]), ","));
    archaiusConfig.setProperty(serviceName + RIBBON_PARAM_MAXAUTORETRIES, PropertiesUtil
            .toInteger(config.get(RIBBON_MAXAUTORETRIES_PROPERTY), RIBBON_MAXAUTORETRIES_DEFAULT));
    archaiusConfig.setProperty(serviceName + RIBBON_PARAM_MAXAUTORETRIESONSERVER, PropertiesUtil.toInteger(
            config.get(RIBBON_MAXAUTORETRIESONSERVER_PROPERTY), RIBBON_MAXAUTORETRIESONSERVER_DEFAULT));
    archaiusConfig.setProperty(serviceName + RIBBON_PARAM_OKTORETRYONALLOPERATIONS, "true");

    // hystrix parameters

    // make sure to set a queue size big enough so requests won't be immediately rejected while pre-caching.
    // TODO: make this configurable per server and/or investigate why this requests failed immediately with ExecutionIsolationStrategy.SEMAPHORE
    archaiusConfig.setProperty("hystrix.threadpool.default.queueSizeRejectionThreshold", 4096);
    archaiusConfig.setProperty("hystrix.threadpool.default.maxQueueSize", 4096);

    archaiusConfig.setProperty(HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_TIMEOUT_MS,
            PropertiesUtil.toInteger(config.get(HYSTRIX_TIMEOUT_MS_PROPERTY), HYSTRIX_TIMEOUT_MS_DEFAULT));
    archaiusConfig.setProperty(HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_FALLBACK_ENABLED,
            PropertiesUtil.toBoolean(config.get(HYSTRIX_FALLBACK_ENABLED_PROPERTY),
                    HYSTRIX_FALLBACK_ENABLED_DEFAULT));
    archaiusConfig.setProperty(HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_CIRCUITBREAKER_ENABLED,
            PropertiesUtil.toBoolean(config.get(HYSTRIX_CIRCUITBREAKER_ENABLED_PROPERTY),
                    HYSTRIX_CIRCUITBREAKER_ENABLED_DEFAULT));
    archaiusConfig.setProperty(
            HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_CIRCUITBREAKER_REQUESTVOLUMETHRESHOLD,
            PropertiesUtil.toInteger(config.get(HYSTRIX_CIRCUITBREAKER_REQUESTVOLUMETHRESHOLD_PROPERTY),
                    HYSTRIX_CIRCUITBREAKER_REQUESTVOLUMETHRESHOLD_DEFAULT));
    archaiusConfig.setProperty(
            HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_CIRCUITBREAKER_SLEEPWINDOW_MS,
            PropertiesUtil.toInteger(config.get(HYSTRIX_CIRCUITBREAKER_SLEEPWINDOW_MS_PROPERTY),
                    HYSTRIX_CIRCUITBREAKER_SLEEPWINDOW_MS_DEFAULT));
    archaiusConfig.setProperty(
            HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_CIRCUITBREAKER_ERRORTHRESHOLDPERCENTAGE,
            PropertiesUtil.toInteger(config.get(HYSTRIX_CIRCUITBREAKER_ERRORTHRESHOLDPERCENTAGE_PROPERTY),
                    HYSTRIX_CIRCUITBREAKER_ERRORTHRESHOLDPERCENTAGE_DEFAULT));
    archaiusConfig.setProperty(HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_CIRCUITBREAKER_FORCEOPEN,
            PropertiesUtil.toBoolean(config.get(HYSTRIX_CIRCUITBREAKER_FORCEOPEN_PROPERTY),
                    HYSTRIX_CIRCUITBREAKER_FORCEOPEN_DEFAULT));
    archaiusConfig.setProperty(HYSTRIX_COMMAND_PREFIX + serviceName + HYSTRIX_PARAM_CIRCUITBREAKER_FORCECLOSED,
            PropertiesUtil.toBoolean(config.get(HYSTRIX_CIRCUITBREAKER_FORCECLOSED_PROPERTY),
                    HYSTRIX_CIRCUITBREAKER_FORCECLOSED_DEFAULT));
}

From source file:co.turnus.analysis.pipelining.SimplePipelining.java

private void initTrace() {
    if (!traceProject.isTraceLoaded()) {
        Configuration config = new BaseConfiguration();
        config.setProperty(SENS_STATEVAR, true);
        config.setProperty(SENS_FSM, false);
        config.setProperty(SENS_PORT, false);
        config.setProperty(SENS_GUARD, false);
        config.setProperty(SENS_TOKENS, false);
        traceProject.loadTrace(config);/*w  ww .  java2s.com*/
    }
}

From source file:com.netflix.config.ConcurrentMapConfigurationTest.java

private void testConfigurationSet(Configuration conf) {
    long start = System.currentTimeMillis();
    for (int i = 0; i < 1000000; i++) {
        conf.setProperty("key" + +(i % 100), "value");
    }/*  w w  w  . j  a v a 2s .co m*/
    long duration = System.currentTimeMillis() - start;
    System.out.println("Set property for " + conf + " took " + duration + " ms");
}