List of usage examples for org.apache.commons.configuration Configuration getString
String getString(String key, String defaultValue);
From source file:com.manydesigns.portofino.logic.SecurityLogic.java
public static String getAnonymousGroup(Configuration conf) { return conf.getString(GROUP_ANONYMOUS, GROUP_ANONYMOUS_DEFAULT); }
From source file:com.manydesigns.portofino.logic.SecurityLogic.java
public static String getRegisteredGroup(Configuration conf) { return conf.getString(GROUP_REGISTERED, GROUP_REGISTERED_DEFAULT); }
From source file:edu.berkeley.sparrow.daemon.util.Network.java
/** Return the hostname of this machine, based on configured value, or system * Interrogation. *///w ww. j ava2s.com public static String getHostName(Configuration conf) { String defaultHostname = null; try { defaultHostname = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { defaultHostname = "localhost"; } return conf.getString(SparrowConf.HOSTNAME, defaultHostname); }
From source file:ch.epfl.eagle.daemon.util.Network.java
/** Return the hostname of this machine, based on configured value, or system * Interrogation. *//*from w w w . java 2s .co m*/ public static String getHostName(Configuration conf) { String defaultHostname = null; try { defaultHostname = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { defaultHostname = "localhost"; } return conf.getString(EagleConf.HOSTNAME, defaultHostname); }
From source file:edu.cwru.sepia.environment.Environment.java
/** * Do some reflection to read the type of tracker to use and call its constructor with a random if possible, * and failing that, no argument.//from w w w . j a v a2 s. c o m * @param seed * @return */ private static TurnTracker readTurnTrackerFromPrefs(int seed, Configuration configuration) { TurnTracker toReturn = null; String trackerName = configuration.getString("TurnTracker", "edu.cwru.sepia.environment.SimultaneousTurnTracker"); Class<?> trackerClass = null; try { trackerClass = Class.forName(trackerName); } catch (ClassNotFoundException e) { logger.log(Level.SEVERE, "Unable to find class for TurnTracker " + trackerName, e); } try { toReturn = (TurnTracker) trackerClass.getConstructor(Random.class).newInstance(new Random(seed)); } catch (Exception e) { try { toReturn = (TurnTracker) trackerClass.getConstructor().newInstance(); } catch (Exception e1) { logger.log(Level.SEVERE, "Unable to create an instance of TurnTracker " + trackerName, e); } } if (toReturn == null) { logger.info("No TurnTracker was specified or instantiation failed; using SimultaneousTurnTracker"); return new SimultaneousTurnTracker(new Random(seed)); } else return toReturn; }
From source file:com.linkedin.pinot.core.query.scheduler.QuerySchedulerFactory.java
/** * Static factory to instantiate query scheduler based on scheduler configuration. * 'name' configuration in the scheduler will decide which scheduler instance to create * Besides known instances, 'name' can be a classname * @param schedulerConfig scheduler specific configuration * @param queryExecutor QueryExecutor to use * @return/* ww w. ja va 2s .c o m*/ */ public static @Nonnull QueryScheduler create(@Nonnull Configuration schedulerConfig, @Nonnull QueryExecutor queryExecutor) { Preconditions.checkNotNull(schedulerConfig); Preconditions.checkNotNull(queryExecutor); String schedulerName = schedulerConfig .getString(ALGORITHM_NAME_CONFIG_KEY, DEFAULT_QUERY_SCHEDULER_ALGORITHM).toLowerCase(); if (schedulerName.equals(FCFS_ALGORITHM)) { LOGGER.info("Using FCFS query scheduler"); return new FCFSQueryScheduler(schedulerConfig, queryExecutor); } // didn't find by name so try by classname QueryScheduler scheduler = getQuerySchedulerByClassName(schedulerName, schedulerConfig, queryExecutor); if (scheduler != null) { return scheduler; } // if we don't find the configured algorithm we warn and use the default one // because it's better to execute with poor algorithm than completely fail. // Failure on bad configuration will cause outage vs an inferior algorithm that // will provide degraded service LOGGER.warn("Scheduler {} not found. Using default FCFS query scheduler", schedulerName); return new FCFSQueryScheduler(schedulerConfig, queryExecutor); }
From source file:com.comcast.viper.flume2storm.location.DynamicLocationServiceConfiguration.java
/** * @param config// ww w. j a v a 2s . c o m * The configuration to use * @return The newly built {@link DynamicLocationServiceConfiguration} based * on the configuration specified * @throws F2SConfigurationException * If the configuration is invalid */ public static DynamicLocationServiceConfiguration from(Configuration config) throws F2SConfigurationException { DynamicLocationServiceConfiguration result = new DynamicLocationServiceConfiguration(); result.setConnectionStr(config.getString(CONNECTION_STRING, CONNECTION_STRING_DEFAULT)); result.setSessionTimeout(config.getInt(SESSION_TIMEOUT, SESSION_TIMEOUT_DEFAULT)); result.setConnectionTimeout(config.getInt(CONNECTION_TIMEOUT, CONNECTION_TIMEOUT_DEFAULT)); result.setReconnectionDelay(config.getInt(RECONNECTION_DELAY, RECONNECTION_DELAY_DEFAULT)); result.setTerminationTimeout(config.getInt(TERMINATION_TIMEOUT, TERMINATION_TIMEOUT_DEFAULT)); result.setBasePath(config.getString(BASE_PATH, BASE_PATH_DEFAULT)); result.setServiceName(config.getString(SERVICE_NAME, SERVICE_NAME_DEFAULT)); return result; }
From source file:com.comcast.viper.flume2storm.location.StaticLocationServiceConfiguration.java
/** * @param config/*from www . j a v a2 s . co m*/ * The configuration to use * @return The newly built {@link StaticLocationServiceConfiguration} based on * the configuration specified * @throws F2SConfigurationException * If the configuration is invalid */ public static StaticLocationServiceConfiguration from(Configuration config) throws F2SConfigurationException { StaticLocationServiceConfiguration result = new StaticLocationServiceConfiguration(); result.setServiceProviderBase(config.getString(SERVICE_PROVIDER_BASE, SERVICE_PROVIDER_LIST)); String className = config.getString(CONFIGURATION_LOADER_CLASS); if (className == null) { throw F2SConfigurationException.missing(CONFIGURATION_LOADER_CLASS); } try { result.setConfigurationLoaderClassName(className); } catch (Exception e) { throw F2SConfigurationException.with(config, CONFIGURATION_LOADER_CLASS, e); } return result; }
From source file:com.comcast.viper.flume2storm.connection.parameters.SimpleConnectionParameters.java
/** * @param configuration/*from ww w . ja v a 2 s .co m*/ * The configuration to use * @return The newly built {@link SimpleConnectionParameters} based on the * configuration specified * @throws F2SConfigurationException * If the configuration is invalid */ public static SimpleConnectionParameters from(Configuration configuration) throws F2SConfigurationException { SimpleConnectionParameters result = new SimpleConnectionParameters(); try { result.setHostname(configuration.getString(HOSTNAME, HOSTNAME_DEFAULT)); } catch (Exception e) { throw F2SConfigurationException.with(HOSTNAME, configuration.getProperty(HOSTNAME), e); } try { result.setPort(configuration.getInt(PORT, PORT_DEFAULT)); } catch (Exception e) { throw F2SConfigurationException.with(PORT, configuration.getProperty(PORT), e); } return result; }
From source file:com.comcast.viper.flume2storm.zookeeper.ZkClientConfiguration.java
/** * Builds a new {@link ZkClientConfiguration} based on a Configuration * /* w ww.j a va2s. com*/ * @param config * The configuration to use * @return The newly built {@link ZkClientConfiguration} based on the * configuration specified * @throws F2SConfigurationException * If the configuration is invalid */ public static ZkClientConfiguration from(Configuration config) throws F2SConfigurationException { ZkClientConfiguration result = new ZkClientConfiguration(); result.connectionStr = config.getString(CONNECTION_STRING, CONNECTION_STRING_DEFAULT); result.sessionTimeout = config.getInt(SESSION_TIMEOUT, SESSION_TIMEOUT_DEFAULT); result.connectionTimeout = config.getInt(CONNECTION_TIMEOUT, CONNECTION_TIMEOUT_DEFAULT); result.reconnectionDelay = config.getInt(RECONNECTION_DELAY, RECONNECTION_DELAY_DEFAULT); result.terminationTimeout = config.getInt(TERMINATION_TIMEOUT, TERMINATION_TIMEOUT_DEFAULT); return result; }