本文整理汇总了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;
}
示例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);
}
}
}
}
示例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;
}