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.connection.KryoNetParametersTest.java

@Test
public void testFromConfiguration() throws Exception {
    int connectionTo = TestUtils.getRandomPositiveInt(100000);
    int retrySleepDelay = TestUtils.getRandomPositiveInt(100000);
    int reconnectionDelay = TestUtils.getRandomPositiveInt(100000);
    int terminationTo = TestUtils.getRandomPositiveInt(100000);
    Configuration config = new BaseConfiguration();
    config.addProperty(KryoNetParameters.CONNECTION_TIMEOUT, connectionTo);
    config.addProperty(KryoNetParameters.RETRY_SLEEP_DELAY, retrySleepDelay);
    config.addProperty(KryoNetParameters.RECONNECTION_DELAY, reconnectionDelay);
    config.addProperty(KryoNetParameters.TERMINATION_TO, terminationTo);
    KryoNetParameters params = KryoNetParameters.from(config);
    Assert.assertEquals(connectionTo, params.getConnectionTimeout());
    Assert.assertEquals(retrySleepDelay, params.getRetrySleepDelay());
    Assert.assertEquals(reconnectionDelay, params.getReconnectionDelay());
    Assert.assertEquals(terminationTo, params.getTerminationTimeout());
}

From source file:fresto.Global.java

public static TitanGraph openGraph() {
    Configuration conf = new BaseConfiguration();
    //conf.setProperty("storage.backend", "cassandra"); 
    conf.setProperty("storage.backend", TITAN_STORAGE_BACKEND);
    conf.setProperty("storage.hostname", TITAN_STORAGE_HOSTNAME);
    // Default/*  w ww .ja  v a2  s.co  m*/
    //conf.setProperty("storage.connection-pool-size", 32); 
    g = TitanFactory.open(conf);
    return g;
}

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

/**
 * Test {@link FlumeSpoutConfiguration#from(Configuration)}
 *
 * @throws F2SConfigurationException/*from   w ww .  j a  v  a 2s  .c  o  m*/
 *           If the configuration is invalid
 */
@Test
public void testFromConfiguration() throws F2SConfigurationException {
    String locationServiceFactoryClassName = SimpleLocationServiceFactory.class.getCanonicalName();
    String serviceProviderSerializationClassName = SimpleServiceProviderSerialization.class.getCanonicalName();
    String eventReceptorFactoryClassName = SimpleEventReceptorFactory.class.getCanonicalName();
    Configuration config = new BaseConfiguration();
    config.addProperty(FlumeSpoutConfiguration.LOCATION_SERVICE_FACTORY_CLASS, locationServiceFactoryClassName);
    config.addProperty(FlumeSpoutConfiguration.SERVICE_PROVIDER_SERIALIZATION_CLASS,
            serviceProviderSerializationClassName);
    config.addProperty(FlumeSpoutConfiguration.EVENT_RECEPTOR_FACTORY_CLASS, eventReceptorFactoryClassName);

    FlumeSpoutConfiguration flumeSpoutConfiguration = FlumeSpoutConfiguration.from(config);
    Assert.assertEquals(locationServiceFactoryClassName,
            flumeSpoutConfiguration.getLocationServiceFactoryClassName());
    Assert.assertEquals(serviceProviderSerializationClassName,
            flumeSpoutConfiguration.getServiceProviderSerializationClassName());
    Assert.assertEquals(eventReceptorFactoryClassName,
            flumeSpoutConfiguration.getEventReceptorFactoryClassName());
}

From source file:co.turnus.generic.AbstractConfigurable.java

protected Configuration getConfiguration() {
    Configuration c = configuration != null ? configuration : new BaseConfiguration();
    return ConfigurationUtils.cloneConfiguration(c);
}

From source file:net.juniper.titan.controller.TitanController.java

private Configuration getTitanConf() {
    Configuration conf = new BaseConfiguration();
    conf.setProperty("index.search.backend", "elasticsearch");
    conf.setProperty("index.search.directory", "/tmp/searchindex");
    conf.setProperty("index.search.hostname", "127.0.0.1");
    conf.setProperty("index.search.client-only", "false");

    conf.setProperty("storage.backend", "cassandrathrift");
    conf.setProperty("storage.hostname", "10.81.53.213");
    conf.setProperty("cache.db-cache", true);
    conf.setProperty("cache.db-cache-clean-wait", 20);
    conf.setProperty("cache.db-cache-time", 180000);
    conf.setProperty("cache.db-cache-size", 0.25);
    conf.setProperty("index.search.backend", "elasticsearch");
    conf.setProperty("index.search.hostname", "10.81.53.213");
    conf.setProperty("index.search.directory", "/tmp/searchindex");
    conf.setProperty("index.search.elasticsearch.client-only", false);

    return conf;//from w  w w .  java  2s. com
}

From source file:com.linkedin.pinot.broker.routing.builder.KafkaLowLevelConsumerRoutingTableBuilderTest.java

@Test
public void testAllOnlineRoutingTable() {
    final int ITERATIONS = 50;
    Random random = new Random();

    KafkaLowLevelConsumerRoutingTableBuilder routingTableBuilder = new KafkaLowLevelConsumerRoutingTableBuilder();
    routingTableBuilder.init(new BaseConfiguration(), null, null);

    long totalNanos = 0L;

    for (int i = 0; i < ITERATIONS; i++) {
        int instanceCount = random.nextInt(12) + 3; // 3 to 14 instances
        int partitionCount = random.nextInt(8) + 4; // 4 to 11 partitions
        int replicationFactor = random.nextInt(3) + 3; // 3 to 5 replicas

        // Generate instances
        String[] instanceNames = new String[instanceCount];
        for (int serverInstanceId = 0; serverInstanceId < instanceCount; serverInstanceId++) {
            instanceNames[serverInstanceId] = "Server_localhost_" + serverInstanceId;
        }//from ww  w  .jav  a2 s .co  m

        // Generate partitions
        String[][] segmentNames = new String[partitionCount][];
        int totalSegmentCount = 0;
        for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
            int segmentCount = random.nextInt(32); // 0 to 31 segments in partition
            segmentNames[partitionId] = new String[segmentCount];
            for (int sequenceNumber = 0; sequenceNumber < segmentCount; sequenceNumber++) {
                segmentNames[partitionId][sequenceNumber] = new LLCSegmentName("table", partitionId,
                        sequenceNumber, System.currentTimeMillis()).getSegmentName();
            }
            totalSegmentCount += segmentCount;
        }

        // Generate instance configurations
        List<InstanceConfig> instanceConfigs = new ArrayList<InstanceConfig>();
        for (String instanceName : instanceNames) {
            InstanceConfig instanceConfig = new InstanceConfig(instanceName);
            instanceConfigs.add(instanceConfig);
            instanceConfig.getRecord().setSimpleField(CommonConstants.Helix.IS_SHUTDOWN_IN_PROGRESS, "false");
        }

        // Generate a random external view
        ExternalView externalView = new ExternalView("table_REALTIME");
        int[] segmentCountForInstance = new int[instanceCount];
        int maxSegmentCountOnInstance = 0;
        for (int partitionId = 0; partitionId < segmentNames.length; partitionId++) {
            String[] segments = segmentNames[partitionId];

            // Assign each segment for this partition
            for (int replicaId = 0; replicaId < replicationFactor; ++replicaId) {
                for (int segmentIndex = 0; segmentIndex < segments.length; segmentIndex++) {
                    int instanceIndex = -1;
                    int randomOffset = random.nextInt(instanceCount);

                    // Pick the first random instance that has fewer than maxSegmentCountOnInstance segments assigned to it
                    for (int j = 0; j < instanceCount; j++) {
                        int potentialInstanceIndex = (j + randomOffset) % instanceCount;
                        if (segmentCountForInstance[potentialInstanceIndex] < maxSegmentCountOnInstance) {
                            instanceIndex = potentialInstanceIndex;
                            break;
                        }
                    }

                    // All replicas have exactly maxSegmentCountOnInstance, pick a replica and increment the max
                    if (instanceIndex == -1) {
                        maxSegmentCountOnInstance++;
                        instanceIndex = randomOffset;
                    }

                    // Increment the segment count for the instance
                    segmentCountForInstance[instanceIndex]++;

                    // Add the segment to the external view
                    externalView.setState(segmentNames[partitionId][segmentIndex], instanceNames[instanceIndex],
                            "ONLINE");
                }
            }
        }

        // Create routing tables
        long startTime = System.nanoTime();
        routingTableBuilder.computeRoutingTableFromExternalView("table_REALTIME", externalView,
                instanceConfigs);

        List<Map<String, List<String>>> routingTables = routingTableBuilder.getRoutingTables();

        long endTime = System.nanoTime();
        totalNanos += endTime - startTime;

        // Check that all routing tables generated match all segments, with no duplicates
        for (Map<String, List<String>> routingTable : routingTables) {
            Set<String> assignedSegments = new HashSet<>();

            for (List<String> segmentsForServer : routingTable.values()) {
                for (String segment : segmentsForServer) {
                    assertFalse(assignedSegments.contains(segment));
                    assignedSegments.add(segment);
                }
            }

            assertEquals(assignedSegments.size(), totalSegmentCount);
        }
    }

    LOGGER.warn("Routing table building avg ms: " + totalNanos / (ITERATIONS * 1000000.0));
}

From source file:com.echosource.ada.rules.AdaProfileExporter.java

/**
 * for unit tests
 */
AdaProfileExporter() {
    this(new BaseConfiguration());
}

From source file:com.feedzai.fos.impl.weka.WekaManagerTest.java

private WekaManagerConfig setupWekaConfig(String headerLocation) {
    BaseConfiguration configuration = new BaseConfiguration();
    configuration.setProperty(GenericObjectPoolConfig.class.getName() + ".minIdle", 10);
    configuration.setProperty(GenericObjectPoolConfig.class.getName() + ".maxActive", 10);
    configuration.setProperty(FosConfig.HEADER_LOCATION, headerLocation);
    configuration.setProperty(FosConfig.FACTORY_NAME, WekaManagerFactory.class.getName());
    return new WekaManagerConfig(new FosConfig(configuration));
}

From source file:cz.cas.lib.proarc.common.export.Kramerius4ExportOptionsTest.java

@Test
public void testFromEmpyConfig() {
    Configuration config = new BaseConfiguration();
    Kramerius4ExportOptions result = Kramerius4ExportOptions.from(config);
    assertTrue(result.getExcludeDatastreams().isEmpty());
    assertEquals(1, result.getDsIdMap().size());
    assertEquals("IMG_FULL", result.getDsIdMap().get(BinaryEditor.RAW_ID));
    assertNull(result.getPolicy());/*from w w  w . j a v a2 s.  c o  m*/
}

From source file:com.dattack.naming.standalone.StandaloneContextFactory.java

private static CompositeConfiguration getConfiguration(final Map<?, ?> environment) {

    final BaseConfiguration baseConf = new BaseConfiguration();
    for (final Entry<?, ?> entry : environment.entrySet()) {
        baseConf.setProperty(ObjectUtils.toString(entry.getKey()), entry.getValue());
    }/*from  ww  w  .ja  v a2s  .com*/

    final CompositeConfiguration configuration = new CompositeConfiguration();
    configuration.addConfiguration(new SystemConfiguration());
    configuration.addConfiguration(new EnvironmentConfiguration());
    configuration.addConfiguration(baseConf);
    return configuration;
}