當前位置: 首頁>>代碼示例>>Java>>正文


Java MapUtils.getIntValue方法代碼示例

本文整理匯總了Java中org.apache.commons.collections.MapUtils.getIntValue方法的典型用法代碼示例。如果您正苦於以下問題:Java MapUtils.getIntValue方法的具體用法?Java MapUtils.getIntValue怎麽用?Java MapUtils.getIntValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.collections.MapUtils的用法示例。


在下文中一共展示了MapUtils.getIntValue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMachineInstanceCountMap

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
@Override
public Map<String, Integer> getMachineInstanceCountMap() {
 List<Map<String,Object>> mapList = instanceDao.getMachineInstanceCountMap();
 if (CollectionUtils.isEmpty(mapList)) {
     return Collections.emptyMap();
 }
 
 Map<String, Integer> resultMap = new HashMap<String, Integer>();
 for(Map<String,Object> map : mapList) {
     String ip = MapUtils.getString(map, "ip", "");
     if (StringUtils.isBlank(ip)) {
         continue;
     }
     int count = MapUtils.getIntValue(map, "count");
     resultMap.put(ip, count);
 }
    return resultMap;
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:19,代碼來源:MachineCenterImpl.java

示例2: fetchData

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
/**
 * 按區域抓取數據
 *
 * @param regionLink
 * @throws Exception
 */
private void fetchData(String regionLink) throws Exception {
    int sleepTime = 0;
    String regionHtml = LianJiaCrawler.INSTANCE.doGet(lianJiaParam.getBaseUrl() + regionLink, lianJiaParam.getAppProperties().getLiaJiaCookie());
    Document document = Jsoup.parse(regionHtml);
    if (LianJiaCrawler.INSTANCE.checkValidHtml(document)) {
        Element pageElement = document.select("div[comp-module='page']").first();
        // 獲取當前頁鏈接
        String curPageUrl;
        String pageUrl = pageElement.attr("page-url");
        Map pageData = JSON.parseObject(pageElement.attr("page-data"), Map.class);
        int curPage = MapUtils.getIntValue(pageData, "curPage");
        int totalPage = MapUtils.getIntValue(pageData, "totalPage") + 1;
        // 抓取每頁數據
        while (curPage <= totalPage) {
            curPageUrl = pageUrl.replace("{page}", String.valueOf(curPage));
            String listHtml = LianJiaCrawler.INSTANCE.doGet(lianJiaParam.getBaseUrl() + curPageUrl, lianJiaParam.getAppProperties().getLiaJiaCookie());
            document = Jsoup.parse(listHtml);
            if (LianJiaCrawler.INSTANCE.checkValidHtml(document)) {
                int count = 1;
                Elements contentElements = document.select("ul[class='sellListContent'] > li");
                Elements bigImgElements = document.select("div[class='bigImgList'] > div");

                for (Element contentElement : contentElements) {
                    LOGGER.info("開始檢查[{}],第{}頁,第{}條記錄", regionLink, curPage, count);
                    // 解析列表數據
                    EstateItemDTO dto = LianJiaCrawler.INSTANCE.parseListData(contentElement);
                    // 解析默認圖片
                    dto = LianJiaCrawler.INSTANCE.parseCoverImgData(dto, bigImgElements);

                    dto.setBatch(lianJiaParam.getBatch());
                    // 轉為二進製數據
                    byte[] dataArray = ProtoStuffUtil.serialize(dto);
                    // 發送消息
                    mqProducer.sendQueueMessage(dataArray, queueName);
                    count++;
                }
            }
            curPage++;

            if (curPage % 5 == 0) {
                sleepTime = 2000;
                Thread.sleep(sleepTime);
                LOGGER.info("休眠了{}毫秒", sleepTime);
            } else {
                sleepTime = new Random().nextInt(200);
                Thread.sleep(sleepTime);
                LOGGER.info("休眠了{}毫秒", sleepTime);
            }
        }
    }
}
 
開發者ID:lupindong,項目名稱:xq_seckill_microservice,代碼行數:58,代碼來源:LianJiaCheckCallable.java

示例3: parse

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
protected DistCpOptions parse(Map<String, Object> copierOptions) {
  if (copierOptions == null) {
    LOG.debug("Null copier options: nothing to parse");
    return distCpOptions;
  }

  List<FileAttribute> fileAttributes = MoreMapUtils.getListOfEnum(copierOptions, FILE_ATTRIBUTES,
      Collections.<FileAttribute> emptyList(), FileAttribute.class);
  for (FileAttribute fileAttribute : fileAttributes) {
    distCpOptions.preserve(fileAttribute);
  }
  if (MapUtils.getBoolean(copierOptions, PRESERVE_RAW_XATTRS, distCpOptions.shouldPreserveRawXattrs())) {
    distCpOptions.preserveRawXattrs();
  }
  distCpOptions.setAtomicWorkPath(
      MoreMapUtils.getHadoopPath(copierOptions, ATOMIC_WORK_PATH, distCpOptions.getAtomicWorkPath()));
  distCpOptions.setCopyStrategy(MapUtils.getString(copierOptions, COPY_STRATEGY, distCpOptions.getCopyStrategy()));
  distCpOptions
      .setIgnoreFailures(MapUtils.getBoolean(copierOptions, IGNORE_FAILURES, distCpOptions.shouldIgnoreFailures()));
  distCpOptions.setLogPath(MoreMapUtils.getHadoopPath(copierOptions, LOG_PATH, distCpOptions.getLogPath()));

  int taskBandwidth = MapUtils.getIntValue(copierOptions, TASK_BANDWIDTH, distCpOptions.getMapBandwidth());
  if (taskBandwidth <= 0) {
    throw new IllegalArgumentException("Parameter " + TASK_BANDWIDTH + " must be a positive integer.");
  }
  distCpOptions.setMapBandwidth(taskBandwidth);

  int maxMaps = MapUtils.getIntValue(copierOptions, MAX_MAPS, distCpOptions.getMaxMaps());
  if (maxMaps <= 0) {
    throw new IllegalArgumentException("Parameter " + MAX_MAPS + " must be a positive integer.");
  }
  distCpOptions.setMaxMaps(maxMaps);

  distCpOptions.setSslConfigurationFile(
      MapUtils.getString(copierOptions, SSL_CONFIGURATION_FILE, distCpOptions.getSslConfigurationFile()));
  // These validate: order is important
  distCpOptions
      .setAtomicCommit(MapUtils.getBoolean(copierOptions, ATOMIC_COMMIT, distCpOptions.shouldAtomicCommit()));
  distCpOptions.setSkipCRC(MapUtils.getBoolean(copierOptions, SKIP_CRC, distCpOptions.shouldSkipCRC()));
  return distCpOptions;
}
 
開發者ID:HotelsDotCom,項目名稱:circus-train,代碼行數:42,代碼來源:DistCpOptionsParser.java


注:本文中的org.apache.commons.collections.MapUtils.getIntValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。