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.sink.StormSinkConfiguration.java

/**
 * Empty constructor - initializes with default values when available
 *//*  ww w.j a v  a2  s  . c  o  m*/
public StormSinkConfiguration() {
    batchSize = BATCH_SIZE_DEFAULT;
    locationServiceFactoryClassName = LOCATION_SERVICE_FACTORY_CLASS_DEFAULT;
    serviceProviderSerializationClassName = SERVICE_PROVIDER_SERIALIZATION_CLASS_DEFAULT;
    connectionParametersFactoryClassName = CONNECTION_PARAMETERS_FACTORY_CLASS_DEFAULT;
    eventSenderFactoryClassName = EVENT_SENDER_FACTORY_CLASS_DEFAULT;
    configuration = new BaseConfiguration();
}

From source file:co.turnus.analysis.profiler.orcc.dynamic.OrccDynamicProfilerOptions.java

public static Configuration getConfiguration(CommandLine cli) {
    try {//from  w  w w  . j  ava 2s  .c o  m
        Configuration conf = new BaseConfiguration();
        conf.setProperty(VERBOSE, cli.hasOption("v"));

        conf.setProperty(SIMULATOR_NAME, NAME);

        String stmp = cli.getOptionValue("p", "");
        conf.setProperty(ORCC_PROJECT, stmp);

        stmp = cli.getOptionValue("x", "");
        conf.setProperty(ORCC_XDF, stmp);

        Boolean btmp = cli.hasOption("i");
        if (btmp) {
            stmp = cli.getOptionValue("i", "");
            conf.setProperty(ORCC_SOURCE_USE, !stmp.isEmpty());
            conf.setProperty(ORCC_SOURCE_FILE, stmp);
        } else {
            conf.setProperty(ORCC_SOURCE_USE, false);
            conf.setProperty(ORCC_SOURCE_FILE, "");
        }

        btmp = cli.hasOption("t");
        if (btmp) {
            stmp = cli.getOptionValue("t", "");
            conf.setProperty(CREATE_TRACE_PROJECT, !stmp.isEmpty());
            conf.setProperty(TRACE_PROJECT_NAME, stmp);
        } else {
            conf.setProperty(CREATE_TRACE_PROJECT, false);
            conf.setProperty(TRACE_PROJECT_NAME, "");
        }

        btmp = cli.hasOption("stack-protector");
        conf.setProperty(STACK_PROTECTION, btmp);

        btmp = cli.hasOption("z");
        conf.setProperty(TRACE_COMPRESS, btmp);

        btmp = cli.hasOption("prof");
        conf.setProperty(EXPORT_PROFILING, btmp);

        stmp = cli.getOptionValue("versioner", GitVersioner.NAME);
        conf.setProperty(VERSIONER, stmp);

        stmp = cli.getOptionValue("scheduler", RoundRobinScheduler.NAME);
        conf.setProperty(ORCC_SCHEDULER, stmp);

        boolean resize[] = { false, false, false };
        if (cli.hasOption("resizer")) {
            String[] buff = cli.getOptionValues("resizer");
            for (int i = 0; i < resize.length; i++) {
                resize[i] = Boolean.parseBoolean(buff[i]);
            }
        }

        conf.setProperty(TYPE_RESIZE_NATIVEPORTS, resize[0]);
        conf.setProperty(TYPE_RESIZE_TO32BITS, resize[1]);
        conf.setProperty(TYPE_RESIZE_TONBITS, resize[2]);

        boolean transfo[] = { false, false, false, false, false, false };
        if (cli.hasOption("transfo")) {
            String[] buff = cli.getOptionValues("transfo");
            for (int i = 0; i < transfo.length; i++) {
                transfo[i] = Boolean.parseBoolean(buff[i]);
            }
        }
        conf.setProperty(TRANSFO_CONSTANTFOLDING, transfo[0]);
        conf.setProperty(TRANSFO_CONSTANTPROPAGATION, transfo[1]);
        conf.setProperty(TRANSFO_DEADACTIONS, transfo[2]);
        conf.setProperty(TRANSFO_EXPREVAL, transfo[3]);
        conf.setProperty(TRANSFO_DEADCODE, transfo[4]);
        conf.setProperty(TRANSFO_VARINIT, transfo[5]);

        int itmp = Integer.parseInt(cli.getOptionValue("b", "512"));
        conf.setProperty(FIFO_DEFAULT, itmp);

        // set the output path
        stmp = cli.getOptionValue("o", "");
        setOutputPath(conf, stmp);

        // set the gantt chart options
        btmp = cli.hasOption("gantt");
        conf.setProperty(EXPORT_GANTT, btmp);
        if (btmp) {
            stmp = conf.getString(OUTPUT_PATH);
            stmp = new File(stmp, "ganttChart." + TurnusExtension.VCD).getAbsolutePath();
            conf.setProperty(VCD_FILE, stmp);
        }

        return conf;

    } catch (Exception e) {
        throw new TurnusRuntimeException("Error parsing the launch configuration options", e);
    }
}

From source file:co.turnus.analysis.buffers.BoundedBufferSchedulingCliLauncher.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 {/*from   w ww .  j  a  v  a  2  s  . 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);
        }
    }

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

    boolean bitAccurate = cmd.hasOption("b");
    config.setProperty(BIT_ACCURATE, bitAccurate);

    boolean zeroStartingPoint = cmd.hasOption("z");
    config.setProperty(ZERO_STARTING_POINT, zeroStartingPoint);

    boolean quickCut = cmd.hasOption("q");
    config.setProperty(QUICK_CUT, quickCut);

    if (cmd.hasOption("s")) {
        String[] sArray = cmd.getOptionValues("s");
        if (sArray.length == 1) {
            int value = Integer.parseInt(sArray[0]);
            config.addProperty(TRACE_CUT_STEPS_MIN, value);
            config.addProperty(TRACE_CUT_STEPS_MAX, value);
            config.addProperty(TRACE_CUT_STEPS_NUM, 1);
        } else if (sArray.length == 2) {
            int min = Integer.parseInt(sArray[0]);
            int max = Integer.parseInt(sArray[1]);
            config.addProperty(TRACE_CUT_STEPS_MIN, min);
            config.addProperty(TRACE_CUT_STEPS_MAX, max);
            config.addProperty(TRACE_CUT_STEPS_NUM, max - min + 1);
        } else {
            int min = Integer.parseInt(sArray[0]);
            int points = Integer.parseInt(sArray[1]);
            int max = Integer.parseInt(sArray[2]);
            config.addProperty(TRACE_CUT_STEPS_MIN, min);
            config.addProperty(TRACE_CUT_STEPS_NUM, points);
            config.addProperty(TRACE_CUT_STEPS_MAX, max);
        }
    }

    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/*  w ww  .jav  a 2  s.  co  m*/
 * {@link StormSinkConfiguration#setLocationServiceFactoryClassName(String)}
 * 
 * @throws F2SConfigurationException
 *           If value is invalid
 */
@Test(expected = F2SConfigurationException.class)
public void testLocationServiceFactoryClassName3() throws F2SConfigurationException {
    Configuration config = new BaseConfiguration();
    config.addProperty(StormSinkConfiguration.LOCATION_SERVICE_FACTORY_CLASS, "not-a-class");
    StormSinkConfiguration.from(config);
}

From source file:com.comcast.viper.flume2storm.IntegrationTest.java

/**
 * @throws Exception/*from w w w . jav a  2 s  . c o  m*/
 *           If anything went wrong
 */
@Before
public void setup() throws Exception {
    config = new CombinedConfiguration();
    // Flume channel configuration
    BaseConfiguration channelConfig = new BaseConfiguration();
    channelConfig.addProperty("keep-alive", "1"); // Speeds up test
    channelConfig.addProperty("capacity", "" + NB_EVENTS);
    config.addConfiguration(channelConfig, CHANNEL_CONFIG);

    MemoryStorage.getInstance().clear();
}

From source file:cz.cas.lib.proarc.common.workflow.WorkflowManagerTest.java

@Test
public void testAddJob() throws Exception {
    IDataSet db = database(support.loadFlatXmlDataStream(EmpireWorkflowJobDaoTest.class, "user.xml"),
            emptyBatchSet(schema));/*from w ww  . ja  v  a 2  s  .c  om*/
    final IDatabaseConnection dbcon = support.getConnection();
    support.cleanInsert(dbcon, db);
    dbcon.getConnection().commit();
    dbcon.close();

    WorkflowManager wm = initWorkflowManager("WorkflowManagerAddProfile.xml");
    WorkflowDefinition workflow = wp.getProfiles();
    assertNotNull(workflow);
    JobDefinition jobProfile = workflow.getJobs().get(0);
    assertNotNull(jobProfile);
    CatalogConfiguration c = new CatalogConfiguration("testCatalogId", "", new BaseConfiguration() {
        {
            addProperty(CatalogConfiguration.PROPERTY_URL, "tcp://localhost:9991");
            addProperty(CatalogConfiguration.PROPERTY_NAME, "test");
            addProperty(CatalogConfiguration.PROPERTY_TYPE, Z3950Catalog.TYPE);
        }
    });
    String mods = IOUtils.toString(WorkflowManagerTest.class.getResource("rdczmods.xml"));
    Job job = wm.addJob(jobProfile, mods, c, null);
    assertNotNull(job);

    Job getJob = wm.getJob(job.getId());
    assertNotNull(getJob);

    JobFilter filter = new JobFilter();
    filter.setId(job.getId());
    Locale locale = new Locale("cs");
    filter.setLocale(locale);

    List<JobView> findJob = wm.findJob(filter);
    assertEquals(1, findJob.size());
    assertEquals("csTitle", findJob.get(0).getProfileLabel());

    TaskFilter taskFilter = new TaskFilter();
    taskFilter.setLocale(locale);
    taskFilter.setJobId(job.getId());
    List<TaskView> findTask = wm.tasks().findTask(taskFilter, workflow);
    assertEquals(2, findTask.size());
    assertEquals(job.getId(), findTask.get(0).getJobId());

    MaterialFilter materialFilter = new MaterialFilter();
    materialFilter.setJobId(job.getId());
    materialFilter.setLocale(locale);
    List<MaterialView> findMaterial = wm.findMaterial(materialFilter);
    assertEquals(2, findMaterial.size());

    TaskParameterFilter paramFilter = new TaskParameterFilter();
    paramFilter.setLocale(locale);
    paramFilter.setProfileName("param.id1");
    List<TaskParameterView> findParameter = wm.findParameter(paramFilter);
    assertEquals(2, findParameter.size());
    assertEquals("param.id1", findParameter.get(0).getParamRef());
    assertEquals("param.id1.value", findParameter.get(0).getValue());
    assertEquals(job.getId(), findParameter.get(0).getJobId());
    assertEquals("Param1", findParameter.get(0).getProfileLabel());
    // param.id2 comes just from the profile not db!
    assertEquals("param.id2", findParameter.get(1).getParamRef());
    assertNull(findParameter.get(1).getValue());
    assertEquals(job.getId(), findParameter.get(1).getJobId());
    assertEquals("param.id2", findParameter.get(1).getProfileLabel());
    assertEquals(findParameter.get(0).getTaskId(), findParameter.get(1).getTaskId());
    assertEquals("task.id1", findParameter.get(1).getTaskProfileName());
    assertEquals("proarc.devices", findParameter.get(1).getValueMapId());
    assertEquals(ValueMapSource.PROARC, findParameter.get(1).getValueMapType());
    assertEquals(Boolean.TRUE, findParameter.get(1).getRequired());
    assertEquals(ValueType.STRING, findParameter.get(1).getValueType());
}

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

@Test
public void testTimeBoundaryRegression() throws Exception {
    final FakePropertyStore propertyStore = new FakePropertyStore();
    final OfflineSegmentZKMetadata offlineSegmentZKMetadata = new OfflineSegmentZKMetadata();
    offlineSegmentZKMetadata.setTimeUnit(TimeUnit.DAYS);
    offlineSegmentZKMetadata.setEndTime(1234L);

    propertyStore.setContents(/*from  w w w .jav  a 2  s . c  o  m*/
            ZKMetadataProvider.constructPropertyStorePathForSegment("myTable_OFFLINE", "someSegment_0"),
            offlineSegmentZKMetadata.toZNRecord());

    final ExternalView offlineExternalView = new ExternalView("myTable_OFFLINE");
    offlineExternalView.setState("someSegment_0", "Server_1.2.3.4_1234", "ONLINE");

    final MutableBoolean timeBoundaryUpdated = new MutableBoolean(false);

    HelixExternalViewBasedRouting routingTable = new HelixExternalViewBasedRouting(propertyStore,
            NO_LLC_ROUTING, null, new BaseConfiguration()) {
        @Override
        protected ExternalView fetchExternalView(String table) {
            return offlineExternalView;
        }

        @Override
        protected void updateTimeBoundary(String tableName, ExternalView externalView) {
            if (tableName.equals("myTable_OFFLINE")) {
                timeBoundaryUpdated.setValue(true);
            }
        }
    };
    routingTable.setBrokerMetrics(new BrokerMetrics(new MetricsRegistry()));

    Assert.assertFalse(timeBoundaryUpdated.booleanValue());

    final ArrayList<InstanceConfig> instanceConfigList = new ArrayList<>();
    instanceConfigList.add(new InstanceConfig("Server_1.2.3.4_1234"));

    routingTable.markDataResourceOnline("myTable_OFFLINE", offlineExternalView, instanceConfigList);
    routingTable.markDataResourceOnline("myTable_REALTIME", new ExternalView("myTable_REALTIME"), null);

    Assert.assertTrue(timeBoundaryUpdated.booleanValue());
}

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

/**
 * Test invalid argument for//  w  ww  .  ja  v  a 2  s .  com
 * {@link FlumeSpoutConfiguration#setEventReceptorFactoryClassName(String)}
 * 
 * @throws F2SConfigurationException
 *           If value is invalid
 */
@Test(expected = F2SConfigurationException.class)
public void testEventReceptorFactoryClassName3() throws F2SConfigurationException {
    Configuration config = new BaseConfiguration();
    config.addProperty(FlumeSpoutConfiguration.EVENT_RECEPTOR_FACTORY_CLASS, "not-a-class");
    FlumeSpoutConfiguration.from(config);
}

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

/**
 * Open a BlazeGraphEmbedded (unisolated) instance wrapping the provided
 * SAIL repository with no additional configuration options.
 * /*www .jav  a2s  .com*/
 * @param repo
 *          an open and initialized repository
 * @return
 *          BlazeGraphEmbedded instance
 */
public static BlazeGraphEmbedded open(final BigdataSailRepository repo) {
    return open(repo, new BaseConfiguration());
}

From source file:edu.cornell.med.icb.goby.config.GobyConfiguration.java

/**
 * Any default configuration item values if required should defined here.
 *
 * @return The default configuration to use.
 *///from   ww  w.ja v a 2s .  c om
private Configuration getDefaultConfiguration() {
    final Configuration defaultConfiguration = new BaseConfiguration();
    defaultConfiguration.addProperty(EXECUTABLE_PATH_LASTAG, "");
    defaultConfiguration.addProperty(EXECUTABLE_PATH_LAST, "");
    defaultConfiguration.addProperty(EXECUTABLE_PATH_BWA, "");
    defaultConfiguration.addProperty(EXECUTABLE_PATH_GSNAP, "");
    defaultConfiguration.addProperty(DATABASE_DIRECTORY, ".");
    defaultConfiguration.addProperty(WORK_DIRECTORY, SystemUtils.getJavaIoTmpDir().toString());
    return defaultConfiguration;
}