List of usage examples for org.apache.commons.configuration Configuration getString
String getString(String key, String defaultValue);
From source file:net.sf.jclal.activelearning.multilabel.querystrategy.MultiLabel3DimensionalQueryStrategy.java
/** * * @param configuration The configuration object for * MultiLabel3DimensionalQueryStrategy//from www . j a va 2s . co m * * The XML labels supported are: * <ul> * <li>evidence-dimension: The possible values are [C, S]</li> * <li>class-dimension: The possible values are [M, A, R]</li> * <li>weight-dimension: The possible values are [N, M]</li> * </ul> */ @Override public void configure(Configuration configuration) { super.configure(configuration); evidenceDimension = configuration.getString("evidence-dimension", "C").toCharArray()[0]; classDimension = configuration.getString("class-dimension", "M").toCharArray()[0]; weightDimension = configuration.getString("weight-dimension", "N").toCharArray()[0]; switch (evidenceDimension) { case 'C': setMaximal(false); break; case 'S': setMaximal(true); break; default: throw new ConfigurationRuntimeException("For the evidence dimension the options are C and S"); } switch (classDimension) { case 'M': break; case 'A': break; case 'R': break; default: throw new ConfigurationRuntimeException("For the class dimension the options are M, A and R"); } switch (weightDimension) { case 'N': break; case 'W': break; default: throw new ConfigurationRuntimeException("For the weight dimension the options are N and W"); } }
From source file:com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata.java
public IndexLoadingConfigMetadata(Configuration tableDataManagerConfig) { List<String> valueOfLoadingInvertedIndexConfig = tableDataManagerConfig .getList(KEY_OF_LOADING_INVERTED_INDEX, null); if ((valueOfLoadingInvertedIndexConfig != null) && (!valueOfLoadingInvertedIndexConfig.isEmpty())) { initLoadingInvertedIndexColumnSet(valueOfLoadingInvertedIndexConfig.toArray(new String[0])); }/*from ww w.j a v a 2 s . co m*/ segmentVersionToLoad = tableDataManagerConfig.getString(KEY_OF_SEGMENT_FORMAT_VERSION, DEFAULT_SEGMENT_FORMAT); enableDefaultColumns = tableDataManagerConfig.getBoolean(KEY_OF_ENABLE_DEFAULT_COLUMNS, false); starTreeVersionToLoad = tableDataManagerConfig.getString(KEY_OF_STAR_TREE_FORMAT_VERSION, CommonConstants.Server.DEFAULT_STAR_TREE_FORMAT_VERSION); }
From source file:com.w20e.socrates.process.ModelResource.java
/** * Get the model identified by id, and create new if necessary. * /* w w w . ja v a2 s .co m*/ * @param id * the model's id. * @param cfg * Configuration resource. * @return the model found, or null. * @throws Exception * in case of any failure. */ public Model getModel(final URI id, final Configuration cfg) throws Exception { LOGGER.fine("Fetching model " + id); Model m = getModelDefinition(id, cfg).getModel(id.toString()); if (m == null) { return m; } Submission submission = new SubmissionImpl(); String action = cfg.getString("submission.type", "file") + ":" + cfg.getString("submission.basedir", "."); submission.setAction(new URI(action)); m.setSubmission(submission); return m; }
From source file:de.hybris.platform.acceleratorservices.config.impl.DefaultHostConfigService.java
@Override public String getProperty(final String property, final String hostname) { Assert.notNull(property, "property must not be null"); Assert.notNull(hostname, "hostname must not be null"); final Configuration configuration = getConfigurationService().getConfiguration(); // Try the host and UiExperience final UiExperienceLevel uiExperienceLevel = getUiExperienceService().getUiExperienceLevel(); if (uiExperienceLevel != null) { final String key = property + "." + hostname + "." + uiExperienceLevel.getCode(); final String propertyValue = configuration.getString(key, null); if (propertyValue != null) { return propertyValue; }/* w w w . j av a 2 s. co m*/ } // Try the host on its own { final String key = property + "." + hostname; final String propertyValue = configuration.getString(key, null); if (propertyValue != null) { return propertyValue; } } // Try the UiExperience on its own if (uiExperienceLevel != null) { final String key = property + "." + uiExperienceLevel.getCode(); final String propertyValue = configuration.getString(key, null); if (propertyValue != null) { return propertyValue; } } // Fallback to the property key only return configuration.getString(property, null); }
From source file:com.linkedin.pinot.server.starter.helix.HelixServerStarter.java
public HelixServerStarter(String helixClusterName, String zkServer, Configuration pinotHelixProperties) throws Exception { LOGGER.info("Starting Pinot server"); _helixClusterName = helixClusterName; _pinotHelixProperties = pinotHelixProperties; String hostname = pinotHelixProperties.getString(CommonConstants.Helix.KEY_OF_SERVER_NETTY_HOST, NetUtil.getHostAddress());//from www.j a v a 2s. c o m _instanceId = pinotHelixProperties.getString("instanceId", CommonConstants.Helix.PREFIX_OF_SERVER_INSTANCE + hostname + "_" + pinotHelixProperties.getInt(CommonConstants.Helix.KEY_OF_SERVER_NETTY_PORT, CommonConstants.Helix.DEFAULT_SERVER_NETTY_PORT)); pinotHelixProperties.addProperty("pinot.server.instance.id", _instanceId); startServerInstance(pinotHelixProperties); LOGGER.info("Connecting Helix components"); // Replace all white-spaces from list of zkServers. String zkServers = zkServer.replaceAll("\\s+", ""); _helixManager = HelixManagerFactory.getZKHelixManager(helixClusterName, _instanceId, InstanceType.PARTICIPANT, zkServers); final StateMachineEngine stateMachineEngine = _helixManager.getStateMachineEngine(); _helixManager.connect(); ZkHelixPropertyStore<ZNRecord> zkPropertyStore = ZkUtils.getZkPropertyStore(_helixManager, helixClusterName); SegmentFetcherAndLoader fetcherAndLoader = new SegmentFetcherAndLoader( _serverInstance.getInstanceDataManager(), new ColumnarSegmentMetadataLoader(), zkPropertyStore, pinotHelixProperties, _instanceId); // Register state model factory final StateModelFactory<?> stateModelFactory = new SegmentOnlineOfflineStateModelFactory(helixClusterName, _instanceId, _serverInstance.getInstanceDataManager(), zkPropertyStore, fetcherAndLoader); stateMachineEngine.registerStateModelFactory(SegmentOnlineOfflineStateModelFactory.getStateModelName(), stateModelFactory); _helixAdmin = _helixManager.getClusterManagmentTool(); addInstanceTagIfNeeded(helixClusterName, _instanceId); // Start restlet server for admin API endpoint int adminApiPort = pinotHelixProperties.getInt(CommonConstants.Server.CONFIG_OF_ADMIN_API_PORT, Integer.parseInt(CommonConstants.Server.DEFAULT_ADMIN_API_PORT)); adminApiService = new AdminApiService(_serverInstance); adminApiService.start(adminApiPort); updateInstanceConfigInHelix(adminApiPort, false/*shutDownStatus*/); // Register message handler factory SegmentMessageHandlerFactory messageHandlerFactory = new SegmentMessageHandlerFactory(fetcherAndLoader); _helixManager.getMessagingService().registerMessageHandlerFactory( Message.MessageType.USER_DEFINE_MSG.toString(), messageHandlerFactory); _serverInstance.getServerMetrics().addCallbackGauge("helix.connected", new Callable<Long>() { @Override public Long call() throws Exception { return _helixManager.isConnected() ? 1L : 0L; } }); _helixManager.addPreConnectCallback(new PreConnectCallback() { @Override public void onPreConnect() { _serverInstance.getServerMetrics().addMeteredGlobalValue(ServerMeter.HELIX_ZOOKEEPER_RECONNECTS, 1L); } }); ControllerLeaderLocator.create(_helixManager); LOGGER.info("Pinot server ready"); // Create metrics for mmap stuff _serverInstance.getServerMetrics().addCallbackGauge("memory.directByteBufferUsage", new Callable<Long>() { @Override public Long call() throws Exception { return MmapUtils.getDirectByteBufferUsage(); } }); _serverInstance.getServerMetrics().addCallbackGauge("memory.mmapBufferUsage", new Callable<Long>() { @Override public Long call() throws Exception { return MmapUtils.getMmapBufferUsage(); } }); _serverInstance.getServerMetrics().addCallbackGauge("memory.mmapBufferCount", new Callable<Long>() { @Override public Long call() throws Exception { return MmapUtils.getMmapBufferCount(); } }); }
From source file:com.appeligo.alerts.PendingAlertThread.java
public PendingAlertThread(Configuration config) { super("PendingAlertThread"); isActive = true;/*from www . j a va 2 s .c om*/ alertManager = AlertManager.getInstance(); maxConsecutiveExceptions = config.getInt("maxConsecutiveExceptions", 10); url = config.getString("url", "http://localhost:8080"); }
From source file:net.sf.jclal.listener.ClassicalReporterListener.java
/** * * @param configuration The configuration of Classical Reporter Listener. * * The XML labels supported are:/*from w w w . j ava2s . co m*/ * * <ul> * <li><b>report-title= String</b>, default= untitled</li> * <li><b>report-directory= String</b>, default= reports</li> * <li><b>report-frequency= int</b></li> * <li><b>report-on-console= boolean</b></li> * <li><b>report-on-file= boolean</b></li> * <li><b>send-email= class</b> * <p> * Package: net.sf.jclal.util.mail</p> * Class: All * </li> * </ul> */ @Override public void configure(Configuration configuration) { // Set report title (default "untitled") String reportTitleT = configuration.getString("report-title", reportTitle); setReportTitle(reportTitleT); // Set report title (default "reports/") String reportDirectoryT = configuration.getString("report-directory", reportDirectory); setReportDirectory(reportDirectoryT); // Set report frequency (default 1 iteration) int reportFrequencyT = configuration.getInt("report-frequency", reportFrequency); setReportFrequency(reportFrequencyT); // Set console report (default on) boolean reportOnConsoleT = configuration.getBoolean("report-on-console", reportOnConsole); setReportOnConsole(reportOnConsoleT); // Set file report (default off) boolean reportOnFileT = configuration.getBoolean("report-on-file", reportOnFile); setReportOnFile(reportOnFileT); String sendError = "send-email type= "; try { String senderEmailClassname = configuration.getString("send-email[@type]"); sendError += senderEmailClassname; //If a email sender was especified if (senderEmailClassname != null) { // sender email class Class<?> senderEmailClass = Class.forName(senderEmailClassname); SenderEmail senderEmailT = (SenderEmail) senderEmailClass.newInstance(); // Configure listener (if necessary) if (senderEmailT instanceof IConfigure) { ((IConfigure) senderEmailT).configure(configuration.subset("send-email")); } setSenderEmail(senderEmailT); } } catch (ClassNotFoundException e) { throw new ConfigurationRuntimeException("\nIllegal sender email classname: " + sendError, e); } catch (InstantiationException e) { throw new ConfigurationRuntimeException("\nIllegal sender email classname: " + sendError, e); } catch (IllegalAccessException e) { throw new ConfigurationRuntimeException("\nIllegal sender email classname: " + sendError, e); } }
From source file:de.hybris.platform.acceleratorservices.config.impl.DefaultSiteConfigService.java
@Override public String getProperty(final String property) { final BaseSiteModel currentBaseSite = getBaseSiteService().getCurrentBaseSite(); Assert.notNull(currentBaseSite, "BaseSite should not be null"); final Configuration configuration = getConfigurationService().getConfiguration(); final String currentBaseSiteUid = currentBaseSite.getUid(); // Try the site UID and UiExperience final UiExperienceLevel uiExperienceLevel = getUiExperienceService().getUiExperienceLevel(); if (uiExperienceLevel != null) { final String key = property + "." + currentBaseSiteUid + "." + uiExperienceLevel.getCode(); final String propertyValue = configuration.getString(key, null); if (propertyValue != null) { return propertyValue; }//from w w w. ja va 2 s. c om } // Try the site UID on its own { final String key = property + "." + currentBaseSiteUid; final String propertyValue = configuration.getString(key, null); if (propertyValue != null) { return propertyValue; } } // Try the UiExperience on its own if (uiExperienceLevel != null) { final String key = property + "." + uiExperienceLevel.getCode(); final String propertyValue = configuration.getString(key, null); if (propertyValue != null) { return propertyValue; } } // Fallback to the property key only return configuration.getString(property, null); }
From source file:ch.epfl.eagle.daemon.nodemonitor.NodeMonitor.java
public void initialize(Configuration conf, int nodeMonitorInternalPort) throws UnknownHostException { String mode = conf.getString(EagleConf.DEPLOYMENT_MODE, "unspecified"); stealing = conf.getBoolean(EagleConf.STEALING, EagleConf.DEFAULT_STEALING); maxStealingAttempts = conf.getInt(EagleConf.STEALING_ATTEMPTS, EagleConf.DEFAULT_STEALING_ATTEMPTS); smallPartition = conf.getInt(EagleConf.SMALL_PARTITION, EagleConf.DEFAULT_SMALL_PARTITION); bigPartition = conf.getInt(EagleConf.BIG_PARTITION, EagleConf.DEFAULT_BIG_PARTITION); gossiping = conf.getBoolean(EagleConf.GOSSIPING, EagleConf.DEFAULT_GOSSIPING); stealingAttempts = 0;//from w w w . jav a2 s.c o m LOG.info("STEALING set to : " + stealing); if (mode.equals("standalone")) { state = new StandaloneNodeMonitorState(); } else if (mode.equals("configbased")) { state = new ConfigNodeMonitorState(); } else { throw new RuntimeException("Unsupported deployment mode: " + mode); } try { state.initialize(conf); } catch (IOException e) { LOG.fatal("Error initializing node monitor state.", e); } longStatusTimestamp = -1; // At the beginning all nodes will be free from Long jobs notExecutingLong = new ArrayList<String>(); List<InetSocketAddress> nodeList = Lists.newArrayList(state.getNodeMonitors()); // TODO EAGLE add itself to the list for (InetSocketAddress isa : nodeList) notExecutingLong.add(isa.toString()); int mem = Resources.getSystemMemoryMb(conf); LOG.info("Using memory allocation: " + mem); ipAddress = Network.getIPAddress(conf); int cores = Resources.getSystemCPUCount(conf); LOG.info("Using core allocation: " + cores); String task_scheduler_type = conf.getString(EagleConf.NM_TASK_SCHEDULER_TYPE, "fifo"); LOG.info("Task scheduler type: " + task_scheduler_type); if (task_scheduler_type.equals("round_robin")) { scheduler = new RoundRobinTaskScheduler(cores); } else if (task_scheduler_type.equals("fifo")) { scheduler = new FifoTaskScheduler(cores, this); } else if (task_scheduler_type.equals("priority")) { scheduler = new PriorityTaskScheduler(cores); } else { throw new RuntimeException("Unsupported task scheduler type: " + mode); } scheduler.initialize(conf, nodeMonitorInternalPort); taskLauncherService = new TaskLauncherService(); taskLauncherService.initialize(conf, scheduler, nodeMonitorInternalPort); }
From source file:edu.berkeley.sparrow.daemon.scheduler.Scheduler.java
public void initialize(Configuration conf, InetSocketAddress socket) throws IOException { address = Network.socketAddressToThrift(socket); String mode = conf.getString(SparrowConf.DEPLYOMENT_MODE, "unspecified"); this.conf = conf; if (mode.equals("standalone")) { state = new StandaloneSchedulerState(); } else if (mode.equals("configbased")) { state = new ConfigSchedulerState(); } else {/* w w w . jav a2s. c o m*/ throw new RuntimeException("Unsupported deployment mode: " + mode); } state.initialize(conf); defaultProbeRatioUnconstrained = conf.getDouble(SparrowConf.SAMPLE_RATIO, SparrowConf.DEFAULT_SAMPLE_RATIO); defaultProbeRatioConstrained = conf.getDouble(SparrowConf.SAMPLE_RATIO_CONSTRAINED, SparrowConf.DEFAULT_SAMPLE_RATIO_CONSTRAINED); requestTaskPlacers = Maps.newConcurrentMap(); useCancellation = conf.getBoolean(SparrowConf.CANCELLATION, SparrowConf.DEFAULT_CANCELLATION); if (useCancellation) { LOG.debug("Initializing cancellation service"); cancellationService = new CancellationService(nodeMonitorClientPool); new Thread(cancellationService).start(); } else { LOG.debug("Not using cancellation"); } spreadEvenlyTaskSetSize = conf.getInt(SparrowConf.SPREAD_EVENLY_TASK_SET_SIZE, SparrowConf.DEFAULT_SPREAD_EVENLY_TASK_SET_SIZE); }