List of usage examples for org.apache.commons.configuration Configuration getLong
Long getLong(String key, Long defaultValue);
From source file:com.germinus.easyconf.ComponentProperties.java
protected static Object getTypedPropertyWithDefault(String key, Class theClass, Configuration properties, Object defaultValue) {//from w w w.j a va 2 s .co m if (theClass.equals(Float.class)) { return properties.getFloat(key, (Float) defaultValue); } else if (theClass.equals(Integer.class)) { return properties.getInteger(key, (Integer) defaultValue); } else if (theClass.equals(String.class)) { return properties.getString(key, (String) defaultValue); } else if (theClass.equals(Double.class)) { return properties.getDouble(key, (Double) defaultValue); } else if (theClass.equals(Long.class)) { return properties.getLong(key, (Long) defaultValue); } else if (theClass.equals(Boolean.class)) { return properties.getBoolean(key, (Boolean) defaultValue); } else if (theClass.equals(List.class)) { return properties.getList(key, (List) defaultValue); } else if (theClass.equals(BigInteger.class)) { return properties.getBigInteger(key, (BigInteger) defaultValue); } else if (theClass.equals(BigDecimal.class)) { return properties.getBigDecimal(key, (BigDecimal) defaultValue); } else if (theClass.equals(Byte.class)) { return properties.getByte(key, (Byte) defaultValue); } else if (theClass.equals(Short.class)) { return properties.getShort(key, (Short) defaultValue); } throw new IllegalArgumentException("Class " + theClass + " is not" + "supported for properties"); }
From source file:com.microrisc.simply.SimpleDeviceObjectFactory.java
/** * Creates new results container.//from w w w . ja v a 2 s .c om */ private CallRequestProcessingInfoContainer createResultsContainer(Configuration configuration) { logger.debug("createResultsContainer - start: configuration={}", configuration); int capacity = configuration.getInt("deviceObject.resultsContainer.capacity", HashMapResultsContainer.DEFAULT_CAPACITY); long maxTimeDuration = configuration.getLong("deviceObject.resultsContainer.maxTimeDuration", HashMapResultsContainer.DEFAULT_MAX_TIME_DURATION); CallRequestProcessingInfoContainer resultsContainer = new HashMapCallRequestProcessingInfoContainer( capacity, maxTimeDuration); logger.debug("createResultsContainer - end: {}", resultsContainer); return resultsContainer; }
From source file:com.cisco.oss.foundation.message.RabbitMQMessageProducer.java
RabbitMQMessageProducer(String producerName) { super(producerName); Configuration subset = configuration.subset(producerName); queueName = subset.getString("queue.name"); if (StringUtils.isBlank(queueName)) { throw new QueueException( "Check Configuration - missing required queue name for producer: " + producerName); }/*from www. j av a 2 s. c om*/ //update expiration expiration = subset.getLong("queue.expiration", 1800000); groupId = subset.getString("queue.groupId", ""); isDurable = subset.getBoolean("queue.isDurable", true); isPersistent = subset.getBoolean("queue.isPersistent", true); try { Channel channel = RabbitMQMessagingFactory.getChannel(); channel.exchangeDeclare(queueName, "topic", isDurable, false, false, null); isInitialized.set(true); } catch (QueueException e) { LOGGER.debug("can't init producer as its underlying connection is not ready"); } catch (IOException e) { throw new QueueException("Can't create producer: " + e, e); } LOGGER.info("created rabbitmq producer: {} on exchange: {}", producerName, queueName); }
From source file:com.cisco.oss.foundation.message.RabbitMQMessageConsumer.java
RabbitMQMessageConsumer(String consumerName) { try {/*from w ww.jav a2 s.c om*/ this.consumerName = consumerName; Configuration subset = configuration.subset(consumerName); queueName = subset.getString("queue.name"); String filter = subset.getString("queue.filter", ""); boolean isDurable = subset.getBoolean("queue.isDurable", true); boolean isSubscription = subset.getBoolean("queue.isSubscription", false); long expiration = subset.getLong("queue.expiration", 1800000); long maxLength = subset.getLong("queue.maxLength", -1); boolean deadLetterIsEnabled = subset.getBoolean("queue.deadLetterIsEnabled", true); String deadLetterExchangeName = subset.getString("queue.deadLetterExchangeName", DLQ); String subscribedTo = isSubscription ? subset.getString("queue.subscribedTo", "") : queueName; String exchangeType = isSubscription ? "topic" : "direct"; try { RabbitMQMessagingFactory.INIT_LATCH.await(); } catch (InterruptedException e) { LOGGER.error("error waiting for init to finish: " + e); } Channel channel = RabbitMQMessagingFactory.getChannel(); channel.exchangeDeclare(subscribedTo, exchangeType, isDurable, false, false, null); Map<String, Object> args = new HashMap<String, Object>(); if (maxLength > 0) { args.put("x-max-length", maxLength); } if (expiration > 0) { args.put("x-message-ttl", expiration); } if (deadLetterIsEnabled) { channel.exchangeDeclare(deadLetterExchangeName, exchangeType, true, false, false, null); args.put("x-dead-letter-exchange", deadLetterExchangeName); } String queue = channel.queueDeclare(queueName, isDurable, false, false, args).getQueue(); Map<String, String> filters = ConfigUtil.parseSimpleArrayAsMap(consumerName + ".queue.filters"); if (filters != null && !filters.isEmpty()) { for (String routingKey : filters.values()) { channel.queueBind(queue, subscribedTo, routingKey); } } else { channel.queueBind(queue, subscribedTo, "#"); } consumer = new QueueingConsumer(channel); // channel.basicConsume(queueName, true, consumer); LOGGER.info("created rabbitmq consumer: {} on exchange: {}, queue-name: {}", consumerName, subscribedTo, queueName); } catch (IOException e) { throw new QueueException("Can't create consumer: " + e, e); } }
From source file:com.cisco.oss.foundation.message.HornetQMessageProducer.java
private String createQueueIfNeeded() { Configuration subset = configuration.subset(producerName); queueName = subset.getString("queue.name"); if (StringUtils.isBlank(queueName)) { throw new QueueException( "Check Configuration - missing required queue name for producer: " + producerName); }/* ww w. j av a 2s. c o m*/ String realQueueName = /*"foundation." + */queueName; //update expiration expiration = subset.getLong("queue.expiration", 1800000); groupId = subset.getString("queue.groupId", ""); return realQueueName; }
From source file:eu.socialsensor.main.BenchmarkConfiguration.java
public BenchmarkConfiguration(Configuration appconfig) { if (appconfig == null) { throw new IllegalArgumentException("appconfig may not be null"); }/*from w w w.java 2 s.co m*/ Configuration eu = appconfig.subset("eu"); Configuration socialsensor = eu.subset("socialsensor"); //metrics final Configuration metrics = socialsensor.subset(GraphDatabaseConfiguration.METRICS_NS.getName()); final Configuration graphite = metrics.subset(GRAPHITE); this.graphiteHostname = graphite.getString(GRAPHITE_HOSTNAME, null); this.graphiteReportingInterval = graphite.getLong(GraphDatabaseConfiguration.GRAPHITE_INTERVAL.getName(), 1000 /*default 1sec*/); final Configuration csv = metrics.subset(CSV); this.csvReportingInterval = metrics.getLong(CSV_INTERVAL, 1000 /*ms*/); this.csvDir = csv.containsKey(CSV_DIR) ? new File(csv.getString(CSV_DIR, System.getProperty("user.dir") /*default*/)) : null; Configuration dynamodb = socialsensor.subset("dynamodb"); this.dynamodbWorkerThreads = dynamodb.getInt("workers", 25); Configuration credentials = dynamodb.subset(CREDENTIALS); this.dynamodbPrecreateTables = dynamodb.getBoolean("precreate-tables", Boolean.FALSE); this.dynamodbTps = Math.max(1, dynamodb.getLong(TPS, 750 /*default*/)); this.dynamodbConsistentRead = dynamodb.containsKey(CONSISTENT_READ) ? dynamodb.getBoolean(CONSISTENT_READ) : false; this.dynamodbDataModel = dynamodb.containsKey("data-model") ? BackendDataModel.valueOf(dynamodb.getString("data-model")) : null; this.dynamodbCredentialsFqClassName = credentials.containsKey(CLASS_NAME) ? credentials.getString(CLASS_NAME) : null; this.dynamodbCredentialsCtorArguments = credentials.containsKey(CONSTRUCTOR_ARGS) ? credentials.getString(CONSTRUCTOR_ARGS) : null; this.dynamodbEndpoint = dynamodb.containsKey(ENDPOINT) ? dynamodb.getString(ENDPOINT) : null; this.dynamodbTablePrefix = dynamodb.containsKey(TABLE_PREFIX) ? dynamodb.getString(TABLE_PREFIX) : Constants.DYNAMODB_TABLE_PREFIX.getDefaultValue(); Configuration orient = socialsensor.subset("orient"); orientLightweightEdges = orient.containsKey(LIGHTWEIGHT_EDGES) ? orient.getBoolean(LIGHTWEIGHT_EDGES) : null; Configuration sparksee = socialsensor.subset("sparksee"); sparkseeLicenseKey = sparksee.containsKey(LICENSE_KEY) ? sparksee.getString(LICENSE_KEY) : null; Configuration titan = socialsensor.subset(TITAN); //TODO(amcp) move dynamodb ns into titan bufferSize = titan.getInt(BUFFER_SIZE, GraphDatabaseConfiguration.BUFFER_SIZE.getDefaultValue()); blocksize = titan.getInt(IDS_BLOCKSIZE, GraphDatabaseConfiguration.IDS_BLOCK_SIZE.getDefaultValue()); pageSize = titan.getInt(PAGE_SIZE, GraphDatabaseConfiguration.PAGE_SIZE.getDefaultValue()); // database storage directory if (!socialsensor.containsKey(DATABASE_STORAGE_DIRECTORY)) { throw new IllegalArgumentException("configuration must specify database-storage-directory"); } dbStorageDirectory = new File(socialsensor.getString(DATABASE_STORAGE_DIRECTORY)); dataset = validateReadableFile(socialsensor.getString(DATASET), DATASET); // load the dataset DatasetFactory.getInstance().getDataset(dataset); if (!socialsensor.containsKey(PERMUTE_BENCHMARKS)) { throw new IllegalArgumentException("configuration must set permute-benchmarks to true or false"); } permuteBenchmarks = socialsensor.getBoolean(PERMUTE_BENCHMARKS); List<?> benchmarkList = socialsensor.getList("benchmarks"); benchmarkTypes = new ArrayList<BenchmarkType>(); for (Object str : benchmarkList) { benchmarkTypes.add(BenchmarkType.valueOf(str.toString())); } selectedDatabases = new TreeSet<GraphDatabaseType>(); for (Object database : socialsensor.getList("databases")) { if (!GraphDatabaseType.STRING_REP_MAP.keySet().contains(database.toString())) { throw new IllegalArgumentException( String.format("selected database %s not supported", database.toString())); } selectedDatabases.add(GraphDatabaseType.STRING_REP_MAP.get(database)); } scenarios = permuteBenchmarks ? Ints.checkedCast(CombinatoricsUtils.factorial(selectedDatabases.size())) : 1; resultsPath = new File(System.getProperty("user.dir"), socialsensor.getString("results-path")); if (!resultsPath.exists() && !resultsPath.mkdirs()) { throw new IllegalArgumentException("unable to create results directory"); } if (!resultsPath.canWrite()) { throw new IllegalArgumentException("unable to write to results directory"); } randomNodes = socialsensor.getInteger(RANDOM_NODES, new Integer(100)); if (this.benchmarkTypes.contains(BenchmarkType.CLUSTERING)) { if (!socialsensor.containsKey(NODES_COUNT)) { throw new IllegalArgumentException("the CW benchmark requires nodes-count integer in config"); } nodesCount = socialsensor.getInt(NODES_COUNT); if (!socialsensor.containsKey(RANDOMIZE_CLUSTERING)) { throw new IllegalArgumentException("the CW benchmark requires randomize-clustering bool in config"); } randomizedClustering = socialsensor.getBoolean(RANDOMIZE_CLUSTERING); if (!socialsensor.containsKey(ACTUAL_COMMUNITIES)) { throw new IllegalArgumentException("the CW benchmark requires a file with actual communities"); } actualCommunities = validateReadableFile(socialsensor.getString(ACTUAL_COMMUNITIES), ACTUAL_COMMUNITIES); final boolean notGenerating = socialsensor.containsKey(CACHE_VALUES); if (notGenerating) { List<?> objects = socialsensor.getList(CACHE_VALUES); cacheValues = new ArrayList<Integer>(objects.size()); cacheValuesCount = null; cacheIncrementFactor = null; for (Object o : objects) { cacheValues.add(Integer.valueOf(o.toString())); } } else if (socialsensor.containsKey(CACHE_VALUES_COUNT) && socialsensor.containsKey(CACHE_INCREMENT_FACTOR)) { cacheValues = null; // generate the cache values with parameters if (!socialsensor.containsKey(CACHE_VALUES_COUNT)) { throw new IllegalArgumentException( "the CW benchmark requires cache-values-count int in config when cache-values not specified"); } cacheValuesCount = socialsensor.getInt(CACHE_VALUES_COUNT); if (!socialsensor.containsKey(CACHE_INCREMENT_FACTOR)) { throw new IllegalArgumentException( "the CW benchmark requires cache-increment-factor int in config when cache-values not specified"); } cacheIncrementFactor = socialsensor.getDouble(CACHE_INCREMENT_FACTOR); } else { throw new IllegalArgumentException( "when doing CW benchmark, must provide cache-values or parameters to generate them"); } } else { randomizedClustering = null; nodesCount = null; cacheValuesCount = null; cacheIncrementFactor = null; cacheValues = null; actualCommunities = null; } }
From source file:com.appeligo.alerts.KeywordAlertThread.java
public KeywordAlertThread(Configuration config) throws IOException { super("KeywordAlertThread"); isActive = true;/* www .j a va 2 s.c o m*/ alertManager = AlertManager.getInstance(); liveIndexDir = config.getString("luceneLiveIndex"); liveLineup = config.getString("liveLineup"); maxConsecutiveExceptions = config.getInt("maxConsecutiveExceptions", 10); shortestTimeBetweenQueriesMs = config.getLong("shortestTimeBetweenQueriesMs", DEFAULT_SHORTEST_TIME_BETWEEN_QUERIES_MS); keywordAlertProximity = config.getInt("keywordAlertProximity", 10); if (!IndexReader.indexExists(liveIndexDir)) { log.error("Lucene Live Index is missing or invalid at " + liveIndexDir + ". Trying anyway in case this gets resolved."); } parser = new QueryParser("text", new PorterStemAnalyzer(LuceneIndexer.STOP_WORDS)); parser.setDefaultOperator(Operator.AND); helper = new KeywordAlertChecker(config); }
From source file:com.cisco.oss.foundation.http.netlifx.netty.NettyNetflixHttpClient.java
private InternalServerProxyMetadata loadServersMetadataConfiguration() { Configuration subset = ConfigurationFactory.getConfiguration().subset(getApiName()); 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, ""); startEurekaClient = subset.getBoolean("http.startEurekaClient", true); final List<String> keys = new ArrayList<String>(); while (keysIterator.hasNext()) { String key = keysIterator.next(); keys.add(key);//from w ww .jav a2s. c o m } 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 (org.apache.commons.lang.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); return metadata; }
From source file:at.newmedialab.ldpath.backend.linkeddata.AbstractLDBackend.java
/** * Initialise a new sesame backend. Repository needs to be set using setRepository. *///w w w. j a v a 2s .c om protected AbstractLDBackend() { ldCache = new LDCache(this); try { Configuration config = new PropertiesConfiguration("endpoints.properties"); HashSet<String> endpointNames = new HashSet<String>(); for (Iterator<String> it = config.getKeys(); it.hasNext();) { String key = it.next(); String[] components = key.split("\\."); if (components.length > 1) { endpointNames.add(components[0]); } } for (String endpointName : endpointNames) { String prefix = config.getString(endpointName + ".prefix", ""); String kind = config.getString(endpointName + ".kind", ""); String endpointUrl = config.getString(endpointName + ".endpoint", ""); String mimetype = config.getString(endpointName + ".mimetype", ""); long expiry = config.getLong(endpointName + ".expiry", (long) 86400); Endpoint.EndpointType type; try { type = Endpoint.EndpointType.valueOf(kind.toUpperCase()); } catch (Exception e) { type = Endpoint.EndpointType.LINKEDDATA; } if (prefix != null && prefix.startsWith(Endpoint.REGEX_INDICATOR)) { // Check for valid Regex try { Pattern.compile(prefix.substring(Endpoint.REGEX_INDICATOR.length())); } catch (PatternSyntaxException pse) { log.error("invalid regexp pattern in endpoint '{}' prefix definition: {}", endpointName, prefix); } } if (endpointUrl != null) { endpointUrl = endpointUrl.replace('<', '{').replace('>', '}'); } else { endpointUrl = ""; } Endpoint endpoint = new Endpoint(endpointName, type, prefix, endpointUrl, mimetype, expiry); log.info("Registering LD Cache Endpoint \"{}\"", endpointName); registerEndpoint(endpoint); } } catch (ConfigurationException e) { log.warn( "could not load configuration file endpoints.properties from current directory, home directory, or classpath"); } }
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 av a 2 s . co m } 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; }