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:com.yahoo.omid.benchmarks.tso.TxRunner.java

public TxRunner(MetricsRegistry metrics, Config expConfig)
        throws IOException, InterruptedException, ExecutionException {

    // Tx Runner config
    this.outstandingTxs = new Semaphore(expConfig.maxInFlight);
    this.maxTxSize = expConfig.maxTxSize;
    this.commitDelay = expConfig.commitDelay;
    this.percentReads = expConfig.readproportion == -1 ? expConfig.percentReads
            : (expConfig.readproportion * 100);
    this.intGenerator = GeneratorUtils.getIntGenerator(expConfig.requestDistribution);
    this.randomGen = new Random(System.currentTimeMillis() * txRunnerId); // to make it channel dependent

    LOG.info("TxRunner-{} [ Row Distribution -> {} ]", txRunnerId, expConfig.requestDistribution);
    LOG.info("TxRunner-{} [ Outstanding transactions -> {} ]", txRunnerId, expConfig.maxInFlight);
    LOG.info("TxRunner-{} [ Max Tx Size -> {} ]", txRunnerId, expConfig.maxTxSize);
    LOG.info("TxRunner-{} [ Commit delay -> {}:{} ]", txRunnerId, expConfig.commitDelay.timeValue,
            expConfig.commitDelay.timeUnit);
    LOG.info("TxRunner-{} [ % reads -> {} ]", txRunnerId, expConfig.percentReads);

    // Commit table client initialization
    CommitTable commitTable;// w w w  .j  av a  2s .co m
    if (expConfig.isHBase()) {
        HBaseLogin.loginIfNeeded(expConfig.getLoginFlags());
        HBaseCommitTableConfig hbaseCommitTableConfig = new HBaseCommitTableConfig();
        hbaseCommitTableConfig.setTableName(expConfig.getHBaseCommitTable());
        commitTable = new HBaseCommitTable(HBaseConfiguration.create(), hbaseCommitTableConfig);
        LOG.info("TxRunner-{} [ Using HBase Commit Table ]", txRunnerId);
    } else {
        commitTable = new NullCommitTable();
        LOG.info("TxRunner-{} [ Using Null Commit Table ]", txRunnerId);
    }
    try {
        this.commitTableClient = commitTable.getClient().get();
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        e.printStackTrace();
        throw e;
    } catch (ExecutionException e) {
        e.printStackTrace();
        throw e;
    }

    // TSO Client initialization
    Configuration tsoConfig = new BaseConfiguration();
    tsoConfig.setProperty(TSO_HOST_CONFKEY, expConfig.tsoHostPort.getHostText());
    tsoConfig.setProperty(TSO_PORT_CONFKEY, expConfig.tsoHostPort.getPortOrDefault(1234));
    tsoConfig.setProperty("request.timeout-ms", -1); // TODO ???
    LOG.info("TxRunner-{} [ Connected to TSO in {} ]", txRunnerId, expConfig.tsoHostPort);

    this.tsoClient = TSOClient.newBuilder().withConfiguration(tsoConfig).build();

    // Stat initialization
    String hostName = InetAddress.getLocalHost().getHostName();
    this.timestampTimer = metrics.timer(name("tx_runner", Integer.toString(txRunnerId), hostName, "timestamp"));
    this.commitTimer = metrics.timer(name("tx_runner", Integer.toString(txRunnerId), hostName, "commit"));
    this.abortTimer = metrics.timer(name("tx_runner", Integer.toString(txRunnerId), hostName, "abort"));
    this.errorCounter = metrics.counter(name("tx_runner", Integer.toString(txRunnerId), hostName, "errors"));

}

From source file:com.linkedin.pinot.integration.tests.ClusterTest.java

protected void startBrokers(int brokerCount) {
    try {//from w  w  w.  j av a  2  s  .co m
        for (int i = 0; i < brokerCount; ++i) {
            final String helixClusterName = getHelixClusterName();
            Configuration configuration = BrokerTestUtils.getDefaultBrokerConfiguration();
            configuration.setProperty("pinot.broker.timeoutMs", 100 * 1000L);
            configuration.setProperty("pinot.broker.client.queryPort", Integer.toString(18099 + i));
            configuration.setProperty("pinot.broker.routing.table.builder.class", "random");
            overrideBrokerConf(configuration);
            _brokerStarters.add(
                    BrokerTestUtils.startBroker(helixClusterName, ZkStarter.DEFAULT_ZK_STR, configuration));
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:com.linkedin.pinot.perf.PerfBenchmarkDriver.java

public void startBroker() throws Exception {

    if (!conf.isStartBroker()) {
        LOGGER.info("Skipping start broker step. Assumes broker is already started");
        return;//from   w ww .j a  v  a 2  s .  co m
    }
    String brokerInstanceName = "Broker_localhost_" + CommonConstants.Helix.DEFAULT_BROKER_QUERY_PORT;

    Configuration brokerConfiguration = new PropertiesConfiguration();
    brokerConfiguration.setProperty("instanceId", brokerInstanceName);
    HelixBrokerStarter helixBrokerStarter = new HelixBrokerStarter(clusterName, zkAddress, brokerConfiguration);
}

From source file:com.linkedin.pinot.integration.tests.ClusterTest.java

protected void startServers(int serverCount) {
    try {/*from   w w  w  .j a  va  2  s .c om*/
        for (int i = 0; i < serverCount; i++) {
            Configuration configuration = DefaultHelixStarterServerConfig.loadDefaultServerConf();
            configuration.setProperty(Server.CONFIG_OF_INSTANCE_DATA_DIR,
                    Server.DEFAULT_INSTANCE_DATA_DIR + "-" + i);
            configuration.setProperty(Server.CONFIG_OF_INSTANCE_SEGMENT_TAR_DIR,
                    Server.DEFAULT_INSTANCE_SEGMENT_TAR_DIR + "-" + i);
            configuration.setProperty(Server.CONFIG_OF_ADMIN_API_PORT,
                    Integer.toString(Integer.valueOf(Server.DEFAULT_ADMIN_API_PORT) - i));
            configuration.setProperty(Server.CONFIG_OF_NETTY_PORT,
                    Integer.toString(Integer.valueOf(Helix.DEFAULT_SERVER_NETTY_PORT) + i));
            overrideOfflineServerConf(configuration);
            _serverStarters.add(
                    new HelixServerStarter(getHelixClusterName(), ZkStarter.DEFAULT_ZK_STR, configuration));
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:co.turnus.analysis.bottlenecks.AlgorithmicBottlenecks.java

private void initTrace() {
    if (!project.isTraceLoaded()) {
        Configuration config = new BaseConfiguration();
        config.setProperty(SENS_STATEVAR, false);
        config.setProperty(SENS_FSM, false);
        config.setProperty(SENS_PORT, false);
        config.setProperty(SENS_GUARD, false);
        config.setProperty(SENS_TOKENS, false);
        project.loadTrace(config);//www . ja  va  2s.c o  m
    }
}

From source file:fresto.datastore.titan.TitanEventWriter.java

public TitanGraph openTitanGraph() {
    //OGraphDatabase oGraph = new OGraphDatabase(DB_URL);
    LOGGER.info("Setting up Titan");
    Configuration config = new BaseConfiguration();
    config.setProperty("storage.backend", STORAGE_BACKEND);
    config.setProperty("storage.hostname", STORAGE_HOSTNAME);
    config.setProperty("storage.connection-pool-size", 8);

    g = TitanFactory.open(config);/*from  ww  w. j  av  a2  s  .c o m*/
    return g;
}

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

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

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

    // hystrix parameters
    archaiusConfig.setProperty("hystrix.threadpool.default.maxQueueSize",
            CaravanHttpThreadPoolConfig.HYSTRIX_THREADPOOL_MAXQUEUESIZE_DEFAULT);
    archaiusConfig.setProperty("hystrix.threadpool.default.queueSizeRejectionThreshold",
            CaravanHttpThreadPoolConfig.HYSTRIX_THREADPOOL_QUEUESIZEREJECTIONTHRESHOLD_DEFAULT);

    archaiusConfig.setProperty(HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_TIMEOUT_MS,
            PropertiesUtil.toInteger(config.get(HYSTRIX_TIMEOUT_MS_PROPERTY), HYSTRIX_TIMEOUT_MS_DEFAULT));
    archaiusConfig.setProperty(HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_FALLBACK_ENABLED,
            PropertiesUtil.toBoolean(config.get(HYSTRIX_FALLBACK_ENABLED_PROPERTY),
                    HYSTRIX_FALLBACK_ENABLED_DEFAULT));
    archaiusConfig.setProperty(HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_CIRCUITBREAKER_ENABLED,
            PropertiesUtil.toBoolean(config.get(HYSTRIX_CIRCUITBREAKER_ENABLED_PROPERTY),
                    HYSTRIX_CIRCUITBREAKER_ENABLED_DEFAULT));
    archaiusConfig.setProperty(
            HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_CIRCUITBREAKER_REQUESTVOLUMETHRESHOLD,
            PropertiesUtil.toInteger(config.get(HYSTRIX_CIRCUITBREAKER_REQUESTVOLUMETHRESHOLD_PROPERTY),
                    HYSTRIX_CIRCUITBREAKER_REQUESTVOLUMETHRESHOLD_DEFAULT));
    archaiusConfig.setProperty(HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_CIRCUITBREAKER_SLEEPWINDOW_MS,
            PropertiesUtil.toInteger(config.get(HYSTRIX_CIRCUITBREAKER_SLEEPWINDOW_MS_PROPERTY),
                    HYSTRIX_CIRCUITBREAKER_SLEEPWINDOW_MS_DEFAULT));
    archaiusConfig.setProperty(
            HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_CIRCUITBREAKER_ERRORTHRESHOLDPERCENTAGE,
            PropertiesUtil.toInteger(config.get(HYSTRIX_CIRCUITBREAKER_ERRORTHRESHOLDPERCENTAGE_PROPERTY),
                    HYSTRIX_CIRCUITBREAKER_ERRORTHRESHOLDPERCENTAGE_DEFAULT));
    archaiusConfig.setProperty(HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_CIRCUITBREAKER_FORCEOPEN,
            PropertiesUtil.toBoolean(config.get(HYSTRIX_CIRCUITBREAKER_FORCEOPEN_PROPERTY),
                    HYSTRIX_CIRCUITBREAKER_FORCEOPEN_DEFAULT));
    archaiusConfig.setProperty(HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_CIRCUITBREAKER_FORCECLOSED,
            PropertiesUtil.toBoolean(config.get(HYSTRIX_CIRCUITBREAKER_FORCECLOSED_PROPERTY),
                    HYSTRIX_CIRCUITBREAKER_FORCECLOSED_DEFAULT));
    if (config.get(HYSTRIX_EXECUTIONISOLATIONTHREADPOOLKEY_OVERRIDE_PROPERTY) != null) {
        // thread pool name
        archaiusConfig.setProperty(
                HYSTRIX_COMMAND_PREFIX + serviceId + HYSTRIX_PARAM_EXECUTIONISOLATIONTHREADPOOLKEY_OVERRIDE,
                config.get(HYSTRIX_EXECUTIONISOLATIONTHREADPOOLKEY_OVERRIDE_PROPERTY));
    }

    // others
    archaiusConfig.setProperty(serviceId + HTTP_PARAM_PROTOCOL,
            PropertiesUtil.toString(config.get(PROTOCOL_PROPERTY), PROTOCOL_PROPERTY_DEFAULT));
    archaiusConfig.setProperty(serviceId + THROW_EXCEPTION_FOR_STATUS_500, PropertiesUtil
            .toBoolean(config.get(THROW_EXCEPTION_FOR_STATUS_500), THROW_EXCEPTION_FOR_STATUS_500_DEFAULT));

    // update protocol to be used
    applyRibbonHostsProcotol(serviceId);
}

From source file:at.salzburgresearch.kmt.zkconfig.ZookeeperConfigurationTest.java

@Test
public void testBoolean() throws Exception {
    Configuration config = new ZookeeperConfiguration(zkConnection, 5000, "/test");

    final String key = UUID.randomUUID().toString();

    assertThat(config.getProperty(key), nullValue());

    config.setProperty(key, true);
    assertTrue(config.getBoolean(key, false));
    assertEquals(config.getBoolean(key, Boolean.FALSE), Boolean.TRUE);

    config.setProperty(key, false);//from   w ww.j a  v  a2 s.  c  om
    assertFalse(config.getBoolean(key, true));
    assertEquals(config.getBoolean(key, Boolean.TRUE), Boolean.FALSE);

}

From source file:com.blazegraph.gremlin.embedded.BlazeGraphEmbedded.java

/**
 * Open a BlazeGraphEmbedded (unisolated) instance wrapping the provided
 * SAIL repository and using the supplied configuration.
 * /*from   ww w  .j  a  va 2  s  .c  o  m*/
 * @return
 *          an open and initialized repository
 * @param config
 *          additional configuration
 * @return
 *          instance
 */
public static BlazeGraphEmbedded open(final BigdataSailRepository repo, final Configuration config) {
    Objects.requireNonNull(repo);
    if (!repo.getDatabase().isStatementIdentifiers()) {
        throw new IllegalArgumentException("BlazeGraph/TP3 requires statement identifiers.");
    }

    /*
     * Grab the last commit time and also check for clock skew.
     */
    final long lastCommitTime = lastCommitTime(repo);
    config.setProperty(BlazeGraph.Options.LIST_INDEX_FLOOR, lastCommitTime);

    return new BlazeGraphEmbedded(repo, config);
}

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   www .j a v a2s. co  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;
}