Example usage for org.apache.commons.configuration Configuration containsKey

List of usage examples for org.apache.commons.configuration Configuration containsKey

Introduction

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

Prototype

boolean containsKey(String key);

Source Link

Document

Check if the configuration contains the specified key.

Usage

From source file:net.sf.maltcms.chromaui.project.spi.project.ChromAUIProject.java

protected synchronized String getSetting(String key) {
    Configuration ps = getSettings();
    if (ps.containsKey(key)) {
        return ps.getString(key);
    }/*  w  w  w.j a v a  2 s . c om*/
    return null;
}

From source file:net.sf.maltcms.chromaui.project.spi.project.ChromAUIProject.java

@Override
public UUID getId() {
    Configuration settings = getSettings();
    if (settings.containsKey(ProjectSettings.KEY_UID)) {
        return UUID.fromString((String) settings.getString(ProjectSettings.KEY_UID));
    } else {//from  ww  w  . ja v a 2  s  .c om
        UUID uid = UUID.randomUUID();
        settings.setProperty(ProjectSettings.KEY_UID, uid.toString());
        return uid;
    }
}

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

/**
 * Get a List of objects associated with the given configuration key.
 * If the key doesn't map to an existing object, the default value
 * is returned.//from   w  w w.jav a2  s .co  m
 *
 * @param key The configuration key.
 * @param defaultValue The default value.
 * @return The associated List of value.
 * 
 */
@Override
public List getList(String key, List defaultValue) {
    List<Object> list = new ArrayList<Object>();

    // add all elements from the first configuration containing the requested key
    Iterator<AbstractConfiguration> it = configList.iterator();
    if (overrideProperties.containsKey(key)) {
        appendListProperty(list, overrideProperties, key);
    }
    while (it.hasNext() && list.isEmpty()) {
        Configuration config = it.next();
        if ((config != containerConfiguration || containerConfigurationChanged) && config.containsKey(key)) {
            appendListProperty(list, config, key);
        }
    }

    // add all elements from the in memory configuration
    if (list.isEmpty()) {
        appendListProperty(list, containerConfiguration, key);
    }

    if (list.isEmpty()) {
        return defaultValue;
    }

    ListIterator<Object> lit = list.listIterator();
    while (lit.hasNext()) {
        lit.set(interpolate(lit.next()));
    }

    return list;
}

From source file:es.udc.gii.common.eaf.algorithm.parallel.evaluation.DistributedEvaluation.java

/**
 * Configures this class.<p>//from  www .ja v a  2s.c  om
 *
 * Configuration example:<p>
 *
 * <pre>
 *    ...
 *    &lt;EvaluationStrategy&gt;
 *       &lt;Class&gt;es.udc.gii.common.eaf.algorithm.parallel.evaluation.DistributedEvaluation&lt;Class&gt;
 *       &lt;ChunkSize&gt;3&lt;/ChunkSize&gt;
 *       &lt;Races&gt;2&lt;/Races&gt;
 *       &lt;CollectStatistics/&gt;
 *    &lt;/EvaluationStrategy&gt;     
 *    ...
 * </pre><p>
 *
 * This configures a master-slave model with 2 masters (races). The master
 * sends 3 individuals each time a slave asks for individuals (chunk size).
 * Statistics about the whole process are collected (<code>CollectStatistics</code>). <p>
 * 
 * If <code>ChunkSize</code> is set to 0, then a chunk is choosen so that:
 * let S be the size of the population to be evaluated, let n be the number
 * of proceses (master and slaves), then the chunk size will be S/n
 * (integer division).
 *
 * @param conf Configuration.
 */
@Override
public void configure(Configuration conf) {
    evaluationStrategy = new SerialEvaluationStrategy();
    evaluationStrategy.configure(conf);

    topology = new EvaluationTopology();
    if (conf.containsKey("Races")) {
        topology.setRaces(conf.getInt("Races"));
    } else {
        topology.setRaces(1); // all nodes
    }
    topology.initialize();

    setChunkSize(conf.getInt("ChunkSize"));
    setCollectStatistics(conf.containsKey("CollectStatistics"));

    this.chunkIndex = new int[getTopology().getSize()];
}

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

public HelixExternalViewBasedRouting(ZkHelixPropertyStore<ZNRecord> propertyStore,
        RoutingTableSelector routingTableSelector, HelixManager helixManager, Configuration configuration) {
    _timeBoundaryService = new HelixExternalViewBasedTimeBoundaryService(propertyStore);
    _largeClusterRoutingTableBuilder = new LargeClusterRoutingTableBuilder();
    _smallClusterRoutingTableBuilder = new BalancedRandomRoutingTableBuilder();
    _realtimeHLCRoutingTableBuilder = new KafkaHighLevelConsumerBasedRoutingTableBuilder();
    _realtimeLLCRoutingTableBuilder = new KafkaLowLevelConsumerRoutingTableBuilder();

    if (configuration.containsKey("minServerCountForLargeCluster")) {
        final String minServerCountForLargeCluster = configuration.getString("minServerCountForLargeCluster");
        try {/*  w w w.java 2s  . c o m*/
            MIN_SERVER_COUNT_FOR_LARGE_CLUSTER = Integer.parseInt(minServerCountForLargeCluster);
            LOGGER.info("Using large cluster min server count of {}", MIN_SERVER_COUNT_FOR_LARGE_CLUSTER);
        } catch (Exception e) {
            LOGGER.warn(
                    "Could not get the large cluster min server count from configuration value {}, keeping default value {}",
                    minServerCountForLargeCluster, MIN_SERVER_COUNT_FOR_LARGE_CLUSTER, e);
        }
    } else {
        LOGGER.info("Using default value for large cluster min server count of {}",
                MIN_SERVER_COUNT_FOR_LARGE_CLUSTER);
    }

    if (configuration.containsKey("minReplicaCountForLargeCluster")) {
        final String minReplicaCountForLargeCluster = configuration.getString("minReplicaCountForLargeCluster");
        try {
            MIN_REPLICA_COUNT_FOR_LARGE_CLUSTER = Integer.parseInt(minReplicaCountForLargeCluster);
            LOGGER.info("Using large cluster min replica count of {}", MIN_REPLICA_COUNT_FOR_LARGE_CLUSTER);
        } catch (Exception e) {
            LOGGER.warn(
                    "Could not get the large cluster min replica count from configuration value {}, keeping default value {}",
                    minReplicaCountForLargeCluster, MIN_REPLICA_COUNT_FOR_LARGE_CLUSTER, e);
        }
    } else {
        LOGGER.info("Using default value for large cluster min replica count of {}",
                MIN_REPLICA_COUNT_FOR_LARGE_CLUSTER);
    }

    _largeClusterRoutingTableBuilder.init(configuration);
    _smallClusterRoutingTableBuilder.init(configuration);
    _realtimeHLCRoutingTableBuilder.init(configuration);
    _realtimeLLCRoutingTableBuilder.init(configuration);

    _routingTableSelector = routingTableSelector;
    _helixManager = helixManager;
}

From source file:com.evolveum.midpoint.task.quartzimpl.TaskManagerConfiguration.java

void setBasicInformation(MidpointConfiguration masterConfig) throws TaskManagerConfigurationException {
    Configuration c = masterConfig.getConfiguration(TASK_MANAGER_CONFIG_SECTION);

    stopOnInitializationFailure = c.getBoolean(STOP_ON_INITIALIZATION_FAILURE_CONFIG_ENTRY,
            STOP_ON_INITIALIZATION_FAILURE_DEFAULT);

    threads = c.getInt(THREADS_CONFIG_ENTRY, THREADS_DEFAULT);
    clustered = c.getBoolean(CLUSTERED_CONFIG_ENTRY, CLUSTERED_DEFAULT);
    jdbcJobStore = c.getBoolean(JDBC_JOB_STORE_CONFIG_ENTRY, clustered);

    nodeId = System.getProperty(MIDPOINT_NODE_ID_PROPERTY);
    if (StringUtils.isEmpty(nodeId) && !clustered) {
        nodeId = NODE_ID_DEFAULT;/*from   www  .  j av  a2  s .c  om*/
    }

    jmxHostName = System.getProperty(MIDPOINT_JMX_HOST_NAME_PROPERTY);

    String portString = System.getProperty(JMX_PORT_PROPERTY);
    if (StringUtils.isEmpty(portString)) {
        jmxPort = JMX_PORT_DEFAULT;
    } else {
        try {
            jmxPort = Integer.parseInt(portString);
        } catch (NumberFormatException nfe) {
            throw new TaskManagerConfigurationException(
                    "Cannot get JMX management port - invalid integer value of " + portString, nfe);
        }
    }

    jmxConnectTimeout = c.getInt(JMX_CONNECT_TIMEOUT_CONFIG_ENTRY, JMX_CONNECT_TIMEOUT_DEFAULT);

    if (c.containsKey(TEST_MODE_CONFIG_ENTRY)) {
        midPointTestMode = c.getBoolean(TEST_MODE_CONFIG_ENTRY);
        LOGGER.trace(TEST_MODE_CONFIG_ENTRY + " present, its value = " + midPointTestMode);
    } else {
        LOGGER.trace(TEST_MODE_CONFIG_ENTRY + " NOT present");
        Properties sp = System.getProperties();
        if (sp.containsKey(SUREFIRE_PRESENCE_PROPERTY)) {
            LOGGER.info("Determined to run in a test environment, setting midPointTestMode to 'true'.");
            midPointTestMode = true;
        } else {
            midPointTestMode = false;
        }
    }
    LOGGER.trace("midPointTestMode = " + midPointTestMode);

    String useTI = c.getString(USE_THREAD_INTERRUPT_CONFIG_ENTRY, USE_THREAD_INTERRUPT_DEFAULT);
    try {
        useThreadInterrupt = UseThreadInterrupt.fromValue(useTI);
    } catch (IllegalArgumentException e) {
        throw new TaskManagerConfigurationException(
                "Illegal value for " + USE_THREAD_INTERRUPT_CONFIG_ENTRY + ": " + useTI, e);
    }

    quartzNodeRegistrationCycleTime = c.getInt(QUARTZ_NODE_REGISTRATION_INTERVAL_CONFIG_ENTRY,
            QUARTZ_NODE_REGISTRATION_CYCLE_TIME_DEFAULT);
    nodeRegistrationCycleTime = c.getInt(NODE_REGISTRATION_INTERVAL_CONFIG_ENTRY,
            NODE_REGISTRATION_CYCLE_TIME_DEFAULT);
    nodeTimeout = c.getInt(NODE_TIMEOUT_CONFIG_ENTRY, NODE_TIMEOUT_DEFAULT);

    jmxUsername = c.getString(JMX_USERNAME_CONFIG_ENTRY, JMX_USERNAME_DEFAULT);
    jmxPassword = c.getString(JMX_PASSWORD_CONFIG_ENTRY, JMX_PASSWORD_DEFAULT);

    waitingTasksCheckInterval = c.getInt(WAITING_TASKS_CHECK_INTERVAL_CONFIG_ENTRY,
            WAITING_TASKS_CHECK_INTERVAL_DEFAULT);
    stalledTasksCheckInterval = c.getInt(STALLED_TASKS_CHECK_INTERVAL_CONFIG_ENTRY,
            STALLED_TASKS_CHECK_INTERVAL_DEFAULT);
    stalledTasksThreshold = c.getInt(STALLED_TASKS_THRESHOLD_CONFIG_ENTRY, STALLED_TASKS_THRESHOLD_DEFAULT);
    stalledTasksRepeatedNotificationInterval = c.getInt(
            STALLED_TASKS_REPEATED_NOTIFICATION_INTERVAL_CONFIG_ENTRY,
            STALLED_TASKS_REPEATED_NOTIFICATION_INTERVAL_DEFAULT);
    runNowKeepsOriginalSchedule = c.getBoolean(RUN_NOW_KEEPS_ORIGINAL_SCHEDULE_CONFIG_ENTRY,
            RUN_NOW_KEEPS_ORIGINAL_SCHEDULE_DEFAULT);
}

From source file:edu.berkeley.sparrow.examples.HeterogeneousFrontend.java

public void run(String[] args) {
    try {/* www. j a va  2s . co m*/
        OptionParser parser = new OptionParser();
        parser.accepts("c", "configuration file").withRequiredArg().ofType(String.class);
        parser.accepts("help", "print help statement");
        OptionSet options = parser.parse(args);

        if (options.has("help")) {
            parser.printHelpOn(System.out);
            System.exit(-1);
        }

        // Logger configuration: log to the console
        BasicConfigurator.configure();
        LOG.setLevel(Level.DEBUG);

        Configuration conf = new PropertiesConfiguration();

        if (options.has("c")) {
            String configFile = (String) options.valueOf("c");
            conf = new PropertiesConfiguration(configFile);
        }

        double warmupLambda = conf.getDouble("warmup_job_arrival_rate_s", DEFAULT_WARMUP_JOB_ARRIVAL_RATE_S);
        int warmupDurationS = conf.getInt("warmup_s", DEFAULT_WARMUP_S);
        int postWarmupS = conf.getInt("post_warmup_s", DEFAULT_POST_WARMUP_S);

        double lambda = conf.getDouble("job_arrival_rate_s", DEFAULT_JOB_ARRIVAL_RATE_S);
        int experimentDurationS = conf.getInt("experiment_s", DEFAULT_EXPERIMENT_S);
        LOG.debug("Using arrival rate of  " + lambda + " tasks per second and running experiment for "
                + experimentDurationS + " seconds.");
        int tasksPerJob = conf.getInt("tasks_per_job", DEFAULT_TASKS_PER_JOB);
        int numPreferredNodes = conf.getInt("num_preferred_nodes", DEFAULT_NUM_PREFERRED_NODES);
        LOG.debug("Using " + numPreferredNodes + " preferred nodes for each task.");
        int benchmarkIterations = conf.getInt("benchmark.iterations", DEFAULT_BENCHMARK_ITERATIONS);
        int benchmarkId = conf.getInt("benchmark.id", DEFAULT_TASK_BENCHMARK);

        List<String> backends = new ArrayList<String>();
        if (numPreferredNodes > 0) {
            /* Attempt to parse the list of slaves, which we'll need to (randomly) select preferred
             * nodes. */
            if (!conf.containsKey(BACKENDS)) {
                LOG.fatal("Missing configuration backend list, which is needed to randomly select "
                        + "preferred nodes (num_preferred_nodes set to " + numPreferredNodes + ")");
            }
            for (String node : conf.getStringArray(BACKENDS)) {
                backends.add(node);
            }
            if (backends.size() < numPreferredNodes) {
                LOG.fatal("Number of backends smaller than number of preferred nodes!");
            }
        }

        List<UserInfo> users = new ArrayList<UserInfo>();
        if (conf.containsKey(USERS)) {
            for (String userSpecification : conf.getStringArray(USERS)) {
                LOG.debug("Reading user specification: " + userSpecification);
                String[] parts = userSpecification.split(":");
                if (parts.length != 3) {
                    LOG.error("Unexpected user specification string: " + userSpecification + "; ignoring user");
                    continue;
                }
                users.add(new UserInfo(parts[0], Integer.parseInt(parts[1]), Integer.parseInt(parts[2])));
            }
        }
        if (users.size() == 0) {
            // Add a dummy user.
            users.add(new UserInfo("defaultUser", 1, 0));
        }

        SparrowFrontendClient client = new SparrowFrontendClient();
        int schedulerPort = conf.getInt("scheduler_port", SchedulerThrift.DEFAULT_SCHEDULER_THRIFT_PORT);
        client.initialize(new InetSocketAddress("localhost", schedulerPort), APPLICATION_ID, this);

        if (warmupDurationS > 0) {
            LOG.debug("Warming up for " + warmupDurationS + " seconds at arrival rate of " + warmupLambda
                    + " jobs per second");
            launchTasks(users, warmupLambda, warmupDurationS, tasksPerJob, numPreferredNodes,
                    benchmarkIterations, benchmarkId, backends, client);
            LOG.debug("Waiting for queues to drain after warmup (waiting " + postWarmupS + " seconds)");
            Thread.sleep(postWarmupS * 1000);
        }
        LOG.debug("Launching experiment for " + experimentDurationS + " seconds");
        launchTasks(users, lambda, experimentDurationS, tasksPerJob, numPreferredNodes, benchmarkIterations,
                benchmarkId, backends, client);
    } catch (Exception e) {
        LOG.error("Fatal exception", e);
    }
}

From source file:edu.berkeley.sparrow.examples.FairnessTestingFrontend.java

public void run(String[] args) {
    try {/* w ww.  j  ava 2  s. c o m*/
        OptionParser parser = new OptionParser();
        parser.accepts("c", "configuration file").withRequiredArg().ofType(String.class);
        parser.accepts("help", "print help statement");
        OptionSet options = parser.parse(args);

        if (options.has("help")) {
            parser.printHelpOn(System.out);
            System.exit(-1);
        }

        // Logger configuration: log to the console
        BasicConfigurator.configure();
        LOG.setLevel(Level.DEBUG);

        Configuration conf = new PropertiesConfiguration();

        if (options.has("c")) {
            String configFile = (String) options.valueOf("c");
            conf = new PropertiesConfiguration(configFile);
        }

        double warmup_lambda = conf.getDouble("warmup_job_arrival_rate_s", DEFAULT_WARMUP_JOB_ARRIVAL_RATE_S);
        int warmup_duration_s = conf.getInt("warmup_s", DEFAULT_WARMUP_S);
        int post_warmup_s = conf.getInt("post_warmup_s", DEFAULT_POST_WARMUP_S);

        // We use this to represent the the rate to fully load the cluster. This is a hack.
        double lambda = conf.getDouble("job_arrival_rate_s", DEFAULT_JOB_ARRIVAL_RATE_S);
        int experiment_duration_s = conf.getInt("experiment_s", DEFAULT_EXPERIMENT_S);
        LOG.debug("Using arrival rate of  " + lambda + " tasks per second and running experiment for "
                + experiment_duration_s + " seconds.");
        int tasksPerJob = conf.getInt("tasks_per_job", DEFAULT_TASKS_PER_JOB);
        int numPreferredNodes = conf.getInt("num_preferred_nodes", DEFAULT_NUM_PREFERRED_NODES);
        LOG.debug("Using " + numPreferredNodes + " preferred nodes for each task.");
        int benchmarkIterations = conf.getInt("benchmark.iterations", DEFAULT_BENCHMARK_ITERATIONS);
        int benchmarkId = conf.getInt("benchmark.id", DEFAULT_TASK_BENCHMARK);

        List<String> backends = new ArrayList<String>();
        if (numPreferredNodes > 0) {
            /* Attempt to parse the list of slaves, which we'll need to (randomly) select preferred
             * nodes. */
            if (!conf.containsKey(BACKENDS)) {
                LOG.fatal("Missing configuration backend list, which is needed to randomly select "
                        + "preferred nodes (num_preferred_nodes set to " + numPreferredNodes + ")");
            }
            for (String node : conf.getStringArray(BACKENDS)) {
                backends.add(node);
            }
            if (backends.size() < numPreferredNodes) {
                LOG.fatal("Number of backends smaller than number of preferred nodes!");
            }
        }

        List<SubExperiment> experiments = new ArrayList<SubExperiment>();
        double fullyUtilizedArrivalRate = lambda;

        // For the first twenty seconds, the first user submits at a rate to fully utilize the cluster.
        List<UserInfo> onlyUser0 = new ArrayList<UserInfo>();
        onlyUser0.add(new UserInfo("user0", 1, 0));
        experiments.add(new SubExperiment(onlyUser0, 20, fullyUtilizedArrivalRate));

        // For the next 10 seconds, user1 increases her rate to 25% of the cluster.
        List<UserInfo> user1QuarterDemand = new ArrayList<UserInfo>();
        user1QuarterDemand.add(new UserInfo("user0", 4, 0));
        user1QuarterDemand.add(new UserInfo("user1", 5, 0));
        experiments.add(new SubExperiment(user1QuarterDemand, 10, 1.25 * fullyUtilizedArrivalRate));

        // For the next 10 seconds, user 1 increases her rate to 50% of the cluster (using exactly
        // her share, but no more).
        List<UserInfo> user1HalfDemand = new ArrayList<UserInfo>();
        user1HalfDemand.add(new UserInfo("user0", 2, 0));
        user1HalfDemand.add(new UserInfo("user1", 3, 0));
        experiments.add(new SubExperiment(user1HalfDemand, 10, 1.5 * fullyUtilizedArrivalRate));

        // Next user 1 goes back down to 25%.
        experiments.add(new SubExperiment(user1QuarterDemand, 10, 1.25 * fullyUtilizedArrivalRate));

        // Finally user 1 goes back to 0.
        experiments.add(new SubExperiment(onlyUser0, 20, fullyUtilizedArrivalRate));

        SparrowFrontendClient client = new SparrowFrontendClient();
        int schedulerPort = conf.getInt("scheduler_port", SchedulerThrift.DEFAULT_SCHEDULER_THRIFT_PORT);
        client.initialize(new InetSocketAddress("localhost", schedulerPort), APPLICATION_ID, this);

        if (warmup_duration_s > 0) {
            List<SubExperiment> warmupExperiment = new ArrayList<SubExperiment>();
            List<UserInfo> warmupUsers = new ArrayList<UserInfo>();
            warmupUsers.add(new UserInfo("warmupUser", 1, 0));
            warmupExperiment.add(new SubExperiment(warmupUsers, warmup_duration_s, warmup_lambda));
            LOG.debug("Warming up for " + warmup_duration_s + " seconds at arrival rate of " + warmup_lambda
                    + " jobs per second");
            launchTasks(warmupExperiment, tasksPerJob, numPreferredNodes, benchmarkIterations, benchmarkId,
                    backends, client);
            LOG.debug("Waiting for queues to drain after warmup (waiting " + post_warmup_s + " seconds)");
            Thread.sleep(post_warmup_s * 1000);
        }
        LOG.debug("Launching experiment for " + experiment_duration_s + " seconds");
        launchTasks(experiments, tasksPerJob, numPreferredNodes, benchmarkIterations, benchmarkId, backends,
                client);
    } catch (Exception e) {
        LOG.error("Fatal exception", e);
    }
}

From source file:cross.Factory.java

/**
 * Write current configuration to file./*from   w  ww .  jav  a2 s  . c  om*/
 *
 * @param filename the filename to use
 * @param d the date stamp to use
 */
@Override
public void dumpConfig(final String filename, final Date d) {
    //retrieve global, joint configuration
    final Configuration cfg = getConfiguration();
    //retrieve pipeline.properties location
    String configFile = cfg.getString("pipeline.properties");
    if (configFile != null) {
        final File pipelinePropertiesFile = new File(configFile);
        //resolve and retrieve pipeline.xml location
        final File pipelineXml;
        try {
            File configBasedir = pipelinePropertiesFile.getParentFile();
            String pipelineLocation = cfg.getString("pipeline.xml").replace("config.basedir",
                    configBasedir.getAbsolutePath());
            pipelineLocation = pipelineLocation.substring("file:".length());
            pipelineXml = new File(pipelineLocation);
            //setup output location
            final File location = new File(FileTools.prependDefaultDirsWithPrefix("", Factory.class, d),
                    filename);
            //location for pipeline.properties dump
            final File pipelinePropertiesFileDump = new File(location.getParentFile(),
                    pipelinePropertiesFile.getName());

            PropertiesConfiguration pipelineProperties = new PropertiesConfiguration(pipelinePropertiesFile);
            PropertiesConfiguration newPipelineProperties = new PropertiesConfiguration(
                    pipelinePropertiesFileDump);
            //copy configuration to dump configuration
            newPipelineProperties.copy(pipelineProperties);
            //correct pipeline.xml location
            newPipelineProperties.setProperty("pipeline.xml",
                    "file:${config.basedir}/" + pipelineXml.getName());
            newPipelineProperties.save();
            //copy pipeline.xml to dump location
            FileUtils.copyFile(pipelineXml, new File(location.getParentFile(), pipelineXml.getName()));
            if (cfg.containsKey("configLocation")) {
                File configLocation = new File(URI.create(cfg.getString("configLocation")));
                File configLocationNew = new File(location.getParentFile(), configLocation.getName());
                FileUtils.copyFile(configLocation, configLocationNew);
            }
            LoggerFactory.getLogger(Factory.class).error("Saving configuration to: ");
            LoggerFactory.getLogger(Factory.class).error("{}", location.getAbsolutePath());
            saveConfiguration(cfg, location);
        } catch (IOException | ConfigurationException ex) {
            LoggerFactory.getLogger(Factory.class).error("{}", ex);
            //            } catch (URISyntaxException ex) {
            //                Factory.getInstance().log.error("{}", ex);
        }
    } else {
        LoggerFactory.getLogger(Factory.class)
                .warn("Can not save configuration, no pipeline properties file given!");
    }
}

From source file:com.cisco.oss.foundation.http.AbstractHttpClient.java

private InternalServerProxyMetadata loadServersMetadataConfiguration() {

    Configuration subset = configuration.subset(apiName);
    final Iterator<String> keysIterator = subset.getKeys();

    // read default values
    int readTimeout = subset.getInt("http." + LoadBalancerConstants.READ_TIME_OUT,
            LoadBalancerConstants.DEFAULT_READ_TIMEOUT);
    int connectTimeout = subset.getInt("http." + LoadBalancerConstants.CONNECT_TIME_OUT,
            LoadBalancerConstants.DEFAULT_CONNECT_TIMEOUT);
    long waitingTime = subset.getLong("http." + LoadBalancerConstants.WAITING_TIME,
            LoadBalancerConstants.DEFAULT_WAITING_TIME);
    int numberOfAttempts = subset.getInt("http." + LoadBalancerConstants.NUMBER_OF_ATTEMPTS,
            LoadBalancerConstants.DEFAULT_NUMBER_OF_ATTEMPTS);
    long retryDelay = subset.getLong("http." + LoadBalancerConstants.RETRY_DELAY,
            LoadBalancerConstants.DEFAULT_RETRY_DELAY);

    long idleTimeout = subset.getLong("http." + LoadBalancerConstants.IDLE_TIME_OUT,
            LoadBalancerConstants.DEFAULT_IDLE_TIMEOUT);
    int maxConnectionsPerAddress = subset.getInt("http." + LoadBalancerConstants.MAX_CONNECTIONS_PER_ADDRESS,
            LoadBalancerConstants.DEFAULT_MAX_CONNECTIONS_PER_ADDRESS);
    int maxConnectionsTotal = subset.getInt("http." + LoadBalancerConstants.MAX_CONNECTIONS_TOTAL,
            LoadBalancerConstants.DEFAULT_MAX_CONNECTIONS_TOTAL);
    int maxQueueSizePerAddress = subset.getInt("http." + LoadBalancerConstants.MAX_QUEUE_PER_ADDRESS,
            LoadBalancerConstants.DEFAULT_MAX_QUEUE_PER_ADDRESS);
    boolean followRedirects = subset.getBoolean("http." + LoadBalancerConstants.FOLLOW_REDIRECTS, false);
    boolean disableCookies = subset.getBoolean("http." + LoadBalancerConstants.DISABLE_COOKIES, false);
    boolean autoCloseable = subset.getBoolean("http." + LoadBalancerConstants.AUTO_CLOSEABLE, true);
    boolean autoEncodeUri = subset.getBoolean("http." + LoadBalancerConstants.AUTO_ENCODE_URI, true);
    boolean staleConnectionCheckEnabled = subset
            .getBoolean("http." + LoadBalancerConstants.IS_STALE_CONN_CHECK_ENABLED, false);
    boolean serviceDirectoryEnabled = subset
            .getBoolean("http." + LoadBalancerConstants.SERVICE_DIRECTORY_IS_ENABLED, false);
    String serviceName = subset.getString("http." + LoadBalancerConstants.SERVICE_DIRECTORY_SERVICE_NAME,
            "UNKNOWN");

    String keyStorePath = subset.getString("http." + LoadBalancerConstants.KEYSTORE_PATH, "");
    String keyStorePassword = subset.getString("http." + LoadBalancerConstants.KEYSTORE_PASSWORD, "");
    String trustStorePath = subset.getString("http." + LoadBalancerConstants.TRUSTSTORE_PATH, "");
    String trustStorePassword = subset.getString("http." + LoadBalancerConstants.TRUSTSTORE_PASSWORD, "");

    final List<String> keys = new ArrayList<String>();

    while (keysIterator.hasNext()) {
        String key = keysIterator.next();
        keys.add(key);//from  ww w. j  a v  a2  s . c om
    }

    Collections.sort(keys);

    List<Pair<String, Integer>> hostAndPortPairs = new CopyOnWriteArrayList<Pair<String, Integer>>();

    for (String key : keys) {

        if (key.contains(LoadBalancerConstants.HOST)) {

            String host = subset.getString(key);

            // trim the host name
            if (StringUtils.isNotEmpty(host)) {
                host = host.trim();
            }
            final String portKey = key.replace(LoadBalancerConstants.HOST, LoadBalancerConstants.PORT);
            if (subset.containsKey(portKey)) {
                int port = subset.getInt(portKey);
                // save host and port for future creation of server list
                hostAndPortPairs.add(Pair.of(host, port));
            }
        }

    }

    InternalServerProxyMetadata metadata = new InternalServerProxyMetadata(readTimeout, connectTimeout,
            idleTimeout, maxConnectionsPerAddress, maxConnectionsTotal, maxQueueSizePerAddress, waitingTime,
            numberOfAttempts, retryDelay, hostAndPortPairs, keyStorePath, keyStorePassword, trustStorePath,
            trustStorePassword, followRedirects, autoCloseable, staleConnectionCheckEnabled, disableCookies,
            serviceDirectoryEnabled, serviceName, autoEncodeUri);
    //        metadata.getHostAndPortPairs().addAll(hostAndPortPairs);
    //        metadata.setReadTimeout(readTimeout);
    //        metadata.setConnectTimeout(connectTimeout);
    //        metadata.setNumberOfRetries(numberOfAttempts);
    //        metadata.setRetryDelay(retryDelay);
    //        metadata.setWaitingTime(waitingTime);

    return metadata;

}