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


Java MapUtils.getLong方法代碼示例

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


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

示例1: configRoleResources

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
/**
 * 配置角色-資源關係
 * @param request
 * @param response
 * @param parameter
 * @return
 */
@RequestMapping(value="/admin/role/config/submit", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON)
@HttpAccessLogging(title="係統管理/角色管理/配置角色資源關係")
public Object configRoleResources(HttpServletRequest request, HttpServletResponse response,  @RequestBody Map<String,Object> parameter) {
	List<Long> resourceIdList = new ArrayList<Long>();
	String resourceIds = MapUtils.getString(parameter, "resourceIds");
	Long roleId = MapUtils.getLong(parameter, "roleId");
	if(!StringUtils.isEmpty(resourceIds)){
		String[] resourceIdArray = resourceIds.split(",");
		if(resourceIdArray != null && resourceIdArray.length > 0){
			for(String resourceId : resourceIdArray){
				resourceIdList.add(Long.valueOf(resourceId));
			}
		}
	}
	LoginToken<AdminUser> loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY);
	adminRoleService.configRoleResources(roleId, resourceIdList, loginToken.getLoginId(), DateTimeUtils.formatNow());
	return genSuccessResult("配置成功!", null);
}
 
開發者ID:penggle,項目名稱:xproject,代碼行數:26,代碼來源:AdminRoleMgtController.java

示例2: addUserRoles

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
/**
 * 添加用戶-角色配置
 * @param request
 * @param response
 * @param userId
 * @param roleIds
 * @return
 */
@RequestMapping(value="/admin/user/config/add", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON)
@HttpAccessLogging(title="係統管理/用戶管理/添加用戶角色配置")
public Object addUserRoles(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String,Object> parameter) {
	Long userId = MapUtils.getLong(parameter, "userId");
	String roleIds = MapUtils.getString(parameter, "roleIds");
	List<Long> roleIdList = new ArrayList<Long>();
	if(!StringUtils.isEmpty(roleIds)){
		String[] roleIdArray = roleIds.split(",");
		if(roleIdArray != null && roleIdArray.length > 0){
			for(String roleId : roleIdArray){
				roleIdList.add(Long.valueOf(roleId));
			}
		}
	}
	
	LoginToken<AdminUser> loginToken = ShiroUtils.getSessionAttribute(LoginToken.LOGIN_TOKEN_SESSION_KEY);
	AdminUser user = new AdminUser();
	user.setUserId(userId);
	adminUserService.addUserRoles(user, roleIdList, loginToken.getLoginId(), DateTimeUtils.formatNow());
	return genSuccessResult("添加成功!", null);
}
 
開發者ID:penggle,項目名稱:xproject,代碼行數:30,代碼來源:AdminUserMgtController.java

示例3: delUserRoles

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
/**
 * 刪除戶-角色配置
 * @param request
 * @param response
 * @param userId
 * @param roleIds
 * @return
 */
@RequestMapping(value="/admin/user/config/del", method=POST, consumes=APPLICATION_JSON, produces=APPLICATION_JSON)
@HttpAccessLogging(title="係統管理/用戶管理/刪除用戶角色配置")
public Object delUserRoles(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String,Object> parameter) {
	Long userId = MapUtils.getLong(parameter, "userId");
	String roleIds = MapUtils.getString(parameter, "roleIds");
	List<Long> roleIdList = new ArrayList<Long>();
	if(!StringUtils.isEmpty(roleIds)){
		String[] roleIdArray = roleIds.split(",");
		if(roleIdArray != null && roleIdArray.length > 0){
			for(String roleId : roleIdArray){
				roleIdList.add(Long.valueOf(roleId));
			}
		}
	}
	AdminUser user = new AdminUser();
	user.setUserId(userId);
	adminUserService.delUserRoles(user, roleIdList);
	return genSuccessResult("刪除成功!", null);
}
 
開發者ID:penggle,項目名稱:xproject,代碼行數:28,代碼來源:AdminUserMgtController.java

示例4: getCommandStatsList

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
private List<AppCommandStats> getCommandStatsList(long appId, long collectTime,
                                                  Table<RedisConstant, String, Long> table) {
    Map<String, Long> commandMap = table.row(RedisConstant.Commandstats);
    List<AppCommandStats> list = new ArrayList<AppCommandStats>();
    if (commandMap == null) {
        return list;
    }
    for (String key : commandMap.keySet()) {
        String commandName = key.replace("cmdstat_", "");
        long callCount = MapUtils.getLong(commandMap, key, 0L);
        if (callCount == 0L) {
            continue;
        }
        AppCommandStats commandStats = new AppCommandStats();
        commandStats.setAppId(appId);
        commandStats.setCollectTime(collectTime);
        commandStats.setCommandName(commandName);
        commandStats.setCommandCount(callCount);
        commandStats.setModifyTime(new Date());
        list.add(commandStats);
    }
    return list;
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:24,代碼來源:RedisCenterImpl.java

示例5: getCommandsDiff

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
/**
 * 獲取命令差值統計
 *
 * @param currentInfoMap
 * @param lastInfoMap
 * @return 命令統計
 */
private Table<RedisConstant, String, Long> getCommandsDiff(Map<RedisConstant, Map<String, Object>> currentInfoMap,
                                                           Map<String, Object> lastInfoMap) {
    //沒有上一次統計快照,忽略差值統計
    if (lastInfoMap == null || lastInfoMap.isEmpty()) {
        return HashBasedTable.create();
    }
    Map<String, Object> map = currentInfoMap.get(RedisConstant.Commandstats);
    Map<String, Long> currentMap = transferLongMap(map);
    Map<String, Object> lastObjectMap;
    if (lastInfoMap.get(RedisConstant.Commandstats.getValue()) == null) {
        lastObjectMap = new HashMap<String, Object>();
    } else {
        lastObjectMap = (Map<String, Object>) lastInfoMap.get(RedisConstant.Commandstats.getValue());
    }
    Map<String, Long> lastMap = transferLongMap(lastObjectMap);

    Table<RedisConstant, String, Long> resultTable = HashBasedTable.create();
    for (String command : currentMap.keySet()) {
        long lastCount = MapUtils.getLong(lastMap, command, 0L);
        long currentCount = MapUtils.getLong(currentMap, command, 0L);
        if (currentCount > lastCount) {
            resultTable.put(RedisConstant.Commandstats, command, currentCount - lastCount);
        }
    }
    return resultTable;
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:34,代碼來源:RedisCenterImpl.java

示例6: getRedisMaxMemory

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
@Override
public Long getRedisMaxMemory(final long appId, final String ip, final int port) {
    final String key = "maxmemory";
    final Map<String, Long> resultMap = new HashMap<String, Long>();
    boolean isSuccess = new IdempotentConfirmer() {
        private int timeOutFactor = 1;

        @Override
        public boolean execute() {
            Jedis jedis = null;
            try {
                jedis = getJedis(appId, ip, port);
                jedis.getClient().setConnectionTimeout(REDIS_DEFAULT_TIME * (timeOutFactor++));
                jedis.getClient().setSoTimeout(REDIS_DEFAULT_TIME * (timeOutFactor++));
                List<String> maxMemoryList = jedis.configGet(key); // 返回結果:list中是2個字符串,如:"maxmemory",
                // "4096000000"
                if (maxMemoryList != null && maxMemoryList.size() >= 2) {
                    resultMap.put(key, Long.valueOf(maxMemoryList.get(1)));
                }
                return MapUtils.isNotEmpty(resultMap);
            } catch (Exception e) {
                logger.warn("{}:{} errorMsg: {}", ip, port, e.getMessage());
                return false;
            } finally {
                if (jedis != null) {
                    jedis.close();
                }
            }
        }
    }.run();
    if (isSuccess) {
        return MapUtils.getLong(resultMap, key);
    } else {
        logger.error("{}:{} getMaxMemory failed!", ip, port);
        return null;
    }
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:38,代碼來源:RedisCenterImpl.java

示例7: getMultipartCopyThreshold

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
public Long getMultipartCopyThreshold() {
  return MapUtils.getLong(copierOptions, Keys.MULTIPART_COPY_THRESHOLD.keyName(), null);
}
 
開發者ID:HotelsDotCom,項目名稱:circus-train,代碼行數:4,代碼來源:S3S3CopierOptions.java

示例8: getMultipartCopyPartSize

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
public Long getMultipartCopyPartSize() {
  return MapUtils.getLong(copierOptions, Keys.MULTIPART_COPY_PART_SIZE.keyName(), null);
}
 
開發者ID:HotelsDotCom,項目名稱:circus-train,代碼行數:4,代碼來源:S3S3CopierOptions.java

示例9: inspect

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
@Override
public boolean inspect(Map<InspectParamEnum, Object> paramMap) {
    Long appId = MapUtils.getLong(paramMap, InspectParamEnum.SPLIT_KEY);
    AppDetailVO appDetailVO = appStatsCenter.getAppDetail(appId);
    if (appDetailVO == null) {
        logger.warn("appId {} appDetailVO is empty", appId);
        return true;
    }
    List<InstanceInfo> appInstanceInfoList = (List<InstanceInfo>) paramMap.get(InspectParamEnum.INSTANCE_LIST);
    if (CollectionUtils.isEmpty(appInstanceInfoList)) {
        logger.warn("appId {} instanceList is empty", appId);
        return true;
    }
    // 報警閥值
    int appClientConnThreshold = getClientConnThreshold(appDetailVO.getAppDesc());
    int appClientConnNum = appDetailVO.getConn();
    // 閥值乘以分片個數
    int instanceCount = appInstanceInfoList.size();
    if (appClientConnNum > appClientConnThreshold * instanceCount) {
        alertAppClientConn(appDetailVO, appClientConnThreshold, instanceCount);
    } else {
        for (InstanceInfo instanceInfo : appInstanceInfoList) {
            if (instanceInfo == null) {
                continue;
            }
            if (instanceInfo.isOffline()) {
                continue;
            }
            if (!TypeUtil.isRedisType(instanceInfo.getType())) {
                continue;
            }
            // 忽略sentinel觀察者
            if (TypeUtil.isRedisSentinel(instanceInfo.getType())) {
                continue;
            }
            long instanceId = instanceInfo.getId();
            InstanceStats instanceStats = instanceStatsCenter.getInstanceStats(instanceId);
            if (instanceStats == null) {
                continue;
            }
            double instanceClientConnNum = instanceStats.getCurrConnections();
            // 大於標準值
            if (instanceClientConnNum > appClientConnThreshold) {
                alertInstanceClientConn(instanceStats, appDetailVO, appClientConnThreshold);
            }
        }
    }
    return true;
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:50,代碼來源:AppClientConnInspector.java

示例10: inspect

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
@Override
public boolean inspect(Map<InspectParamEnum, Object> paramMap) {
    Long appId = MapUtils.getLong(paramMap, InspectParamEnum.SPLIT_KEY);
    List<AppDesc> appDescList = new ArrayList<AppDesc>();
    AppDesc app = appDao.getAppDescById(appId);
    if (app != null) {
        appDescList.add(app);
    }
    if (CollectionUtils.isEmpty(appDescList)) {
        logger.error("appList is empty, appId={}", appId);
        return true;
    }
    for (AppDesc appDesc : appDescList) {
        //測試不檢查
        if(appDesc.getIsTest() == 1){
            continue;
        }
        long checkAppId = appDesc.getAppId();
        AppDetailVO appDetailVO = appStatsCenter.getAppDetail(checkAppId);
        if (appDetailVO == null) {
            continue;
        }
        double appMemUsePercent = appDetailVO.getMemUsePercent();
        int appUseSetMemAlertValue = appDesc.getMemAlertValue();
        // 先檢查應用的內存使用率是否超過閥值,如果沒有再檢查分片
        if (appMemUsePercent > appUseSetMemAlertValue) {
            // 報警
            alertAppMemUse(appDetailVO);
        } else {
            List<InstanceInfo> appInstanceInfoList = (List<InstanceInfo>) paramMap.get(InspectParamEnum.INSTANCE_LIST);
            if (CollectionUtils.isNotEmpty(appInstanceInfoList)) {
                for (InstanceInfo instanceInfo : appInstanceInfoList) {
                    if (instanceInfo == null) {
                        continue;
                    }
                    if (!TypeUtil.isRedisType(instanceInfo.getType())) {
                        continue;
                    }
                    // 忽略sentinel觀察者
                    if (TypeUtil.isRedisSentinel(instanceInfo.getType())) {
                        continue;
                    }
                    long instanceId = instanceInfo.getId();
                    InstanceStats instanceStats = instanceStatsCenter.getInstanceStats(instanceId);
                    if(instanceStats == null){
                        continue;
                    }
                    double instanceMemUsePercent = instanceStats.getMemUsePercent();
                    // 大於標準值
                    if (instanceMemUsePercent > appUseSetMemAlertValue) {
                        alertInstanceMemUse(instanceStats, appDetailVO);
                    }
                }
            }
        }
    }
    return true;
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:59,代碼來源:AppMemInspector.java

示例11: generate

import org.apache.commons.collections.MapUtils; //導入方法依賴的package包/類
private AppClientExceptionStat generate(String clientIp, long collectTime, long reportTime, Map<String, Object> map) {

        // 異常信息
        String exceptionClass = MapUtils.getString(map, ClientReportConstant.EXCEPTION_CLASS, "");
        Long exceptionCount = MapUtils.getLong(map, ClientReportConstant.EXCEPTION_COUNT, 0L);
        int exceptionType = MapUtils.getInteger(map, ClientReportConstant.EXCEPTION_TYPE, ClientExceptionType.REDIS_TYPE.getType());

        String host = null;
        Integer port = null;
        Integer instanceId = null;
        long appId;
        if (ClientExceptionType.REDIS_TYPE.getType() == exceptionType) {
            // 實例host:port
            String hostPort = MapUtils.getString(map, ClientReportConstant.EXCEPTION_HOST_PORT, "");
            if (StringUtils.isEmpty(hostPort)) {
                logger.warn("hostPort is empty", hostPort);
                return null;
            }
            int index = hostPort.indexOf(":");
            if (index <= 0) {
                logger.warn("hostPort {} format is wrong", hostPort);
                return null;
            }
            host = hostPort.substring(0, index);
            port = NumberUtils.toInt(hostPort.substring(index + 1));

            // 實例信息
            InstanceInfo instanceInfo = clientReportInstanceService.getInstanceInfoByHostPort(host, port);
            if (instanceInfo == null) {
//                logger.warn("instanceInfo is empty, host is {}, port is {}", host, port);
                return null;
            }
            // 實例id
            instanceId = instanceInfo.getId();
            // 應用id
            appId = instanceInfo.getAppId();
        } else {
            List<AppClientVersion> appClientVersion = appClientVersionDao.getByClientIp(clientIp);
            if (CollectionUtils.isNotEmpty(appClientVersion)) {
                appId = appClientVersion.get(0).getAppId();
            } else {
                appId = 0;
            }
        }

        // 組裝AppClientExceptionStat
        AppClientExceptionStat stat = new AppClientExceptionStat();
        stat.setAppId(appId);
        stat.setClientIp(clientIp);
        stat.setReportTime(new Date(reportTime));
        stat.setCollectTime(collectTime);
        stat.setCreateTime(new Date());
        stat.setExceptionClass(exceptionClass);
        stat.setExceptionCount(exceptionCount);
        stat.setInstanceHost(host);
        stat.setInstancePort(port);
        stat.setInstanceId(instanceId);
        stat.setType(exceptionType);

        return stat;
    }
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:62,代碼來源:ClientReportExceptionServiceImpl.java


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