List of usage examples for org.apache.commons.configuration Configuration getLong
Long getLong(String key, Long defaultValue);
From source file:com.linkedin.pinot.server.starter.helix.SegmentFetcherAndLoader.java
public SegmentFetcherAndLoader(DataManager dataManager, SegmentMetadataLoader metadataLoader, ZkHelixPropertyStore<ZNRecord> propertyStore, Configuration pinotHelixProperties, String instanceId) { _propertyStore = propertyStore;//from www . j a v a 2 s .c o m _dataManager = dataManager; _metadataLoader = metadataLoader; _instanceId = instanceId; int maxRetries = Integer.parseInt(CommonConstants.Server.DEFAULT_SEGMENT_LOAD_MAX_RETRY_COUNT); try { maxRetries = pinotHelixProperties.getInt(CommonConstants.Server.CONFIG_OF_SEGMENT_LOAD_MAX_RETRY_COUNT, maxRetries); } catch (Exception e) { // Keep the default value } _segmentLoadMaxRetryCount = maxRetries; long minRetryDelayMillis = Long .parseLong(CommonConstants.Server.DEFAULT_SEGMENT_LOAD_MIN_RETRY_DELAY_MILLIS); try { minRetryDelayMillis = pinotHelixProperties.getLong( CommonConstants.Server.CONFIG_OF_SEGMENT_LOAD_MIN_RETRY_DELAY_MILLIS, minRetryDelayMillis); } catch (Exception e) { // Keep the default value } _segmentLoadMinRetryDelayMs = minRetryDelayMillis; SegmentFetcherFactory.initSegmentFetcherFactory(pinotHelixProperties); }
From source file:com.linkedin.pinot.controller.helix.core.SegmentOnlineOfflineStateModelFactory.java
public SegmentOnlineOfflineStateModelFactory(String helixClusterName, String instanceId, DataManager instanceDataManager, SegmentMetadataLoader segmentMetadataLoader, Configuration pinotHelixProperties, ZkHelixPropertyStore<ZNRecord> propertyStore) { this.propertyStore = propertyStore; HELIX_CLUSTER_NAME = helixClusterName; INSTANCE_ID = instanceId;/*from w w w. j a va 2s.c o m*/ INSTANCE_DATA_MANAGER = instanceDataManager; SEGMENT_METADATA_LOADER = instanceDataManager.getSegmentMetadataLoader(); int maxRetries = Integer.parseInt(CommonConstants.Server.DEFAULT_SEGMENT_LOAD_MAX_RETRY_COUNT); try { maxRetries = pinotHelixProperties.getInt(CommonConstants.Server.CONFIG_OF_SEGMENT_LOAD_MAX_RETRY_COUNT, maxRetries); } catch (Exception e) { // Keep the default value } SEGMENT_LOAD_MAX_RETRY_COUNT = maxRetries; long minRetryDelayMillis = Long .parseLong(CommonConstants.Server.DEFAULT_SEGMENT_LOAD_MIN_RETRY_DELAY_MILLIS); try { minRetryDelayMillis = pinotHelixProperties.getLong( CommonConstants.Server.CONFIG_OF_SEGMENT_LOAD_MIN_RETRY_DELAY_MILLIS, minRetryDelayMillis); } catch (Exception e) { // Keep the default value } SEGMENT_LOAD_MIN_RETRY_DELAY_MILLIS = minRetryDelayMillis; }
From source file:com.linkedin.pinot.broker.requesthandler.BrokerRequestHandler.java
public BrokerRequestHandler(RoutingTable table, TimeBoundaryService timeBoundaryService, ScatterGather scatterGatherer, ReduceServiceRegistry reduceServiceRegistry, BrokerMetrics brokerMetrics, Configuration config) { _routingTable = table;//www . j ava 2s . c o m _timeBoundaryService = timeBoundaryService; _reduceServiceRegistry = reduceServiceRegistry; _scatterGatherer = scatterGatherer; _replicaSelection = new RoundRobinReplicaSelection(); _brokerMetrics = brokerMetrics; _optimizer = new BrokerRequestOptimizer(); _requestIdGenerator = new AtomicLong(0); _queryResponseLimit = config.getInt(BROKER_QUERY_RESPONSE_LIMIT_CONFIG, DEFAULT_BROKER_QUERY_RESPONSE_LIMIT); _brokerTimeOutMs = config.getLong(BROKER_TIME_OUT_CONFIG, DEFAULT_BROKER_TIME_OUT_MS); _brokerId = config.getString(BROKER_ID_CONFIG_KEY, DEFAULT_BROKER_ID); LOGGER.info("Broker response limit is: " + _queryResponseLimit); LOGGER.info("Broker timeout is - " + _brokerTimeOutMs + " ms"); LOGGER.info("Broker id: " + _brokerId); }
From source file:com.cisco.oss.foundation.http.netlifx.apache.ApacheNetflixHttpClient.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 . java 2s . 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 (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); // metadata.getHostAndPortPairs().addAll(hostAndPortPairs); // metadata.setReadTimeout(readTimeout); // metadata.setConnectTimeout(connectTimeout); // metadata.setNumberOfRetries(numberOfAttempts); // metadata.setRetryDelay(retryDelay); // metadata.setWaitingTime(waitingTime); return metadata; }
From source file:com.blazegraph.gremlin.structure.BlazeGraph.java
/** * Construct an instance using the supplied configuration. */// w w w.j av a 2 s . co m protected BlazeGraph(final Configuration config) { this.config = config; this.vf = Optional.ofNullable((BlazeValueFactory) config.getProperty(Options.VALUE_FACTORY)) .orElse(BlazeValueFactory.INSTANCE); final long listIndexFloor = config.getLong(Options.LIST_INDEX_FLOOR, System.currentTimeMillis()); this.vpIdFactory = new AtomicLong(listIndexFloor); this.maxQueryTime = config.getInt(Options.MAX_QUERY_TIME, 0); this.sparqlLogMax = config.getInt(Options.SPARQL_LOG_MAX, Options.DEFAULT_SPARQL_LOG_MAX); this.TYPE = vf.type(); this.VALUE = vf.value(); this.LI_DATATYPE = vf.liDatatype(); this.sparql = new SparqlGenerator(vf); this.transforms = new Transforms(); }
From source file:org.apache.bookkeeper.common.conf.ConfigKey.java
/** * Retrieve the setting from the configuration <tt>conf</tt> as a {@link Long} value. * * @param conf configuration to retrieve the setting * @return the value as a long number//from w w w .ja v a2 s . co m */ public long getLong(Configuration conf) { checkArgument(type() == Type.LONG, "'" + name() + "' is NOT a LONG numeric setting"); return conf.getLong(name(), (Long) defaultValue()); }
From source file:org.apache.james.modules.server.ElasticSearchMetricReporterModule.java
@Provides public ESReporterConfiguration provideConfiguration(PropertiesProvider propertiesProvider) throws ConfigurationException { try {//from w ww. ja va 2 s.co m Configuration propertiesReader = propertiesProvider.getConfiguration(ELASTICSEARCH_CONFIGURATION_NAME); if (isMetricEnable(propertiesReader)) { return ESReporterConfiguration.builder().enabled() .onHost(locateHost(propertiesReader), propertiesReader.getInt("elasticsearch.http.port", DEFAULT_ES_HTTP_PORT)) .onIndex(propertiesReader.getString("elasticsearch.metrics.reports.index", null)) .periodInSecond(propertiesReader.getLong("elasticsearch.metrics.reports.period", null)) .build(); } } catch (FileNotFoundException e) { LOGGER.info("Can not locate " + ELASTICSEARCH_CONFIGURATION_NAME + " configuration"); } return ESReporterConfiguration.builder().disabled().build(); }
From source file:org.apache.james.smtpserver.fastfail.SpamTrapHandler.java
@Override public void init(Configuration config) throws ConfigurationException { String[] rcpts = config.getStringArray("spamTrapRecip"); if (rcpts.length == 0) { setSpamTrapRecipients(Arrays.asList(rcpts)); } else {/*from w w w . j a v a2s . c om*/ throw new ConfigurationException("Please configure a spamTrapRecip."); } setBlockTime(config.getLong("blockTime", blockTime)); }
From source file:org.apache.marmotta.loader.core.test.dummy.DummyLoaderBackend.java
/** * Create the RDFHandler to be used for bulk-loading, optionally using the configuration passed as argument. * * @param configuration//from ww w .j a v a 2 s . co m * @return a newly created RDFHandler instance */ @Override public LoaderHandler createLoader(Configuration configuration) { return new DummyLoaderHandler(configuration.getLong(METHOD_SLEEP_MILLIS, 0l)); }
From source file:org.apache.qpid.server.store.berkeleydb.AbstractBDBMessageStore.java
/** * Called after instantiation in order to configure the message store. * * @param name The name of the virtual host using this store * @return whether a new store environment was created or not (to indicate whether recovery is necessary) * * @throws Exception If any error occurs that means the store is unable to configure itself. *//*from w ww . j a v a 2 s. c o m*/ public void configure(String name, Configuration storeConfig) throws Exception { final String storeLocation = storeConfig.getString(MessageStoreConstants.ENVIRONMENT_PATH_PROPERTY, System.getProperty("QPID_WORK") + File.separator + "bdbstore" + File.separator + name); _persistentSizeHighThreshold = storeConfig.getLong(MessageStoreConstants.OVERFULL_SIZE_PROPERTY, Long.MAX_VALUE); _persistentSizeLowThreshold = storeConfig.getLong(MessageStoreConstants.UNDERFULL_SIZE_PROPERTY, _persistentSizeHighThreshold); if (_persistentSizeLowThreshold > _persistentSizeHighThreshold || _persistentSizeLowThreshold < 0l) { _persistentSizeLowThreshold = _persistentSizeHighThreshold; } File environmentPath = new File(storeLocation); if (!environmentPath.exists()) { if (!environmentPath.mkdirs()) { throw new IllegalArgumentException( "Environment path " + environmentPath + " could not be read or created. " + "Ensure the path is correct and that the permissions are correct."); } } _storeLocation = storeLocation; _envConfigMap = getConfigMap(ENVCONFIG_DEFAULTS, storeConfig, "envConfig"); LOGGER.info("Configuring BDB message store"); setupStore(environmentPath, name); }