List of usage examples for org.apache.commons.collections MapUtils getString
public static String getString(Map map, Object key, String defaultValue)
From source file:net.di2e.ecdr.commons.filter.StrictFilterDelegate.java
@Override public Map<String, String> handlePropertyIsEqualToNumber(String propertyName, double literal) { Map<String, String> filterContainer = new HashMap<String, String>(); filterContainer.put(MapUtils.getString(propertyMap, propertyName, propertyName), String.valueOf(literal)); return filterContainer; }
From source file:com.iisigroup.cap.batch.handler.BatchHandler.java
public Result schDetail(Request params) { AjaxFormResult result = new AjaxFormResult(); BatchSchedule sch = batchSrv.findSchById(params.get("schId")); Map<String, Object> map = CapBeanUtil.bean2Map(sch, CapBeanUtil.getFieldName(BatchSchedule.class, false)); map.put("notifyStatus", MapUtils.getString(map, "notifyStatus", "").split(",")); result.putAll(map);/*from ww w . jav a2 s .co m*/ return result; }
From source file:com.pinterest.teletraan.ConfigHelper.java
public static void scheduleWorkers(TeletraanServiceConfiguration configuration, TeletraanServiceContext serviceContext) throws Exception { List<WorkerConfig> workerConfigs = configuration.getWorkerConfigs(); for (WorkerConfig config : workerConfigs) { String workerName = config.getName(); Map<String, String> properties = config.getProperties(); int defaultValue = new Random().nextInt(30); int initDelay = MapUtils.getIntValue(properties, "initialDelay", defaultValue); int period = MapUtils.getIntValue(properties, "period", DEFAULT_PERIOD); if (workerName.equalsIgnoreCase(StateTransitioner.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new StateTransitioner(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.SECONDS); LOG.info("Scheduled StateTransitioner."); }/*from www . j a v a 2s .com*/ if (workerName.equalsIgnoreCase(AutoPromoter.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new AutoPromoter(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.SECONDS); LOG.info("Scheduled AutoPromoter."); } if (workerName.equalsIgnoreCase(HotfixStateTransitioner.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new HotfixStateTransitioner(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.SECONDS); LOG.info("Scheduled HotfixStateTransitioner."); } if (workerName.equalsIgnoreCase(SimpleAgentJanitor.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); int minStaleHostThreshold = MapUtils.getIntValue(properties, "minStaleHostThreshold", DEFAULT_MIN_STALE_HOST_THRESHOLD); int maxStaleHostThreshold = MapUtils.getIntValue(properties, "maxStaleHostThreshold", DEFAULT_MAX_STALE_HOST_THRESHOLD); Runnable worker = new SimpleAgentJanitor(serviceContext, minStaleHostThreshold, maxStaleHostThreshold); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.SECONDS); LOG.info("Scheduled SimpleAgentJanitor."); } if (workerName.equalsIgnoreCase(AgentJanitor.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); int minStaleHostThreshold = MapUtils.getIntValue(properties, "minStaleHostThreshold", DEFAULT_MIN_STALE_HOST_THRESHOLD); int maxStaleHostThreshold = MapUtils.getIntValue(properties, "maxStaleHostThreshold", DEFAULT_MAX_STALE_HOST_THRESHOLD); int maxLaunchLatencyThreshold = MapUtils.getIntValue(properties, "maxLaunchLaencyThreshold", DEFAULT_LAUNCH_LATENCY_THRESHOLD); Runnable worker = new AgentJanitor(serviceContext, minStaleHostThreshold, maxStaleHostThreshold, maxLaunchLatencyThreshold); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.SECONDS); LOG.info("Scheduled AgentJanitor."); } // Schedule cron like jobs JobDetail deployJanitorJob = null; CronTrigger deployJanitorTrigger = null; if (workerName.equalsIgnoreCase(DeployJanitor.class.getSimpleName())) { String schedule = MapUtils.getString(properties, "schedule", DEFAULT_DEPLOY_JANITOR_SCHEDULE); deployJanitorJob = JobBuilder.newJob(DeployJanitor.class).withIdentity("deployJanitorJob", "group1") .build(); deployJanitorTrigger = TriggerBuilder.newTrigger().forJob(deployJanitorJob) .withSchedule(CronScheduleBuilder.cronSchedule(schedule)).build(); } JobDetail buildJanitorJob = null; CronTrigger buildJanitorTrigger = null; if (workerName.equalsIgnoreCase(BuildJanitor.class.getSimpleName())) { String schedule = MapUtils.getString(properties, "schedule", DEFAULT_BUILD_JANITOR_SCHEDULE); int maxDaysToKeep = MapUtils.getIntValue(properties, "minStaleHostThreshold", DEFAULT_MAX_DAYS_TO_KEEP); int maxBuildsToKeep = MapUtils.getIntValue(properties, "maxStaleHostThreshold", DEFAULT_MAX_BUILDS_TO_KEEP); serviceContext.setMaxDaysToKeep(maxDaysToKeep); serviceContext.setMaxBuildsToKeep(maxBuildsToKeep); buildJanitorJob = JobBuilder.newJob(BuildJanitor.class).withIdentity("buildJanitorJob", "group1") .build(); buildJanitorTrigger = TriggerBuilder.newTrigger().forJob(buildJanitorJob) .withSchedule(CronScheduleBuilder.cronSchedule(schedule)).build(); } if (deployJanitorTrigger != null || buildJanitorTrigger != null) { Scheduler cronScheduler = new StdSchedulerFactory().getScheduler(); cronScheduler.getContext().put("serviceContext", serviceContext); cronScheduler.start(); if (deployJanitorTrigger != null) { cronScheduler.scheduleJob(deployJanitorJob, deployJanitorTrigger); LOG.info("Scheduled DeployJanitor."); } if (buildJanitorTrigger != null) { cronScheduler.scheduleJob(buildJanitorJob, buildJanitorTrigger); LOG.info("Scheduled BuildJanitor."); } } // TODO Arcee specific workers if (workerName.equalsIgnoreCase(LaunchLatencyUpdater.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new LaunchLatencyUpdater(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.SECONDS); LOG.info("Scheduled LaunchLatencyUpdater."); } if (workerName.equalsIgnoreCase(MetricsCollector.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new MetricsCollector(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.SECONDS); LOG.info("Scheduled MetricsCollector."); } if (workerName.equalsIgnoreCase(GroupInfoCollector.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new GroupInfoCollector(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.MINUTES); LOG.info("Scheduled GroupInfoCollector."); } if (workerName.equalsIgnoreCase(GroupInfoUpdater.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new GroupInfoUpdater(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.MINUTES); LOG.info("Scheduled GroupInfoUpdater."); } if (workerName.equalsIgnoreCase(LaunchEventCollector.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new LaunchEventCollector(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.MINUTES); LOG.info("Scheduled LaunchEventCollector."); } if (workerName.equalsIgnoreCase(HostTerminator.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new HostTerminator(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.MINUTES); LOG.info("Scheduled HostTerminator."); } if (workerName.equalsIgnoreCase(HealthChecker.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new HealthChecker(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.MINUTES); LOG.info("Scheduled HealthChecker."); } if (workerName.equalsIgnoreCase(HealthCheckInserter.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new HealthCheckInserter(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.MINUTES); LOG.info("Scheduled HealthCheckInserter."); } if (workerName.equalsIgnoreCase(HealthCheckHostTerminator.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new HealthCheckHostTerminator(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.MINUTES); LOG.info("Scheduled HealthCheckHostTerminator."); } if (workerName.equalsIgnoreCase(NewInstanceChecker.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new NewInstanceChecker(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.MINUTES); LOG.info("Scheduled NewInstanceChecker."); } if (workerName.equalsIgnoreCase(LifecycleUpdator.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new LifecycleUpdator(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.MINUTES); LOG.info("Scheduled LifecycleUpdator."); } if (workerName.equalsIgnoreCase(ReservedInstanceScheduler.class.getSimpleName())) { ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); Runnable worker = new ReservedInstanceScheduler(serviceContext); scheduler.scheduleAtFixedRate(worker, initDelay, period, TimeUnit.MINUTES); LOG.info("Scheduled ReservedInstanceScheduler."); } } }
From source file:net.di2e.ecdr.commons.filter.StrictFilterDelegate.java
@Override public Map<String, String> handleTimeDuring(String propertyName, Date start, Date end) { Map<String, String> filterContainer = new HashMap<String, String>(); filterContainer.put(SearchConstants.STARTDATE_PARAMETER, DATE_FORMATTER.print(start.getTime())); filterContainer.put(SearchConstants.ENDDATE_PARAMETER, DATE_FORMATTER.print(end.getTime())); filterContainer.put(SearchConstants.DATETYPE_PARAMETER, MapUtils.getString(dateTypeMap, propertyName, propertyName)); return filterContainer; }
From source file:net.di2e.ecdr.commons.filter.StrictFilterDelegate.java
@Override public Map<String, String> handleTimeAfter(String propertyName, Date start, boolean inclusive) { Map<String, String> filterContainer = new HashMap<String, String>(); filterContainer.put(SearchConstants.STARTDATE_PARAMETER, DATE_FORMATTER.print(start.getTime())); filterContainer.put(SearchConstants.DATETYPE_PARAMETER, MapUtils.getString(dateTypeMap, propertyName, propertyName)); return filterContainer; }
From source file:net.di2e.ecdr.commons.filter.StrictFilterDelegate.java
@Override public Map<String, String> handleTimeBefore(String propertyName, Date end, boolean inclusive) { Map<String, String> filterContainer = new HashMap<String, String>(); filterContainer.put(SearchConstants.ENDDATE_PARAMETER, DATE_FORMATTER.print(end.getTime())); filterContainer.put(SearchConstants.DATETYPE_PARAMETER, MapUtils.getString(dateTypeMap, propertyName, propertyName)); return filterContainer; }
From source file:org.apache.hadoop.hive.ql.parse.MergeSemanticAnalyzer.java
private String replaceDefaultKeywordForMerge(String valueClause, Table table, ASTNode columnListNode) throws SemanticException { if (!valueClause.toLowerCase().contains("`default`")) { return valueClause; }/* ww w . j av a 2s . co m*/ Map<String, String> colNameToDefaultConstraint = getColNameToDefaultValueMap(table); String[] values = valueClause.trim().split(","); String[] replacedValues = new String[values.length]; // the list of the column names may be set in the query String[] columnNames = columnListNode == null ? table.getAllCols().stream().map(f -> f.getName()).toArray(size -> new String[size]) : columnListNode.getChildren().stream().map(n -> ((ASTNode) n).toString()) .toArray(size -> new String[size]); for (int i = 0; i < values.length; i++) { if (values[i].trim().toLowerCase().equals("`default`")) { replacedValues[i] = MapUtils.getString(colNameToDefaultConstraint, columnNames[i], "null"); } else { replacedValues[i] = values[i]; } } return StringUtils.join(replacedValues, ','); }
From source file:org.eclipse.jubula.client.core.businessprocess.TestExecution.java
/** * Initializes all pre-defined variables for execution of the given * test suite./*w w w . ja va 2 s .co m*/ * * @param varStore The place to store the variables. * @param testSuite The test suite that will be executed. Some variables * have values based on this test suite. */ private void storePredefinedVariables(TDVariableStore varStore, ITestSuitePO testSuite) { // TEST_language varStore.store(TDVariableStore.VAR_LANG, m_executionLanguage.toString()); // TEST_testsuite varStore.store(TDVariableStore.VAR_TS, testSuite.getName()); // TEST_username varStore.store(TDVariableStore.VAR_USERNAME, System.getProperty("user.name")); //$NON-NLS-1$ // TEST_dbusername varStore.store(TDVariableStore.VAR_DBUSERNAME, Persistor.instance().getCurrentDBUser()); try { AutAgentConnection serverConn = AutAgentConnection.getInstance(); // TEST_autstarter varStore.store(TDVariableStore.VAR_AUTAGENT, serverConn.getCommunicator().getHostName()); // TEST_portnumber varStore.store(TDVariableStore.VAR_PORT, String.valueOf(serverConn.getCommunicator().getPort())); } catch (ConnectionException ce) { // No connection to AutStarter. // Do nothing. } // TEST_aut varStore.store(TDVariableStore.VAR_AUT, testSuite.getAut().getName()); // TEST_autconfig Map<String, String> autConfigMap = getConnectedAUTsConfigMap(); if (autConfigMap != null) { varStore.store(TDVariableStore.VAR_AUTCONFIG, MapUtils.getString(autConfigMap, AutConfigConstants.CONFIG_NAME, TestresultSummaryBP.AUTRUN)); } else { // write constant for AUTs which has been started via autrun varStore.store(TDVariableStore.VAR_AUTCONFIG, TestresultSummaryBP.AUTRUN); } // TEST_clientVersion varStore.store(TDVariableStore.VAR_CLIENTVERSION, Platform.getBundle(Activator.PLUGIN_ID).getHeaders().get(Constants.BUNDLE_VERSION)); }
From source file:org.eclipse.jubula.client.core.model.AUTConfigPO.java
/** * Gets a value of this AutConfig. Keys are defined in * {@link IAutConfigKeys}.<br>/*w w w .j av a2 s .com*/ * If the given key does not exists, it returns an empty String! * * @param key * an AutConfigKey enum. * @param defaultValue * a defaut value to return if the given key is unknown. * @return the value of the given key. */ public String getValue(String key, String defaultValue) { return MapUtils.getString(getHbmConfigMap(), key, defaultValue); }
From source file:org.eclipse.jubula.client.core.model.TestResult.java
/** * {@inheritDoc} */ public String getAutAgentHostName() { return MapUtils.getString(getAutConfigMap(), AutConfigConstants.SERVER, StringConstants.EMPTY); }