Example usage for org.apache.commons.configuration PropertiesConfiguration addProperty

List of usage examples for org.apache.commons.configuration PropertiesConfiguration addProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration PropertiesConfiguration addProperty.

Prototype

public void addProperty(String key, Object value) 

Source Link

Document

Adds a new property to this configuration.

Usage

From source file:com.pinterest.secor.io.FileReaderWriterTest.java

private void setupSequenceFileReaderConfig() {
    PropertiesConfiguration properties = new PropertiesConfiguration();
    properties.addProperty("secor.file.reader.writer", "com.pinterest.secor.io.impl.SequenceFileReaderWriter");
    mConfig = new SecorConfig(properties);
}

From source file:com.pinterest.secor.io.FileReaderWriterTest.java

private void setupDelimitedTextFileReaderWriterConfig() {
    PropertiesConfiguration properties = new PropertiesConfiguration();
    properties.addProperty("secor.file.reader.writer",
            "com.pinterest.secor.io.impl.DelimitedTextFileReaderWriter");
    mConfig = new SecorConfig(properties);
}

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

private PropertiesConfiguration serverProperties() {
    final PropertiesConfiguration serverConfiguration = new PropertiesConfiguration();
    serverConfiguration.addProperty(getKey("pinot.server.instance", "id"), "0");
    serverConfiguration.addProperty(getKey("pinot.server.instance", "bootstrap.segment.dir"),
            SERVER_BOOTSTRAP_DIR);//from w w w .  j a  va2 s  .  c o  m
    serverConfiguration.addProperty(getKey("pinot.server.instance", "dataDir"), SERVER_INDEX_DIR);
    serverConfiguration.addProperty(getKey("pinot.server.instance", "tableName"),
            StringUtils.join(TABLE_NAMES, ',').trim());
    for (final String table : TABLE_NAMES) {
        serverConfiguration
                .addProperty(getKey("pinot.server.instance", table.trim(), "numQueryExecutorThreads"), "50");
        serverConfiguration.addProperty(getKey("pinot.server.instance", table.trim(), "dataManagerType"),
                "offline");
        serverConfiguration.addProperty(getKey("pinot.server.instance", table.trim(), "readMode"),
                SERVER_INDEX_READ_MODE);
    }
    serverConfiguration.addProperty("pinot.server.instance.data.manager.class",
            FileBasedInstanceDataManager.class.getName());
    serverConfiguration.addProperty("pinot.server.instance.segment.metadata.loader.class",
            ColumnarSegmentMetadataLoader.class.getName());
    serverConfiguration.addProperty("pinot.server.query.executor.pruner.class",
            StringUtil.join(",", TimeSegmentPruner.class.getSimpleName(),
                    DataSchemaSegmentPruner.class.getSimpleName(), ValidSegmentPruner.class.getSimpleName()));
    serverConfiguration.addProperty("pinot.server.query.executor.pruner.TimeSegmentPruner.id", "0");
    serverConfiguration.addProperty("pinot.server.query.executor.pruner.DataSchemaSegmentPruner.id", "1");
    serverConfiguration.addProperty("pinot.server.query.executor.pruner.ValidSegmentPruner.id", "2");
    serverConfiguration.addProperty("pinot.server.query.executor.class",
            ServerQueryExecutorV1Impl.class.getName());
    serverConfiguration.addProperty("pinot.server.requestHandlerFactory.class",
            SimpleRequestHandlerFactory.class.getName());
    serverConfiguration.addProperty("pinot.server.netty.port", SERVER_PORT);
    serverConfiguration.setDelimiterParsingDisabled(false);
    return serverConfiguration;
}

From source file:com.github.zdsiyan.maven.plugin.smartconfig.internal.PropertyConfigurator.java

@Override
public ByteArrayOutputStream execute(InputStream in, Charset charset, List<PointHandle> pointhandles)
        throws IOException {
    try {/* w ww .  ja v  a  2  s . c  om*/
        PropertiesConfiguration configuration = new PropertiesConfiguration();
        configuration.load(in, charset.name());

        pointhandles.forEach(point -> {
            switch (point.getMode()) {
            case insert:
                configuration.addProperty(point.getExpression(), point.getValue());
                break;
            case delete:
                configuration.setProperty(point.getExpression(), "");
                break;
            case replace:
            default:
                configuration.setProperty(point.getExpression(), point.getValue());
                break;
            }
        });

        // output
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        configuration.save(out, charset.name());
        return out;
    } catch (ConfigurationException ex) {
        // FIXME
        throw new RuntimeException(ex);
    }
}

From source file:com.linkedin.pinot.broker.broker.BrokerRequestValidationTest.java

/**
 * Setup method to start the broker. Stars the broker with
 * a query response limit of {@value QUERY_RESPONSE_LIMIT}
 * @return/*ww  w.  j a v  a2s. c  o  m*/
 * @throws Exception
 */
@BeforeClass
public BrokerServerBuilder setup() throws Exception {
    // Read default configurations.
    PropertiesConfiguration config = new PropertiesConfiguration(
            new File(BrokerServerBuilderTest.class.getClassLoader().getResource("broker.properties").toURI()));

    // Set the value for query response limit.
    config.addProperty(QUERY_RESPONSE_LIMIT_CONFIG, QUERY_RESPONSE_LIMIT);
    brokerBuilder = new BrokerServerBuilder(config, null, null, null);

    brokerBuilder.buildNetwork();
    brokerBuilder.buildHTTP();
    brokerBuilder.start();

    return brokerBuilder;
}

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

private PropertiesConfiguration brokerProperties() {
    final PropertiesConfiguration brokerConfiguration = new PropertiesConfiguration();

    //transport properties

    //config based routing
    brokerConfiguration.addProperty("pinot.broker.transport.routingMode", "CONFIG");

    //two tables/*from   w  ww. j  av  a  2s .c o m*/
    brokerConfiguration.addProperty("pinot.broker.transport.routing.tableName",
            StringUtils.join(TABLE_NAMES, ","));

    // table conf

    for (final String table : TABLE_NAMES) {
        brokerConfiguration.addProperty(getKey("pinot.broker.transport.routing", table, "numNodesPerReplica"),
                "1");
        brokerConfiguration.addProperty(getKey("pinot.broker.transport.routing", table, "serversForNode.0"),
                "localhost:" + SERVER_PORT);
        brokerConfiguration.addProperty(
                getKey("pinot.broker.transport.routing", table, "serversForNode.default"),
                "localhost:" + SERVER_PORT);
    }
    // client properties
    brokerConfiguration.addProperty("pinot.broker.client.enableConsole", "true");
    brokerConfiguration.addProperty("pinot.broker.client.queryPort", BROKER_CLIENT_PORT);
    brokerConfiguration.addProperty("pinot.broker.client.consolePath", "dont/need/this");
    brokerConfiguration.setDelimiterParsingDisabled(false);
    return brokerConfiguration;
}

From source file:com.github.nethad.clustermeister.provisioning.dependencymanager.DependencyConfigurationUtilTest.java

@Test
public void testPom() throws DependencyResolutionException {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    String pomPath = getClass().getResource(EXAMPLE_POM_PATH).getPath();
    String pom2Path = getClass().getResource(EXAMPLE_POM2_PATH).getPath();
    configuration.addProperty(DependencyConfigurationUtil.PRELOAD_POMS, pomPath);
    configuration.addProperty(DependencyConfigurationUtil.PRELOAD_POMS, pom2Path);

    DependencyConfigurationUtil.getConfiguredDependencies(configuration);

    verify(mavenRepositorySystem, times(1)).resolveDependenciesFromPom(eq(new File(pomPath)));
    verify(mavenRepositorySystem, times(1)).resolveDependenciesFromPom(eq(new File(pom2Path)));
}

From source file:cz.cas.lib.proarc.common.config.AppConfiguration.java

private void buildConfiguration(CompositeConfiguration cc, File cfgFile) {
    try {// w w  w  . ja  va  2s .  c  o m
        // envConfig contains interpolated properties
        PropertiesConfiguration envConfig = new PropertiesConfiguration();
        envConfig.addProperty(PROPERTY_APP_HOME, configHome.getPath());
        cc.addConfiguration(envConfig);
        // external configuration editable by users; UTF-8 expected
        PropertiesConfiguration external = new PropertiesConfiguration();
        external.setEncoding("UTF-8");
        FileChangedReloadingStrategy reloading = new FileChangedReloadingStrategy();
        external.setReloadingStrategy(reloading);
        external.setFile(cfgFile);
        cc.addConfiguration(external);
        try {
            // bundled default configurations
            Enumeration<URL> resources = AppConfiguration.class.getClassLoader()
                    .getResources(DEFAULT_PROPERTIES_RESOURCE);
            for (URL resource; resources.hasMoreElements();) {
                resource = resources.nextElement();
                LOG.log(Level.FINE, "classpath config: {0}", resource);
                cc.addConfiguration(new PropertiesConfiguration(resource));
            }
        } catch (IOException ex) {
            LOG.log(Level.SEVERE, null, ex);
        }
    } catch (ConfigurationException ex) {
        LOG.log(Level.SEVERE, null, ex);
    }
}

From source file:com.aurel.track.DBScriptTest.java

/***************************** HELPERS *****************************/

public PropertiesConfiguration getRealPropertyObj(String dbTypePrefix) {
    try {//w  ww  .  j a v  a 2  s. co  m
        String propFilePath = System.getProperty("user.dir")
                + "/src/test/resources/schema/DBScriptTester.properties";
        FileInputStream input = new FileInputStream(propFilePath);
        Properties prop = new Properties();
        prop.load(input);
        PropertiesConfiguration props = new PropertiesConfiguration();
        props.addProperty("torque.dsfactory.track.connection.user", prop.get(dbTypePrefix + "user"));
        props.addProperty("torque.dsfactory.track.connection.password", prop.get(dbTypePrefix + "password"));
        props.addProperty("torque.database.track.adapter", prop.get(dbTypePrefix + "adapter"));
        props.addProperty("torque.dsfactory.track.connection.driver", prop.get(dbTypePrefix + "driver"));
        props.addProperty("torque.dsfactory.track.connection.url", prop.get(dbTypePrefix + "url"));
        props.addProperty("torque.dsfactory.track.factory",
                "org.apache.torque.dsfactory.SharedPoolDataSourceFactory");
        props.addProperty("torque.dsfactory.track.pool.maxActive", "30");
        props.addProperty("torque.dsfactory.track.pool.testOnBorrow", "true");
        props.addProperty("torque.dsfactory.track.pool.validationQuery", "SELECT PKEY FROM TSTATE");
        return props;
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return null;
}

From source file:com.kylinolap.rest.service.AdminService.java

/**
 * Get Java Env info as string/*from  w ww. j  av a 2s  .  c o m*/
 * 
 * @return
 */
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN)
public String getEnv() {
    logger.debug("Get Kylin Runtime environment");
    PropertiesConfiguration tempConfig = new PropertiesConfiguration();

    // Add Java Env

    try {
        String content = "";
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        // env
        Map<String, String> env = System.getenv();
        for (String envName : env.keySet()) {
            tempConfig.addProperty(envName, env.get(envName));
        }
        // properties
        Properties properteis = System.getProperties();
        for (Object propName : properteis.keySet()) {
            tempConfig.setProperty((String) propName, properteis.get(propName));
        }

        // do save
        tempConfig.save(baos);
        content = baos.toString();
        return content;
    } catch (ConfigurationException e) {
        logger.debug("Failed to get Kylin Runtime env", e);
        throw new InternalErrorException("Failed to get Kylin env Config", e);
    }
}