List of usage examples for org.apache.commons.configuration Configuration getInt
int getInt(String key, int defaultValue);
From source file:com.knowbout.epg.processor.ScheduleParser.java
private void loadLineups() { log.debug("Processing lineups for schedules"); int lineupCount = config.getList("lineups.lineup.name").size(); Session session = HibernateUtil.currentSession(); TransactionManager.beginTransaction(); for (int i = 0; i < lineupCount; i++) { Configuration lineupConfig = config.subset("lineups.lineup(" + i + ")"); String name = lineupConfig.getString("name"); String id = lineupConfig.getString("id"); boolean digital = lineupConfig.getBoolean("digital", false); int delay = lineupConfig.getInt("delay", 0); int affiliateDelay = lineupConfig.getInt("affiliateDelay", 0); NetworkLineup sl = null;//ww w . j av a2s . c o m boolean found = false; try { sl = (NetworkLineup) session.get(NetworkLineup.class, id); found = (sl != null); } catch (Exception e) { } if (!found) { sl = new NetworkLineup(); sl.setId(id); } sl.setName(name); sl.setId(id); sl.setDigital(digital); sl.setDelay(delay); sl.setAffiliateDelay(affiliateDelay); if (!found) { sl.insert(); } } TransactionManager.commitTransaction(); log.debug("finished Processing lineups for schedules"); }
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 w w w .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.linkedin.pinot.core.query.scheduler.MultiLevelPriorityQueue.java
public MultiLevelPriorityQueue(@Nonnull Configuration config, @Nonnull ResourceManager resourceManager, @Nonnull SchedulerGroupFactory groupFactory, @Nonnull SchedulerGroupMapper groupMapper) { Preconditions.checkNotNull(config);//from w w w . ja v a 2 s .c o m Preconditions.checkNotNull(resourceManager); Preconditions.checkNotNull(groupFactory); Preconditions.checkNotNull(groupMapper); // max available tokens per millisecond equals number of threads (total execution capacity) // we are over provisioning tokens here because its better to keep pipe full rather than empty queryDeadlineMillis = config.getInt(QUERY_DEADLINE_SECONDS_KEY, 30) * 1000; wakeUpTimeMicros = config.getInt(QUEUE_WAKEUP_MICROS, DEFAULT_WAKEUP_MICROS); maxPendingPerGroup = config.getInt(MAX_PENDING_PER_GROUP_KEY, 10); this.config = config; this.resourceManager = resourceManager; this.groupFactory = groupFactory; this.groupSelector = groupMapper; }
From source file:dk.dma.ais.abnormal.analyzer.analysis.SpeedOverGroundAnalysis.java
@Inject public SpeedOverGroundAnalysis(Configuration configuration, AppStatisticsService statisticsService, StatisticDataRepository statisticsRepository, EventEmittingTracker trackingService, EventRepository eventRepository, BehaviourManager behaviourManager) { super(eventRepository, statisticsRepository, trackingService, behaviourManager); this.statisticsService = statisticsService; setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_SOG_PREDICTIONTIME_MAX, -1)); TOTAL_SHIP_COUNT_THRESHOLD = configuration.getInt(CONFKEY_ANALYSIS_SOG_CELL_SHIPCOUNT_MIN, 1000); PD = configuration.getFloat(CONFKEY_ANALYSIS_SOG_PD, 0.001f); SHIP_LENGTH_MIN = configuration.getInt(CONFKEY_ANALYSIS_SOG_SHIPLENGTH_MIN, 50); USE_AGGREGATED_STATS = configuration.getBoolean(CONFKEY_ANALYSIS_SOG_USE_AGGREGATED_STATS, false); LOG.info(getAnalysisName() + " created (" + this + ")."); }
From source file:dk.dma.ais.abnormal.analyzer.analysis.CourseOverGroundAnalysis.java
@Inject public CourseOverGroundAnalysis(Configuration configuration, AppStatisticsService statisticsService, StatisticDataRepository statisticsRepository, EventEmittingTracker trackingService, EventRepository eventRepository, BehaviourManager behaviourManager) { super(eventRepository, statisticsRepository, trackingService, behaviourManager); this.statisticsService = statisticsService; setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_COG_PREDICTIONTIME_MAX, -1)); TOTAL_SHIP_COUNT_THRESHOLD = configuration.getInt(CONFKEY_ANALYSIS_COG_CELL_SHIPCOUNT_MIN, 1000); PD = configuration.getFloat(CONFKEY_ANALYSIS_COG_PD, 0.001f); SHIP_LENGTH_MIN = configuration.getInt(CONFKEY_ANALYSIS_COG_SHIPLENGTH_MIN, 50); USE_AGGREGATED_STATS = configuration.getBoolean(CONFKEY_ANALYSIS_COG_USE_AGGREGATED_STATS, false); LOG.info(getAnalysisName() + " created (" + this + ")."); }
From source file:com.evolveum.midpoint.task.quartzimpl.TaskManagerConfiguration.java
void setBasicInformation(MidpointConfiguration masterConfig) throws TaskManagerConfigurationException { Configuration c = masterConfig.getConfiguration(TASK_MANAGER_CONFIG_SECTION); stopOnInitializationFailure = c.getBoolean(STOP_ON_INITIALIZATION_FAILURE_CONFIG_ENTRY, STOP_ON_INITIALIZATION_FAILURE_DEFAULT); threads = c.getInt(THREADS_CONFIG_ENTRY, THREADS_DEFAULT); clustered = c.getBoolean(CLUSTERED_CONFIG_ENTRY, CLUSTERED_DEFAULT); jdbcJobStore = c.getBoolean(JDBC_JOB_STORE_CONFIG_ENTRY, clustered); nodeId = System.getProperty(MIDPOINT_NODE_ID_PROPERTY); if (StringUtils.isEmpty(nodeId) && !clustered) { nodeId = NODE_ID_DEFAULT;// w w w . j av a2 s .c om } jmxHostName = System.getProperty(MIDPOINT_JMX_HOST_NAME_PROPERTY); String portString = System.getProperty(JMX_PORT_PROPERTY); if (StringUtils.isEmpty(portString)) { jmxPort = JMX_PORT_DEFAULT; } else { try { jmxPort = Integer.parseInt(portString); } catch (NumberFormatException nfe) { throw new TaskManagerConfigurationException( "Cannot get JMX management port - invalid integer value of " + portString, nfe); } } jmxConnectTimeout = c.getInt(JMX_CONNECT_TIMEOUT_CONFIG_ENTRY, JMX_CONNECT_TIMEOUT_DEFAULT); if (c.containsKey(TEST_MODE_CONFIG_ENTRY)) { midPointTestMode = c.getBoolean(TEST_MODE_CONFIG_ENTRY); LOGGER.trace(TEST_MODE_CONFIG_ENTRY + " present, its value = " + midPointTestMode); } else { LOGGER.trace(TEST_MODE_CONFIG_ENTRY + " NOT present"); Properties sp = System.getProperties(); if (sp.containsKey(SUREFIRE_PRESENCE_PROPERTY)) { LOGGER.info("Determined to run in a test environment, setting midPointTestMode to 'true'."); midPointTestMode = true; } else { midPointTestMode = false; } } LOGGER.trace("midPointTestMode = " + midPointTestMode); String useTI = c.getString(USE_THREAD_INTERRUPT_CONFIG_ENTRY, USE_THREAD_INTERRUPT_DEFAULT); try { useThreadInterrupt = UseThreadInterrupt.fromValue(useTI); } catch (IllegalArgumentException e) { throw new TaskManagerConfigurationException( "Illegal value for " + USE_THREAD_INTERRUPT_CONFIG_ENTRY + ": " + useTI, e); } quartzNodeRegistrationCycleTime = c.getInt(QUARTZ_NODE_REGISTRATION_INTERVAL_CONFIG_ENTRY, QUARTZ_NODE_REGISTRATION_CYCLE_TIME_DEFAULT); nodeRegistrationCycleTime = c.getInt(NODE_REGISTRATION_INTERVAL_CONFIG_ENTRY, NODE_REGISTRATION_CYCLE_TIME_DEFAULT); nodeTimeout = c.getInt(NODE_TIMEOUT_CONFIG_ENTRY, NODE_TIMEOUT_DEFAULT); jmxUsername = c.getString(JMX_USERNAME_CONFIG_ENTRY, JMX_USERNAME_DEFAULT); jmxPassword = c.getString(JMX_PASSWORD_CONFIG_ENTRY, JMX_PASSWORD_DEFAULT); waitingTasksCheckInterval = c.getInt(WAITING_TASKS_CHECK_INTERVAL_CONFIG_ENTRY, WAITING_TASKS_CHECK_INTERVAL_DEFAULT); stalledTasksCheckInterval = c.getInt(STALLED_TASKS_CHECK_INTERVAL_CONFIG_ENTRY, STALLED_TASKS_CHECK_INTERVAL_DEFAULT); stalledTasksThreshold = c.getInt(STALLED_TASKS_THRESHOLD_CONFIG_ENTRY, STALLED_TASKS_THRESHOLD_DEFAULT); stalledTasksRepeatedNotificationInterval = c.getInt( STALLED_TASKS_REPEATED_NOTIFICATION_INTERVAL_CONFIG_ENTRY, STALLED_TASKS_REPEATED_NOTIFICATION_INTERVAL_DEFAULT); runNowKeepsOriginalSchedule = c.getBoolean(RUN_NOW_KEEPS_ORIGINAL_SCHEDULE_CONFIG_ENTRY, RUN_NOW_KEEPS_ORIGINAL_SCHEDULE_DEFAULT); }
From source file:dk.dma.ais.abnormal.analyzer.analysis.CloseEncounterAnalysis.java
@Inject public CloseEncounterAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository) { super(eventRepository, trackingService, null); this.statisticsService = statisticsService; this.sogMin = configuration.getFloat(CONFKEY_ANALYSIS_CLOSEENCOUNTER_SOG_MIN, 5.0f); setTrackPredictionTimeMax(configuration.getInteger(CONFKEY_ANALYSIS_CLOSEENCOUNTER_PREDICTIONTIME_MAX, -1)); setAnalysisPeriodMillis(configuration.getInt(CONFKEY_ANALYSIS_CLOSEENCOUNTER_RUN_PERIOD, 30000) * 1000); LOG.info(this.getClass().getSimpleName() + " created (" + this + ")."); }
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;// w w w . jav a 2 s . co 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:keel.Algorithms.Neural_Networks.IRPropPlus_Clas.IRPropPlus.java
/** * <p>// w w w . j a v a 2s . c o m * @param settings Settings Configuration * </p> */ public void configure(Configuration settings) { initialStepSize = settings.getDouble("initial-step-size[@value]", 0.0125); minimumDelta = settings.getDouble("minimum-delta[@value]", 0.0); maximumDelta = settings.getDouble("maximum-delta[@value]", 50.0); positiveEta = settings.getDouble("positive-eta[@value]", 1.2); negativeEta = settings.getDouble("negative-eta[@value]", 0.2); epochs = settings.getInt("cycles[@value]", 25); }
From source file:com.salesmanager.central.orders.EditOrderDetailsAction.java
protected void prepareOrderDetails() throws Exception { super.setPageTitle("label.order.orderdetails.title"); Context ctx = (Context) super.getServletRequest().getSession().getAttribute(ProfileConstants.context); Integer merchantid = ctx.getMerchantid(); // Get the order OrderService oservice = (OrderService) ServiceFactory.getService(ServiceFactory.OrderService); CustomerService cservice = (CustomerService) ServiceFactory.getService(ServiceFactory.CustomerService); Order o = oservice.getOrder(this.getOrder().getOrderId()); // check if that entity realy belongs to merchantid if (o == null) { throw new AuthorizationException("Order is null for orderId " + this.getOrder().getOrderId()); }// w w w . j av a 2 s .com // Check if user is authorized super.authorize(o); this.setOrder(o); super.getServletRequest().getSession().setAttribute("lastorderid", String.valueOf(order.getOrderId())); Configuration conf = PropertiesUtil.getConfiguration(); int maxcount = conf.getInt("core.product.file.downloadmaxcount", 5); Map statusmap = RefCache.getOrderstatuswithlang(LanguageUtil.getLanguageNumberCode(ctx.getLang())); super.getServletRequest().setAttribute("orderid", String.valueOf(order.getOrderId())); super.getServletRequest().setAttribute("orderstatus", order.getOrderStatus()); // 2)GET PRODUCTS Set st1 = order.getOrderProducts(); boolean hasdownloadable = false; if (st1 != null) { this.orderproducts = new ArrayList(); Iterator opit = st1.iterator(); while (opit.hasNext()) { OrderProduct op = (OrderProduct) opit.next(); if (op.getDownloads() != null && op.getDownloads().size() > 0) { hasdownloadable = true; // check if download expired or downloadcount==0 Set opdSet = op.getDownloads(); downloads = opdSet; if (opdSet != null && opdSet.size() > 0) { Iterator opdIter = opdSet.iterator(); while (opdIter.hasNext()) { OrderProductDownload opd = (OrderProductDownload) opdIter.next(); if (opd.getDownloadCount() >= maxcount) { this.setDownloadexpired(true); break; } } } } op.setCurrency(ctx.getCurrency()); this.orderproducts.add(op); } } // //2)GET ORDER TOTAL Set st2 = order.getOrderTotal(); Map totals = new LinkedHashMap(); if (st2 != null) { this.ordertotals = new ArrayList(); Iterator otit = st2.iterator(); List tax = null; List refund = null; while (otit.hasNext()) { OrderTotal ot = (OrderTotal) otit.next(); this.ordertotals.add(ot); if (ot.getModule().equals("ot_tax")) { if (tax == null) { tax = new ArrayList(); } else { tax = (List) totals.get("ot_tax"); } tax.add(ot); totals.put("ot_tax", tax); } else if (ot.getModule().equals("ot_refund")) { if (refund == null) { refund = new ArrayList(); } else { refund = (List) totals.get("ot_refund"); } refund.add(ot); totals.put("ot_refund", refund); } else { totals.put(ot.getModule(), ot); } } } super.getServletRequest().setAttribute("ordertotals", totals); super.getServletRequest().setAttribute("hasdownloadable", hasdownloadable); StringBuffer ohsb = null; // 2)GET ORDER HISTORY Set st3 = order.getOrderHistory(); if (st3 != null) { Iterator ohit = st3.iterator(); ohsb = new StringBuffer(); while (ohit.hasNext()) { OrderStatusHistory ost = (OrderStatusHistory) ohit.next(); String status = ""; if (statusmap.containsKey(ost.getOrderStatusId())) { OrderStatus os = (OrderStatus) statusmap.get(ost.getOrderStatusId()); status = os.getOrderStatusName(); } else { status = String.valueOf(this.getOrder().getOrderId()); } ohsb.append("<b>").append(DateUtil.formatDate(ost.getDateAdded())).append("</b>"); ohsb.append(" - ").append(status); ohsb.append("<br>"); ohsb.append("----------------------------------"); if (ost.getComments() != null && !ost.getComments().trim().equals("")) { ohsb.append("<br>"); ohsb.append(ost.getComments()); } ohsb.append("<br><br>"); } } if (ohsb != null) { this.setCommentsHistory(ohsb.toString()); super.getServletRequest().setAttribute("comments", ohsb.toString()); } Customer cust = cservice.getCustomer(order.getCustomerId()); this.setCustomer(cust); if (cust != null) { int lang = LanguageUtil.getLanguageNumberCode(cust.getCustomerLang()); // 2) Set stateprovince if (cust.getCustomerState() != null && !cust.getCustomerState().trim().equals("")) { this.setCustomerStateProvince(cust.getCustomerState()); } else { Map z = RefCache.getAllZonesmap(lang); // shipping zone Zone zone = (Zone) z.get(cust.getCustomerZoneId()); if (zone != null) { this.setCustomerStateProvince(zone.getZoneName()); } } // 3) Set country Map countries = RefCache.getAllcountriesmap(lang); Country c = (Country) countries.get(cust.getCustomerCountryId()); if (c != null) { this.setCustomerCountry(c.getCountryName()); } else { this.setCustomerCountry(order.getBillingCountry()); } } }