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:co.turnus.trace.scheduler.devs.util.SimpleTest.java

private static Configuration parseArgs(String[] args) {
    Configuration config = new BaseConfiguration();
    config.setProperty(SENS_STATEVAR, false);
    config.setProperty(SENS_TOKENS, true);
    config.setProperty(SIMULATION_ID, "SimpleTest");

    if (args.length > 2) {
        config.setProperty(EXPORT_GANTT, true);
        config.setProperty(VCD_FILE, args[2]);
    } else {/*from   ww w  .j a  v  a  2s.c  o  m*/
        config.setProperty(EXPORT_GANTT, false);
    }

    return config;
}

From source file:com.linkedin.pinot.broker.routing.RoutingTableTest.java

@Test
public void testHelixExternalViewBasedRoutingTable() throws Exception {
    HelixExternalViewBasedRouting routingTable = new HelixExternalViewBasedRouting(null, null,
            new BaseConfiguration());

    ExternalView externalView = new ExternalView("testResource0_OFFLINE");
    externalView.setState("segment0", "dataServer_instance_0", "ONLINE");
    externalView.setState("segment0", "dataServer_instance_1", "ONLINE");
    externalView.setState("segment1", "dataServer_instance_1", "ONLINE");
    externalView.setState("segment1", "dataServer_instance_2", "ONLINE");
    externalView.setState("segment2", "dataServer_instance_2", "ONLINE");
    externalView.setState("segment2", "dataServer_instance_0", "ONLINE");
    List<InstanceConfig> instanceConfigs = generateInstanceConfigs("dataServer_instance", 0, 2);
    TableConfig testResource0Config = generateTableConfig("testResource0_OFFLINE");
    routingTable.markDataResourceOnline(testResource0Config, externalView, instanceConfigs);
    ExternalView externalView1 = new ExternalView("testResource1_OFFLINE");
    externalView1.setState("segment10", "dataServer_instance_0", "ONLINE");
    externalView1.setState("segment11", "dataServer_instance_1", "ONLINE");
    externalView1.setState("segment12", "dataServer_instance_2", "ONLINE");

    TableConfig testResource1Config = generateTableConfig("testResource1_OFFLINE");
    routingTable.markDataResourceOnline(testResource1Config, externalView1, instanceConfigs);

    ExternalView externalView2 = new ExternalView("testResource2_OFFLINE");
    externalView2.setState("segment20", "dataServer_instance_0", "ONLINE");
    externalView2.setState("segment21", "dataServer_instance_0", "ONLINE");
    externalView2.setState("segment22", "dataServer_instance_0", "ONLINE");
    externalView2.setState("segment20", "dataServer_instance_1", "ONLINE");
    externalView2.setState("segment21", "dataServer_instance_1", "ONLINE");
    externalView2.setState("segment22", "dataServer_instance_1", "ONLINE");
    externalView2.setState("segment20", "dataServer_instance_2", "ONLINE");
    externalView2.setState("segment21", "dataServer_instance_2", "ONLINE");
    externalView2.setState("segment22", "dataServer_instance_2", "ONLINE");
    TableConfig testResource2Config = generateTableConfig("testResource2_OFFLINE");

    routingTable.markDataResourceOnline(testResource2Config, externalView2, instanceConfigs);

    for (int numRun = 0; numRun < 100; ++numRun) {
        assertResourceRequest(routingTable, "testResource0_OFFLINE", "[segment0, segment1, segment2]", 3);
    }//w ww . j a va2  s.c om
    for (int numRun = 0; numRun < 100; ++numRun) {
        assertResourceRequest(routingTable, "testResource1_OFFLINE", "[segment10, segment11, segment12]", 3);
    }
    for (int numRun = 0; numRun < 100; ++numRun) {
        assertResourceRequest(routingTable, "testResource2_OFFLINE", "[segment20, segment21, segment22]", 3);
    }
}

From source file:net.riccardocossu.i18split.maven.I18splitMojo.java

public void execute() throws MojoExecutionException {
    File f = new File(outputBasePath);

    if (!f.exists()) {
        f.mkdirs();/*from w  ww  .j av a  2s.  co  m*/
    }

    BaseConfiguration conf = new BaseConfiguration();
    conf.addProperty(ConfigKeys.INPUT_DRIVER, inputPlugin);
    conf.addProperty(ConfigKeys.OUTPUT_DRIVER, outputPlugin);
    conf.addProperty(ConfigKeys.OUTPUT_BASE_PATH, outputBasePath);
    conf.addProperty(ConfigKeys.INPUT_BASE_PATH, inputBasePath);
    conf.addProperty(ConfigKeys.INPUT_ENCODING, inputEncoding);
    conf.addProperty(ConfigKeys.OUTPUT_ENCODING, outputEncoding);
    if (pluginsConfig != null) {
        @SuppressWarnings("unchecked")
        MapConfiguration mc = new MapConfiguration(pluginsConfig);
        conf.append(mc);
    }
    org.apache.maven.plugin.logging.Log log = getLog();
    Iterator<String> keys = conf.getKeys();
    while (keys.hasNext()) {
        String k = keys.next();
        log.info(String.format("%s = %s", k, conf.getProperty(k)));
    }
    Engine eng = new Engine(conf);
    eng.process();

}

From source file:com.linkedin.pinot.routing.RandomRoutingTableTest.java

@Test
public void testHelixExternalViewBasedRoutingTable() throws Exception {
    URL resourceUrl = getClass().getClassLoader().getResource("SampleExternalView.json");
    Assert.assertNotNull(resourceUrl);/*  w  w  w.  ja v  a  2  s. c o  m*/
    String fileName = resourceUrl.getFile();
    String tableName = "testTable_OFFLINE";
    InputStream evInputStream = new FileInputStream(fileName);
    ZNRecordSerializer znRecordSerializer = new ZNRecordSerializer();
    ZNRecord externalViewRecord = (ZNRecord) znRecordSerializer.deserialize(IOUtils.toByteArray(evInputStream));
    int totalRuns = 10000;
    RoutingTableBuilder routingStrategy = new BalancedRandomRoutingTableBuilder(10);
    HelixExternalViewBasedRouting routingTable = new HelixExternalViewBasedRouting(null,
            new PercentageBasedRoutingTableSelector(), null, new BaseConfiguration());

    routingTable.setSmallClusterRoutingTableBuilder(routingStrategy);

    ExternalView externalView = new ExternalView(externalViewRecord);

    routingTable.markDataResourceOnline(tableName, externalView, getInstanceConfigs(externalView));

    double[] globalArrays = new double[9];

    for (int numRun = 0; numRun < totalRuns; ++numRun) {
        RoutingTableLookupRequest request = new RoutingTableLookupRequest(tableName,
                Collections.<String>emptyList());
        Map<ServerInstance, SegmentIdSet> serversMap = routingTable.findServers(request);
        TreeSet<ServerInstance> serverInstances = new TreeSet<ServerInstance>(serversMap.keySet());

        int i = 0;

        double[] arrays = new double[9];
        for (ServerInstance serverInstance : serverInstances) {
            globalArrays[i] += serversMap.get(serverInstance).getSegments().size();
            arrays[i++] = serversMap.get(serverInstance).getSegments().size();
        }
        for (int j = 0; i < arrays.length; ++j) {
            Assert.assertTrue(arrays[j] / totalRuns <= 31);
            Assert.assertTrue(arrays[j] / totalRuns >= 28);
        }
        //      System.out.println(Arrays.toString(arrays) + " : " + new StandardDeviation().evaluate(arrays) + " : " + new Mean().evaluate(arrays));
    }
    for (int i = 0; i < globalArrays.length; ++i) {
        Assert.assertTrue(globalArrays[i] / totalRuns <= 31);
        Assert.assertTrue(globalArrays[i] / totalRuns >= 28);
    }
    //    System.out.println(Arrays.toString(globalArrays) + " : " + new StandardDeviation().evaluate(globalArrays) + " : "
    //        + new Mean().evaluate(globalArrays));
}

From source file:com.runwaysdk.configuration.InMemoryConfigurator.java

public InMemoryConfigurator() {
    config = new CompositeConfiguration();
    config.addConfiguration(new BaseConfiguration());
    config.addConfiguration(new SystemConfiguration());
    interpolate();//  ww w . j a  v  a  2 s.c  o m
}

From source file:edu.cwru.sepia.agent.CombatAgentDuelTest.java

@BeforeClass
public static void loadTemplates() throws Exception {

    State.StateBuilder builder = new State.StateBuilder();

    builder.setSize(15, 15);/*from ww w  .  ja  v a2  s.  c o  m*/
    state = builder.build();

    templates1 = TypeLoader.loadFromFile("data/unit_templates", player1, state);
    System.out.println("Sucessfully loaded templates");
    for (Template<?> t : templates1) {
        builder.addTemplate(t);
    }
    templates2 = TypeLoader.loadFromFile("data/unit_templates", player2, state);
    System.out.println("Sucessfully loaded templates");
    for (Template<?> t : templates2) {
        builder.addTemplate(t);
    }

    {
        Unit u = ((UnitTemplate) builder.getTemplate(player1, "Footman")).produceInstance(state);
        u.setXPosition(5);
        u.setYPosition(5);
        builder.addUnit(u, u.getXPosition(), u.getYPosition());
    }
    {
        Unit u = ((UnitTemplate) builder.getTemplate(player1, "Footman")).produceInstance(state);
        u.setXPosition(5);
        u.setYPosition(4);
        builder.addUnit(u, u.getXPosition(), u.getYPosition());
    }

    {
        Unit u = ((UnitTemplate) builder.getTemplate(player2, "Footman")).produceInstance(state);
        u.setXPosition(6);
        u.setYPosition(5);
        builder.addUnit(u, u.getXPosition(), u.getYPosition());
    }
    {
        Unit u = ((UnitTemplate) builder.getTemplate(player2, "Footman")).produceInstance(state);
        u.setXPosition(6);
        u.setYPosition(4);
        builder.addUnit(u, u.getXPosition(), u.getYPosition());
    }

    planner = new SimplePlanner(state);
    model = new SimpleDurativeModel(state, null, new BaseConfiguration());
}

From source file:com.linkedin.pinot.broker.routing.RandomRoutingTableTest.java

@Test
public void testHelixExternalViewBasedRoutingTable() throws Exception {
    URL resourceUrl = getClass().getClassLoader().getResource("SampleExternalView.json");
    Assert.assertNotNull(resourceUrl);/*from w ww .j a v a  2  s  . c om*/
    String fileName = resourceUrl.getFile();

    byte[] externalViewBytes = IOUtils.toByteArray(new FileInputStream(fileName));
    ExternalView externalView = new ExternalView(
            (ZNRecord) new ZNRecordSerializer().deserialize(externalViewBytes));
    String tableName = externalView.getResourceName();
    List<InstanceConfig> instanceConfigs = getInstanceConfigs(externalView);
    int numSegmentsInEV = externalView.getPartitionSet().size();
    int numServersInEV = instanceConfigs.size();

    HelixExternalViewBasedRouting routing = new HelixExternalViewBasedRouting(null, null,
            new BaseConfiguration());
    routing.markDataResourceOnline(generateTableConfig(tableName), externalView, instanceConfigs);

    for (int i = 0; i < NUM_ROUNDS; i++) {
        Map<String, List<String>> routingTable = routing
                .getRoutingTable(new RoutingTableLookupRequest(tableName));
        Assert.assertEquals(routingTable.size(), numServersInEV);
        int numSegments = 0;
        for (List<String> segmentsForServer : routingTable.values()) {
            int numSegmentsForServer = segmentsForServer.size();
            Assert.assertTrue(numSegmentsForServer >= MIN_NUM_SEGMENTS_PER_SERVER
                    && numSegmentsForServer <= MAX_NUM_SEGMENTS_PER_SERVER);
            numSegments += numSegmentsForServer;
        }
        Assert.assertEquals(numSegments, numSegmentsInEV);
    }
}

From source file:com.runwaysdk.configuration.CommonsConfigurationTest.java

@Test
public void testCommonsConfigOverride() {
    BaseConfiguration bc = new BaseConfiguration();
    BaseConfiguration bc2 = new BaseConfiguration();

    bc2.addProperty("test.prop", 52);

    CompositeConfiguration cconfig = new CompositeConfiguration();
    cconfig.addConfiguration(bc);/*w w  w. ja  v  a2 s.c o m*/
    cconfig.addConfiguration(bc2);

    bc.addProperty("test.prop", 112);

    Assert.assertEquals(112, cconfig.getInt("test.prop"));
}

From source file:co.turnus.trace.example.SimpleTraceExample.java

public TraceProject loadProject() {
    TurnusLogger.info("Load the causation trace");
    try {/*w w  w. ja  v a2s .co  m*/

        File dir = new File(SimpleTraceExample.class.getResource("/co/turnus/trace/example/").toURI());
        TraceProject project = TraceProject.load(dir);

        Configuration config = new BaseConfiguration();
        config.setProperty(SENS_STATEVAR, false);

        project.loadTrace(config);

        trace = project.getTrace();
        decorator = project.getTraceDecorator();

        return project;

    } catch (Exception e) {
        throw new TurnusRuntimeException("Error loading the trace file", e.getCause());
    }

}

From source file:com.comcast.viper.flume2storm.location.SimpleStaticLocationServiceTest.java

/**
 * Loads the {@link StaticLocationService} configuration file
 *//*from ww  w . ja v  a 2  s.com*/
@Before
public void init() {
    configuration = new BaseConfiguration();
    // List of service providers to load
    configuration.addProperty(SERVICE_PROVIDER_LIST, StringUtils.join(new String[] { SP1, SP2 }, " "));

    // First service provider
    configuration.addProperty(buildPName(SERVICE_PROVIDER_BASE_DEFAULT, SP1, HOSTNAME), CP1.getHostname());
    configuration.addProperty(buildPName(SERVICE_PROVIDER_BASE_DEFAULT, SP1, PORT), CP1.getPort());

    // Second service provider
    configuration.addProperty(buildPName(SERVICE_PROVIDER_BASE_DEFAULT, SP2, HOSTNAME), CP2.getHostname());
    configuration.addProperty(buildPName(SERVICE_PROVIDER_BASE_DEFAULT, SP2, PORT), CP2.getPort());

    // Third service provider
    configuration.addProperty(buildPName(SIMPLE_SERVICE_PROVIDER_BASE, SP3, HOSTNAME), CP3.getHostname());
    configuration.addProperty(buildPName(SIMPLE_SERVICE_PROVIDER_BASE, SP3, PORT), CP3.getPort());

    configuration.addProperty("some.other.variable", "whatever");
}