List of usage examples for org.springframework.util CollectionUtils isEmpty
public static boolean isEmpty(@Nullable Map<?, ?> map)
From source file:com.asuraiv.coordination.Master.java
/** * @param rc// w ww.ja va 2s . com * @param path * @param ctx * @param children * @see org.apache.zookeeper.AsyncCallback.ChildrenCallback#processResult(int, java.lang.String, java.lang.Object, java.util.List) */ public void processResult(int rc, String path, Object ctx, List<String> children) { if (CollectionUtils.isEmpty(children)) { return; } for (String task : children) { String taskStatus = zkUtils.getData("/tasks/" + task); if (!TaskStatus.WAITING.name().equals(taskStatus)) { continue; } // Worker . String availableWorker = getAvailableWorkers(); LOG.info("[MASTER] {} ? {} ? .", availableWorker, task); zkUtils.asyncCreate("/assign/" + availableWorker, task.getBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL, null, null); // Watcher ? zkUtils.asyncGetChildren("/tasks", true, /* AsyncCallback.ChildrenCallback */this, null); } }
From source file:com.alibaba.otter.manager.biz.monitor.impl.PositionTimeoutRuleMonitor.java
@Override public void explore(List<AlarmRule> rules) { if (CollectionUtils.isEmpty(rules)) { return;// w w w . j a v a 2 s .com } Long pipelineId = rules.get(0).getPipelineId(); Pipeline pipeline = pipelineService.findById(pipelineId); PositionEventData data = arbitrateViewService.getCanalCursor(pipeline.getParameters().getDestinationName(), pipeline.getParameters().getMainstemClientId()); long latestSyncTime = 0L; if (data != null && data.getModifiedTime() != null) { Date modifiedDate = data.getModifiedTime(); latestSyncTime = modifiedDate.getTime(); } else { return; } long now = System.currentTimeMillis(); long elapsed = now - latestSyncTime; boolean flag = false; for (AlarmRule rule : rules) { flag |= checkTimeout(rule, elapsed); } if (flag) { logRecordAlarm(pipelineId, MonitorName.POSITIONTIMEOUT, String.format(TIME_OUT_MESSAGE, pipelineId, (elapsed / 1000))); } }
From source file:com.alibaba.otter.manager.biz.monitor.impl.ProcessTimeoutRuleMonitor.java
@Override public void explore(List<AlarmRule> rules) { if (CollectionUtils.isEmpty(rules)) { return;/*from ww w .j av a2 s . c o m*/ } Long pipelineId = rules.get(0).getPipelineId(); List<ProcessStat> processStats = processStatService.listRealtimeProcessStat(pipelineId); if (CollectionUtils.isEmpty(processStats)) { return; } long now = System.currentTimeMillis(); Map<Long, Long> processTime = new HashMap<Long, Long>(); for (ProcessStat processStat : processStats) { Long timeout = 0L; if (!CollectionUtils.isEmpty(processStat.getStageStats())) { timeout = now - processStat.getStageStats().get(0).getStartTime(); } processTime.put(processStat.getProcessId(), timeout); } String message = StringUtils.EMPTY; for (AlarmRule rule : rules) { if (message.isEmpty()) { message = checkTimeout(rule, processTime); } else { checkTimeout(rule, processTime); } } if (!message.isEmpty()) { logRecordAlarm(pipelineId, MonitorName.PROCESSTIMEOUT, message); } }
From source file:org.suren.autotest.web.framework.selenium.action.SeleniumZTreeSequenceOperation.java
@Override public void perform(Element element, List<String> actions) { if (CollectionUtils.isEmpty(actions) || actions.size() <= 1) { throw new RuntimeException("Error format."); }/*ww w.ja va 2s .co m*/ String parentXPath = actions.get(0); String xpath = parentXPath; WebDriver driver = engine.getDriver(); WebElement parentEle = driver.findElement(By.xpath(xpath)); int index = 1; for (; index < actions.size() - 1; index++) { xpath = String.format("%s/descendant::span[contains(text(),'%s')]", parentXPath, actions.get(index)); logger.debug(xpath); parentEle = parentEle.findElement(By.xpath(xpath)); String id = parentEle.getAttribute("id"); logger.debug(id); if (StringUtils.isBlank(id)) { return; } id = id.replace("span", "switch"); logger.debug(id); WebDriverWait wait = new WebDriverWait(engine.getDriver(), 30); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(id))); parentEle = driver.findElement(By.id(id)); if (parentEle.getAttribute("class").endsWith("close")) { parentEle.click(); } ThreadUtil.silentSleep(2000); } xpath = String.format("%s/descendant::span[contains(text(),'%s')]", parentXPath, actions.get(index)); logger.debug(xpath); WebDriverWait wait = new WebDriverWait(engine.getDriver(), 30); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath))); parentEle.findElement(By.xpath(xpath)).click(); }
From source file:com.alibaba.otter.manager.biz.monitor.impl.PipelineTimeoutRuleMonitor.java
@Override public void explore(List<AlarmRule> rules) { if (CollectionUtils.isEmpty(rules)) { return;/* w w w . j a va2s . co m*/ } Long pipelineId = rules.get(0).getPipelineId(); ThroughputCondition condition = new ThroughputCondition(); condition.setPipelineId(pipelineId); condition.setType(ThroughputType.ROW); ThroughputStat stat = throughputStatService.findThroughputStatByPipelineId(condition); long latestSyncTime = 0L; if (stat != null && stat.getGmtModified() != null) { Date modifiedDate = stat.getGmtModified(); latestSyncTime = modifiedDate.getTime(); } long now = System.currentTimeMillis(); long elapsed = now - latestSyncTime; boolean flag = false; for (AlarmRule rule : rules) { flag |= checkTimeout(rule, elapsed); } if (flag) { logRecordAlarm(pipelineId, MonitorName.PIPELINETIMEOUT, String.format(TIME_OUT_MESSAGE, pipelineId, (elapsed / 1000))); } }
From source file:pe.gob.mef.gescon.service.impl.EntidadServiceImpl.java
@Override public List<Entidad> getEntidadesUbigeo() { List<Entidad> lista = new ArrayList<Entidad>(); try {/*from ww w. ja v a 2 s . com*/ EntidadDao entidadDao = (EntidadDao) ServiceFinder.findBean("EntidadDao"); List<HashMap> entidad = entidadDao.getEntidadesUbigeo(); if (!CollectionUtils.isEmpty(entidad)) { for (HashMap map : entidad) { Entidad c = new Entidad(); c.setNentidadid((BigDecimal) map.get("ID")); c.setVcodigoentidad((String) map.get("CODIGO")); c.setVnombre((String) map.get("NOMBRE")); c.setVdescripcion((String) map.get("DES")); c.setVusuariocreacion((String) map.get("USUC")); c.setDfechacreacion((Date) map.get("FECHAC")); c.setVusuariomodificacion((String) map.get("USUM")); c.setDfechamodificacion((Date) map.get("FECHAM")); c.setNactivo((BigDecimal) map.get("ACTIVO")); c.setVdepartamento((String) map.get("DEPARTAMENTO")); c.setVprovincia((String) map.get("PROVINCIA")); c.setVdistrito((String) map.get("DISTRITO")); c.setVtipo((String) map.get("TIPO")); lista.add(c); } } } catch (Exception e) { e.getMessage(); e.printStackTrace(); } return lista; }
From source file:com.devicehive.handler.command.CommandSubscribeRequestHandler.java
@Override public Response handle(Request request) { CommandSubscribeRequest body = (CommandSubscribeRequest) request.getBody(); validate(body);/*from ww w.j a v a 2 s . co m*/ Subscriber subscriber = new Subscriber(body.getSubscriptionId(), request.getReplyTo(), request.getCorrelationId()); Set<Subscription> subscriptions = new HashSet<>(); if (CollectionUtils.isEmpty(body.getNames())) { Subscription subscription = new Subscription(Action.COMMAND_EVENT.name(), body.getDevice()); subscriptions.add(subscription); } else { for (String name : body.getNames()) { Subscription subscription = new Subscription(Action.COMMAND_EVENT.name(), body.getDevice(), name); subscriptions.add(subscription); } } subscriptions.forEach(subscription -> eventBus.subscribe(subscriber, subscription)); Collection<DeviceCommand> commands = findCommands(body.getDevice(), body.getNames(), body.getTimestamp()); CommandSubscribeResponse subscribeResponse = new CommandSubscribeResponse(body.getSubscriptionId(), commands); return Response.newBuilder().withBody(subscribeResponse).withLast(false) .withCorrelationId(request.getCorrelationId()).buildSuccess(); }
From source file:com.mysoft.b2b.event.scheduler.job.EventLogJob.java
@Override public void run() { log.info("??-->......."); List<EventLog> eventLogs = this.getEventLogs(); int total = CollectionUtils.isEmpty(eventLogs) ? 0 : eventLogs.size(); log.info("??-->???:" + total); if (0 == total) { log.info("??-->???"); return;/*from www . j a va 2s. co m*/ } for (int i = 0; i < eventLogs.size(); i++) { log.info("??-->" + (i + 1) + "?"); EventLog eventLog = eventLogs.get(i); try { //EventLog? this.startToDealJob(eventLog); //?? App app = this.getAppById(eventLog.getAppId()); if (null == app) { continue; } if (ProtocolType.RMI.getValue() == app.getProtocolType()) { Event event = eventService.getEvent(eventLog.getEventId()); RMIClientHelper.getRMIProtocolService(app.getProtocolAddr()).dealEvent(event); } this.finishToDealJob(true, eventLog, null); } catch (Exception e) { this.finishToDealJob(false, eventLog, e); } } }
From source file:com.dianping.dpsf.invoke.filter.MockInvokeFilter.java
@Override public DPSFResponse invoke(RemoteInvocationHandler handler, InvocationInvokeContext invocationContext) throws Throwable { MockMeta mockMeta = invocationContext.getMetaData().getMockMeta(); try {//from w w w . j a v a 2 s. c o m DPSFResponse response = handler.handle(invocationContext); if (response.getMessageType() == Constants.MESSAGE_TYPE_SERVICE_EXCEPTION || response.getMessageType() == Constants.MESSAGE_TYPE_EXCEPTION) { if (mockMeta != null && StringUtils.isNotBlank(mockMeta.getMockClass()) && !CollectionUtils.isEmpty(mockMeta.getMockMethods())) { return createMockResponse(invocationContext, mockMeta); } } return response; } catch (Exception e) { return createMockResponse(invocationContext, mockMeta); } }