List of usage examples for org.apache.commons.configuration Configuration getLong
Long getLong(String key, Long defaultValue);
From source file:edu.berkeley.sparrow.examples.BBackend.java
public static void main(String[] args) throws IOException, TException { ipAddress = InetAddress.getLocalHost().toString(); 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);/*from www.j a v a2 s .c om*/ } // Logger configuration: log to the console BasicConfigurator.configure(); Configuration conf = new PropertiesConfiguration(); if (options.has("c")) { String configFile = (String) options.valueOf("c"); try { conf = new PropertiesConfiguration(configFile); } catch (ConfigurationException e) { } } // Start backend server LOG.setLevel(Level.toLevel(conf.getString(LOG_LEVEL, DEFAULT_LOG_LEVEL))); LOG.debug("debug logging on"); int listenPort = conf.getInt(LISTEN_PORT, DEFAULT_LISTEN_PORT); int nodeMonitorPort = conf.getInt(NODE_MONITOR_PORT, NodeMonitorThrift.DEFAULT_NM_THRIFT_PORT); batchingDelay = conf.getLong(BATCHING_DELAY, DEFAULT_BATCHING_DELAY); String nodeMonitorHost = conf.getString(NODE_MONITOR_HOST, DEFAULT_NODE_MONITOR_HOST); int workerThread = conf.getInt(WORKER_THREADS, DEFAULT_WORKER_THREADS); appClientAdress = InetAddress.getByName(conf.getString(APP_CLIENT_IP)); appClientPortNumber = conf.getInt(APP_CLIENT_PORT_NUMBER, DEFAULT_APP_CLIENT_PORT_NUMBER); executor = Executors.newFixedThreadPool(workerThread); // Starting logging of results resultLog = new SynchronizedWrite("ResultsBackend.txt"); Thread resultLogTh = new Thread(resultLog); resultLogTh.start(); BBackend protoBackend = new BBackend(); BackendService.Processor<BackendService.Iface> processor = new BackendService.Processor<BackendService.Iface>( protoBackend); TServers.launchSingleThreadThriftServer(listenPort, processor); protoBackend.initialize(listenPort, nodeMonitorHost, nodeMonitorPort); }
From source file:com.microrisc.simply.iqrf.dpa.v201.init.DPA_InitializerConfigurationFactory.java
private static DiscoveryConfiguration createDiscoveryConfiguration(Configuration configuration) { int doDiscovery = configuration.getInt("initialization.type.dpa.discovery", 0); if (doDiscovery == 0) { return null; }//from w w w . j a va2s. co m long discoveryTimeout = configuration.getLong("initialization.type.dpa.discovery.timeout", -1); int discoveryTxPower = configuration.getInt("initialization.type.dpa.discovery.txPower", -1); // if user explicitly sets to do discovery if (doDiscovery > 0) { if (discoveryTimeout == -1) { discoveryTimeout = DiscoveryConfiguration.DEFAULT_DISCOVERY_TIMEOUT; } if (discoveryTxPower == -1) { discoveryTxPower = DiscoveryConfiguration.DEFAULT_DISCOVERY_TX_POWER; } } return new DiscoveryConfiguration(discoveryTimeout, discoveryTxPower); }
From source file:com.boozallen.cognition.ingest.accumulo.utils.AccumuloConnectionUtils.java
public static AccumuloConnectionConfig extractConnectionConfiguration(Configuration conf) { AccumuloConnectionConfig config = new AccumuloConnectionConfig(); config.instance = conf.getString(INSTANCE); config.zooServers = conf.getString(ZOO_SERVERS); config.user = conf.getString(USER);//from ww w. ja v a 2 s. c om config.key = conf.getString(KEY); config.maxMem = conf.getLong(MAX_MEM, MAX_MEM_DEFAULT); config.maxLatency = conf.getLong(MAX_LATENCY, MAX_LATENCY_DEFAULT); config.maxWriteThreads = conf.getInt(MAX_WRITE_THREADS, MAX_WRITE_THREADS_DEFAULT); return config; }
From source file:com.linkedin.pinot.core.query.utils.SimpleSegmentMetadata.java
public static SegmentMetadata load(Configuration properties) { final SegmentMetadata segmentMetadata = new SimpleSegmentMetadata(); ((SimpleSegmentMetadata) segmentMetadata).setSize(properties.getLong(SEGMENT_SIZE, 0)); return segmentMetadata; }
From source file:com.microrisc.simply.iqrf.dpa.v201.init.DPA_InitializerConfigurationFactory.java
private static EnumerationConfiguration createEnumerationConfiguration(Configuration configuration) { int getPerAttemptsNum = configuration.getInt( "initialization.type.dpa.enumeration.getPeripheral.num_attempts", EnumerationConfiguration.DEFAULT_GET_PER_ATTEMPTS_NUM); long getPerTimeout = configuration.getLong("initialization.type.dpa.enumeration.getPeripheral.timeout", EnumerationConfiguration.DEFAULT_GET_PER_TIMEOUT); return new EnumerationConfiguration(getPerAttemptsNum, getPerTimeout); }
From source file:com.microrisc.simply.iqrf.dpa.v201.init.DPA_InitializerConfigurationFactory.java
private static BondedNodesConfiguration createBondedNodesConfiguration(Configuration configuration) { int processBondedNodes = configuration.getInt("initialization.type.dpa.getBondedNodes", 0); if (processBondedNodes == 0) { return null; }// www . j ava 2 s .com int getBondedNodesAttemptsNum = configuration.getInt("initialization.type.dpa.getBondedNodes.num_attempts", -1); long getBondeNodesTimeout = configuration.getLong("initialization.type.dpa.getBondedNodes.timeout", -1); // if user explicitly sets to process bonded nodes if (processBondedNodes > 0) { if (getBondedNodesAttemptsNum == -1) { getBondedNodesAttemptsNum = BondedNodesConfiguration.DEFAULT_GET_BONDED_NODES_ATTEMPTS_NUM; } if (getBondeNodesTimeout == -1) { getBondeNodesTimeout = BondedNodesConfiguration.DEFAULT_GET_BONDED_NODES_TIMEOUT; } } return new BondedNodesConfiguration(getBondedNodesAttemptsNum, getBondeNodesTimeout); }
From source file:com.microrisc.simply.iqrf.dpa.v201.DPA_SimplyFactory.java
/** * Creates and returns broadcast services implementation object. * @param configuration source configuration * @param connectorService connector to use * @return DPA broadcaster object/* ww w .j av a 2 s.c o m*/ * @throws SimplyException if specified connector doesn't support DPA Broadcasting */ private static BroadcastServices createBroadcastServices(Configuration configuration, ConnectorService connectorService) throws SimplyException { if (!(connectorService instanceof BroadcastingConnectorService)) { throw new SimplyException("Connector doesn't support broadcasting."); } int capacity = configuration.getInt("dpa.broadcasting.resultsContainer.capacity", HashMapResultsContainer.DEFAULT_CAPACITY); long maxTimeDuration = configuration.getLong("dpa.broadcasting.resultsContainer.maxTimeDuration", HashMapResultsContainer.DEFAULT_MAX_TIME_DURATION); return new BroadcastServicesDefaultImpl((BroadcastingConnectorService) connectorService, new HashMapCallRequestProcessingInfoContainer(capacity, maxTimeDuration)); }
From source file:com.microrisc.simply.SimpleStandardServicesDeviceObjectConfigurator.java
@Override public void configure(StandardServicesDeviceObject devObject, Configuration configuration) { long defaultWaitingTimeout = configuration.getLong("deviceObject.defaultWaitingTimeout", -1); if (defaultWaitingTimeout != -1) { devObject.setDefaultWaitingTimeout(defaultWaitingTimeout); }/*w w w . j av a 2s .c o m*/ }
From source file:es.juntadeandalucia.framework.ticket.impl.DefaultTicket.java
public DefaultTicket(Configuration config) throws Exception { try {/*from w w w. j a v a2 s . c o m*/ ticketLifeTime = config.getLong(TIME_TICKET_LIFETIME, 0); } catch (Exception e) { e = new Exception(msg.getString("ticket.error.lifetimeerror")); //$NON-NLS-1$ log.warn(e); throw e; } List<?> textKey = config.getList(TICKET_KEY); try { SecretKeyFactory kf = SecretKeyFactory.getInstance("DESede"); key = kf.generateSecret(new DESedeKeySpec(hexToByte(textKey))); } catch (Exception e) { e = new Exception(msg.getString("ticket.error.keycreationerror")); //$NON-NLS-1$ log.warn(e); throw e; } }
From source file:com.microrisc.simply.connector.response_waiting.SimpleResponseWaitingConnectorConfigurator.java
@Override public void configure(ResponseWaitingConnector connector, Configuration configuration) { int maxSendAttempts = configuration.getInt("connector.type.responseWaiting.maxSendAttempts", -1); if (maxSendAttempts != -1) { connector.setMaxSendAttempts(maxSendAttempts); }// w w w. j a v a2s . co m long responseTimeoutSetting = configuration.getLong("connector.type.responseWaiting.responseTimeout", -1); if (responseTimeoutSetting != -1) { connector.setResponseTimeout(responseTimeoutSetting); } long attemptPause = configuration.getLong("connector.type.responseWaiting.attemptPause", -1); if (attemptPause != -1) { connector.setAttemptPause(attemptPause); } long betweenSendPause = configuration.getLong("connector.type.responseWaiting.betweenSendPause", -1); if (betweenSendPause != -1) { connector.setBetweenSendPause(betweenSendPause); } }