Example usage for org.apache.commons.configuration BaseConfiguration BaseConfiguration

List of usage examples for org.apache.commons.configuration BaseConfiguration BaseConfiguration

Introduction

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

Prototype

BaseConfiguration

Source Link

Usage

From source file:com.comcast.viper.flume2storm.spout.FlumeSpoutConfigurationTest.java

/**
 * Test invalid argument for/*from   ww  w  .  java  2s  . co  m*/
 * {@link FlumeSpoutConfiguration#setLocationServiceFactoryClassName(String)}
 * 
 * @throws F2SConfigurationException
 *           If value is invalid
 */
@Test(expected = F2SConfigurationException.class)
public void testLocationServiceFactoryClassName3() throws F2SConfigurationException {
    Configuration config = new BaseConfiguration();
    config.addProperty(FlumeSpoutConfiguration.LOCATION_SERVICE_FACTORY_CLASS, "not-a-class");
    FlumeSpoutConfiguration.from(config);
}

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

@Test
public void testNoneDeletingPollingSource() throws Exception {
    BaseConfiguration config = new BaseConfiguration();
    config.addProperty("prop1", "original");
    DummyPollingSource source = new DummyPollingSource(false);
    source.setFull("");
    FixedDelayPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 10, true);
    ConfigurationWithPollingSource pollingConfig = new ConfigurationWithPollingSource(config, source,
            scheduler);//from   www.  ja v  a 2  s.c  om
    Thread.sleep(200);
    assertEquals("original", pollingConfig.getProperty("prop1"));
    source.setFull("prop1=changed");
    Thread.sleep(200);
    assertEquals("changed", pollingConfig.getProperty("prop1"));
    source.setFull("prop1=changedagain,prop2=new");
    Thread.sleep(200);
    assertEquals("changedagain", pollingConfig.getProperty("prop1"));
    assertEquals("new", pollingConfig.getProperty("prop2"));
    source.setFull("prop3=new");
    Thread.sleep(200);
    assertEquals("changedagain", pollingConfig.getProperty("prop1"));
    assertEquals("new", pollingConfig.getProperty("prop2"));
    assertEquals("new", pollingConfig.getProperty("prop3"));
}

From source file:com.feedzai.fos.impl.r.RIntegrationTest.java

@Test
public void addModelFile() throws Exception {

    BaseConfiguration configuration = new BaseConfiguration();
    Map<String, String> properties = new HashMap<>();
    List<Attribute> attributes = getAttributes();

    ModelConfig modelConfig = new ModelConfig(attributes, properties);

    modelConfig.setProperty(RModelConfig.LIBRARIES, "e1071, foreign");
    modelConfig.setProperty(RModelConfig.MODEL_SAVE_PATH, getCwd());
    modelConfig.setProperty(RModelConfig.CLASS_INDEX, Integer.valueOf(attributes.size() - 1).toString());
    modelConfig.setProperty(RModelConfig.TRAIN_FUNCTION, "svm");
    modelConfig.setProperty(RModelConfig.TRAIN_FUNCTION_ARGUMENTS, "probability = TRUE");
    modelConfig.setProperty(RModelConfig.PREDICT_FUNCTION_ARGUMENTS, "probability = TRUE");
    modelConfig.setProperty(RModelConfig.PREDICT_RESULT_TRANSFORM, "r <- attr(r, 'probabilities')");

    configuration.setProperty(FosConfig.FACTORY_NAME, RManagerFactory.class.getName());

    FosConfig config = new FosConfig(configuration);

    RManagerConfig rManagerConfig = new RManagerConfig(config);

    RManager rManager = new RManager(rManagerConfig);
    UUID uuid = rManager.trainAndAddFile(modelConfig, getCwd() + "/credit-a.arff");

    Scorer scorer = rManager.getScorer();

    Object[] instance = { "b", 30.83, 0, "u", "g", "w", "v", 1.25, "t", "t", 1, "f", "g", 202, 0 };

    List<double[]> result = scorer.score(ImmutableList.of(uuid), instance);
    assertEquals("Only 1 score expected", 1, result.size());
    assertEquals("2 probabilities (not fraud, fraud)", 2, result.get(0).length);

}

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

private static Configuration parseCommandLine(CommandLine cmd) throws ParseException {
    Configuration config = new BaseConfiguration();

    StringBuffer s = new StringBuffer();

    config.setProperty(VERBOSE, cmd.hasOption("v"));

    if (!cmd.hasOption("t")) {
        s.append("Trace project directory not specified. ");
    } else {/* w w w  .  j  a va  2s . c o  m*/
        String fileName = cmd.getOptionValue("t", "");
        File file = new File(fileName);
        if (file == null || !file.exists()) {
            s.append("Trace project does not exists. ");
        } else {
            config.setProperty(TRACE_PROJECT, fileName);
        }
    }

    if (!cmd.hasOption("o")) {
        s.append("Output directory not specified. ");
    } else {
        String fileName = cmd.getOptionValue("o", "");
        File file = new File(fileName);
        if (file == null || !file.exists()) {
            s.append("Output directory does not exists. ");
        } else {
            config.setProperty(OUTPUT_PATH, fileName);
        }
    }

    if (cmd.hasOption("xls")) {
        String fileName = cmd.getOptionValue("xls", "");
        if (fileName == null || fileName.isEmpty()) {
            s.append("XLS file name is not correct. ");
        } else {
            config.setProperty(XLS, fileName);
        }

    }

    String error = s.toString();
    if (!error.isEmpty()) {
        throw new ParseException(error);
    }

    return config;
}

From source file:com.comcast.viper.flume2storm.sink.StormSinkConfigurationTest.java

/**
 * Test invalid argument for {@link StormSinkConfiguration#setBatchSize(int)}
 * using the {@link StormSinkConfiguration#from(Configuration)}
 * //  w  ww .j a v  a2s.c o m
 * @throws F2SConfigurationException
 *           If value is invalid
 */
@Test(expected = F2SConfigurationException.class)
public void testInvalidBatchSize2() throws F2SConfigurationException {
    Configuration config = new BaseConfiguration();
    config.addProperty(StormSinkConfiguration.BATCH_SIZE, "not-a-number");
    StormSinkConfiguration.from(config);
}

From source file:com.steelbridgelabs.oss.neo4j.structure.Neo4JGraphConfigurationBuilder.java

public Configuration build() {
    // create configuration instance
    Configuration configuration = new BaseConfiguration();
    // url/*from www.  j  a  v a  2 s  .  com*/
    configuration.setProperty(Neo4JUrlConfigurationKey, "bolt://" + hostname + ":" + port);
    // hostname
    configuration.setProperty(Neo4JHostnameConfigurationKey, hostname);
    // port
    configuration.setProperty(Neo4JPortConfigurationKey, port);
    // username
    configuration.setProperty(Neo4JUsernameConfigurationKey, username);
    // password
    configuration.setProperty(Neo4JPasswordConfigurationKey, password);
    // graphName
    configuration.setProperty(Neo4JGraphNameConfigurationKey, graphName);
    // vertex id provider
    configuration.setProperty(Neo4JVertexIdProviderClassNameConfigurationKey,
            vertexIdProviderClassName != null ? vertexIdProviderClassName : elementIdProviderClassName);
    // edge id provider
    configuration.setProperty(Neo4JEdgeIdProviderClassNameConfigurationKey,
            edgeIdProviderClassName != null ? edgeIdProviderClassName : elementIdProviderClassName);
    // property id provider
    configuration.setProperty(Neo4JPropertyIdProviderClassNameConfigurationKey,
            propertyIdProviderClassName != null ? propertyIdProviderClassName : elementIdProviderClassName);
    // return configuration
    return configuration;
}

From source file:dk.dma.ais.abnormal.stat.AbnormalStatBuilderAppModule.java

@Provides
@Singleton/* w ww. jav a2  s.com*/
Configuration provideConfiguration() {
    Configuration configuration = null;
    try {
        PropertiesConfiguration configFile = new PropertiesConfiguration("stat-builder.properties");
        configuration = configFile;
        LOG.info("Loaded configuration file " + configFile.getFile().toString() + ".");
    } catch (ConfigurationException e) {
        configuration = new BaseConfiguration();
        LOG.warn(e.getMessage() + ". Using blank configuration.");
    }
    return configuration;
}

From source file:ai.grakn.factory.OrientDBInternalFactory.java

private OrientGraph createIndicesVertex(OrientGraph graph) {
    ResourceBundle keys = ResourceBundle.getBundle("indices-vertices");
    Set<String> labels = keys.keySet();

    for (String label : labels) {
        String[] configs = keys.getString(label).split(",");

        for (String propertyConfig : configs) {
            String[] propertyConfigs = propertyConfig.split(":");
            Schema.VertexProperty property = Schema.VertexProperty.valueOf(propertyConfigs[0]);
            boolean isUnique = Boolean.parseBoolean(propertyConfigs[1]);

            OType orientDataType = getOrientDataType(property);
            BaseConfiguration indexConfig = new BaseConfiguration();
            indexConfig.setProperty("keytype", orientDataType);
            //TODO: Figure out why this is not working when the Orient Guys say it should
            //indexConfig.setProperty("metadata.ignoreNullValues", true);

            if (isUnique) {
                indexConfig.setProperty("type", "UNIQUE");
            }//from  w w w  .  jav a2s  .  co  m

            if (!graph.getVertexIndexedKeys(label).contains(property.name())) {
                graph.createVertexIndex(property.name(), label, indexConfig);
            }
        }
    }

    return graph;
}

From source file:com.comcast.viper.flume2storm.sink.StormSinkConfigurationTest.java

/**
 * Test invalid argument for {@link StormSinkConfiguration#setBatchSize(int)}
 * using the {@link StormSinkConfiguration#from(Configuration)}
 * /* w w w . ja va  2  s  .  co m*/
 * @throws F2SConfigurationException
 *           If value is invalid
 */
@Test(expected = F2SConfigurationException.class)
public void testInvalidBatchSize3() throws F2SConfigurationException {
    Configuration config = new BaseConfiguration();
    config.addProperty(StormSinkConfiguration.BATCH_SIZE, "-1");
    StormSinkConfiguration.from(config);
}

From source file:com.dattack.dbcopy.engine.DbCopyJob.java

public void execute() {

    LOGGER.info("Running job '{}' at thread '{}'", dbcopyJobBean.getId(), Thread.currentThread().getName());

    final List<Future<?>> futureList = new ArrayList<>();

    final DbCopyJobResult jobResult = new DbCopyJobResult(dbcopyJobBean);
    MBeanHelper.registerMBean("com.dattack.dbcopy:type=JobResult,name=" + dbcopyJobBean.getId(), jobResult);

    final RangeVisitor rangeVisitor = new RangeVisitor() {

        @Override/*w w  w  . j av a  2s.  c o m*/
        public void visite(final IntegerRangeBean bean) {

            for (int i = bean.getLowValue(); i < bean.getHighValue(); i += bean.getBlockSize()) {

                final int lowValue = i;
                final int highValue = i + bean.getBlockSize();

                final BaseConfiguration baseConfiguration = new BaseConfiguration();
                baseConfiguration.setProperty(bean.getId() + ".low", lowValue);
                baseConfiguration.setProperty(bean.getId() + ".high", highValue);

                final CompositeConfiguration configuration = new CompositeConfiguration();
                configuration.addConfiguration(externalConfiguration);
                configuration.addConfiguration(ConfigurationUtil.createEnvSystemConfiguration());
                configuration.addConfiguration(baseConfiguration);

                final String taskName = String.format("Task_%d_%d", lowValue, highValue);

                final DbCopyTask dbcopyTask = new DbCopyTask(dbcopyJobBean, configuration,
                        jobResult.createTaskResult(taskName));
                futureList.add(executionController.submit(dbcopyTask));
            }
        }

        @Override
        public void visite(final NullRangeBean bean) {

            final String taskName = "SingleTask";
            final CompositeConfiguration configuration = new CompositeConfiguration();
            configuration.addConfiguration(externalConfiguration);
            configuration.addConfiguration(ConfigurationUtil.createEnvSystemConfiguration());

            final DbCopyTask dbcopyTask = new DbCopyTask(dbcopyJobBean, configuration,
                    jobResult.createTaskResult(taskName));
            futureList.add(executionController.submit(dbcopyTask));
        }
    };

    if (dbcopyJobBean.getRangeBean() == null || dbcopyJobBean.getRangeBean().isEmpty()) {
        new NullRangeBean().accept(rangeVisitor);
    } else {
        for (final AbstractRangeBean item : dbcopyJobBean.getRangeBean()) {
            item.accept(rangeVisitor);
        }
    }

    executionController.shutdown();
    showFutures(futureList);

    show(jobResult);

    LOGGER.info("Job finished (job-name: '{}', thread: '{}')", dbcopyJobBean.getId(),
            Thread.currentThread().getName());
}