本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例7: getMultipartCopyThreshold
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
public Long getMultipartCopyThreshold() {
return MapUtils.getLong(copierOptions, Keys.MULTIPART_COPY_THRESHOLD.keyName(), null);
}
示例8: getMultipartCopyPartSize
import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
public Long getMultipartCopyPartSize() {
return MapUtils.getLong(copierOptions, Keys.MULTIPART_COPY_PART_SIZE.keyName(), null);
}
示例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;
}
示例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;
}
示例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;
}