当前位置: 首页>>代码示例>>Java>>正文


Java MapUtils.getInteger方法代码示例

本文整理汇总了Java中org.apache.commons.collections.MapUtils.getInteger方法的典型用法代码示例。如果您正苦于以下问题:Java MapUtils.getInteger方法的具体用法?Java MapUtils.getInteger怎么用?Java MapUtils.getInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.collections.MapUtils的用法示例。


在下文中一共展示了MapUtils.getInteger方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeSeckillByProcedure

import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
@Override
public SeckillExecution executeSeckillByProcedure(long seckillId, long userPhone, String md5) {
    if (md5 == null || !md5.equals(getMD5(seckillId))) {
        return new SeckillExecution(seckillId, StateEnum.DATA_REWITE);
    }

    Date killTime = new Date();
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("seckillId", seckillId);
    map.put("phone", userPhone);
    map.put("killTime", killTime);
    map.put("result", null);
    try {
        seckillDao.seckillByProcedure(map);
        int result = MapUtils.getInteger(map, "result", -2);
        if (result == 1) {
            SuccessKilled sk = successKilledDao.selectByIdWithSeckill(seckillId, userPhone);
            return new SeckillExecution(seckillId, StateEnum.SUCCESS, sk);
        } else {
            return new SeckillExecution(seckillId, StateEnum.stateOf(result));
        }
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        return new SeckillExecution(seckillId, StateEnum.INNER_ERROR);
    }
}
 
开发者ID:jessezwd,项目名称:HCS,代码行数:27,代码来源:SeckillServiceImpl.java

示例2: getMaster

import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
@Override
public HostAndPort getMaster(String ip, int port, String password) {
    JedisPool jedisPool = maintainJedisPool(ip, port, password);
    Jedis jedis = null;
    try {
        jedis = jedisPool.getResource();
        String info = jedis.info(RedisConstant.Replication.getValue());
        Map<RedisConstant, Map<String, Object>> infoMap = processRedisStats(info);
        Map<String, Object> map = infoMap.get(RedisConstant.Replication);
        if (map == null) {
            return null;
        }
        String masterHost = MapUtils.getString(map, RedisInfoEnum.master_host.getValue(), null);
        int masterPort = MapUtils.getInteger(map, RedisInfoEnum.master_port.getValue(), 0);
        if (StringUtils.isNotBlank(masterHost) && masterPort > 0) {
            return new HostAndPort(masterHost, masterPort);
        }
        return null;
    } catch (Exception e) {
        logger.error("{}:{} getMaster failed {}", ip, port, e.getMessage(), e);
        return null;
    } finally {
        if (jedis != null)
            jedis.close();
    }
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:27,代码来源:RedisCenterImpl.java

示例3: error

import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
/**
 * 定义500的错误JSON信息
 */
@RequestMapping()
@ResponseBody
public ResponseEntity<RestResp> error(HttpServletRequest request) {
    Map<String, Object> body = getErrorAttributes(request,
            isIncludeStackTrace(request, MediaType.TEXT_HTML));

    String path = MapUtils.getString(body, "path");
    String message = MapUtils.getString(body, "message");
    RestResp restResp = new RestResp(RestResp.ERROR, message, path);
    if (MapUtils.getInteger(body, "status") == 404) {
        restResp = new RestResp(RestResp.NOT_FOUND, "访问的路径不存在", path);
    }
    return new ResponseEntity<>(restResp, HttpStatus.OK);
}
 
开发者ID:jeikerxiao,项目名称:SpringBootStudy,代码行数:18,代码来源:DemoErrorController.java

示例4: batchSave

import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
@Override
public void batchSave(ClientReportBean clientReportBean) {
    try {
        // 1.client上报
        final long collectTime = clientReportBean.getCollectTime();
        final long reportTime = clientReportBean.getReportTimeStamp();
        final List<Map<String, Object>> datas = clientReportBean.getDatas();
        if (datas == null || datas.isEmpty()) {
            logger.warn("datas field {} is empty", clientReportBean);
            return;
        }

        // 3.解析
        for (Map<String, Object> map : datas) {
            Integer clientDataType = MapUtils.getInteger(map, ClientReportConstant.CLIENT_DATA_TYPE, -1);
            ClientCollectDataTypeEnum clientCollectDataTypeEnum = ClientCollectDataTypeEnum.MAP.get(clientDataType);
            if (clientCollectDataTypeEnum == null) {
                continue;
            }
            if (ClientCollectDataTypeEnum.VALUE_LENGTH_DISTRI_TYPE.equals(clientCollectDataTypeEnum)) {
                AppClientValueDistriStatTotal appClientValueDistriStat = generate(collectTime, reportTime, map);
                if (appClientValueDistriStat != null) {
                    appClientValueStatDao.save(appClientValueDistriStat);
                }
            }
        }

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:32,代码来源:ClientReportValueDistriServiceImplV2.java

示例5: save

import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
@Override
public void save(ClientReportBean clientReportBean) {
    try {
        // 1.client上报
        final String clientIp = clientReportBean.getClientIp();
        final long collectTime = clientReportBean.getCollectTime();
        final long reportTime = clientReportBean.getReportTimeStamp();
        final Map<String, Object> otherInfo = clientReportBean.getOtherInfo();
        if (otherInfo == null || otherInfo.isEmpty()) {
            logger.warn("otherInfo field is empty, client ip {}", clientIp);
            return;
        }
        int costMapSize = MapUtils.getInteger(otherInfo, ClientReportConstant.COST_MAP_SIZE, 0);
        int valueMapSize = MapUtils.getInteger(otherInfo, ClientReportConstant.VALUE_MAP_SIZE, 0);
        int exceptionMapSize = MapUtils.getInteger(otherInfo, ClientReportConstant.EXCEPTION_MAP_SIZE, 0);
        int collectMapSize = MapUtils.getInteger(otherInfo, ClientReportConstant.COLLECTION_MAP_SIZE, 0);
        // 只记录大于minSize
        int minSize = 100;
        if (costMapSize < minSize && valueMapSize < minSize && exceptionMapSize < minSize && collectMapSize < minSize) {
            return;
        }
        // 设置实体
        AppClientDataSizeStat appClientDataSizeStat = new AppClientDataSizeStat();
        appClientDataSizeStat.setClientIp(clientIp);
        appClientDataSizeStat.setCollectTime(collectTime);
        appClientDataSizeStat.setCollectMapSize(collectMapSize);
        appClientDataSizeStat.setCostMapSize(costMapSize);
        appClientDataSizeStat.setValueMapSize(valueMapSize);
        appClientDataSizeStat.setExceptionMapSize(exceptionMapSize);
        appClientDataSizeStat.setCreateTime(new Date());
        appClientDataSizeStat.setReportTime(new Date(reportTime));
        
        appClientReportDataSizeDao.save(appClientDataSizeStat);
        
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:39,代码来源:ClientReportDataSizeServiceImpl.java

示例6: batchSave

import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
@Override
public void batchSave(ClientReportBean clientReportBean) {
    try {
        // 1.client上报
        final String clientIp = clientReportBean.getClientIp();
        final long collectTime = clientReportBean.getCollectTime();
        final long reportTime = clientReportBean.getReportTimeStamp();
        final List<Map<String, Object>> datas = clientReportBean.getDatas();
        if (datas == null || datas.isEmpty()) {
            logger.warn("datas field {} is empty", clientReportBean);
            return;
        }

        // 2.结果集
        List<AppClientExceptionStat> appClientExceptionStatList = new ArrayList<AppClientExceptionStat>();

        // 3.解析
        for (Map<String, Object> map : datas) {
            Integer clientDataType = MapUtils.getInteger(map, ClientReportConstant.CLIENT_DATA_TYPE, -1);
            ClientCollectDataTypeEnum clientCollectDataTypeEnum = ClientCollectDataTypeEnum.MAP.get(clientDataType);
            if (clientCollectDataTypeEnum == null) {
                continue;
            }
            if (ClientCollectDataTypeEnum.EXCEPTION_TYPE.equals(clientCollectDataTypeEnum)) {
                AppClientExceptionStat appClientExceptionStat = generate(clientIp, collectTime, reportTime, map);
                if (appClientExceptionStat != null) {
                    appClientExceptionStatList.add(appClientExceptionStat);
                }
            }
        }
        
        // 4.批量保存
        if (CollectionUtils.isNotEmpty(appClientExceptionStatList)) {
            appClientExceptionStatDao.batchSave(appClientExceptionStatList);
        }
        
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:41,代码来源:ClientReportExceptionServiceImpl.java

示例7: excuteSeckillProcedure

import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
/**
 * @param seckillId
 * @param userPhone
 * @param md5
 * @return
 * @throws SeckillException
 * @throws RepeteKillException
 * @throws SeckillCloseException
 */
public SeckillExecution excuteSeckillProcedure(long seckillId, long userPhone, String md5) {
    if (md5 == null || (!md5.equals(getMD5(seckillId)))) {
        throw new SeckillException("Seckill data rewrite");
    }
    Date killTime = new Date();
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("seckillId", seckillId);
    map.put("phone", userPhone);
    map.put("killTime", killTime);
    map.put("result", null);
    //执行存储过程,result被赋值
    try {
        seckillDao.killByProcedure(map);
        //获取result
        int result = MapUtils.getInteger(map, "result", -2);
        if (result == 1) {
            SuccessKilled successKilled = successKilledDao.queryByIdWithSeckill(seckillId, userPhone);
            return new SeckillExecution(seckillId, SeckillStateEnum.SUCCESS, successKilled);
        } else {
            return new SeckillExecution(seckillId, SeckillStateEnum.stateOf(result));
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return new SeckillExecution(seckillId, SeckillStateEnum.INNER_ERROR);
    }
}
 
开发者ID:firery,项目名称:imooc-seckill,代码行数:36,代码来源:SeckillServiceImpl.java

示例8: inspect

import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
@Override
public boolean inspect(Map<InspectParamEnum, Object> paramMap) {
    final String host = MapUtils.getString(paramMap, InspectParamEnum.SPLIT_KEY);
    List<InstanceInfo> list = (List<InstanceInfo>) paramMap.get(InspectParamEnum.INSTANCE_LIST);
    outer:
    for (InstanceInfo info : list) {
        final int port = info.getPort();
        final int type = info.getType();
        final long appId = info.getAppId();
        int status = info.getStatus();
        //非正常节点
        if (status != InstanceStatusEnum.GOOD_STATUS.getStatus()) {
            continue;
        }
        if (TypeUtil.isRedisDataType(type)) {
            Jedis jedis = redisCenter.getJedis(appId, host, port, REDIS_DEFAULT_TIME, REDIS_DEFAULT_TIME);
            try {
                Map<String, String> persistenceMap = parseMap(jedis);
                if (persistenceMap.isEmpty()) {
                    logger.error("{}:{} get persistenceMap failed", host, port);
                    continue;
                }
                if (!isAofEnabled(persistenceMap)) {
                    continue;
                }
                long aofCurrentSize = MapUtils.getLongValue(persistenceMap, RedisInfoEnum.aof_current_size.getValue());
                long aofBaseSize = MapUtils.getLongValue(persistenceMap, RedisInfoEnum.aof_base_size.getValue());
                //阀值大于60%
                long aofThresholdSize = (long) (aofBaseSize * 1.6);
                double percentage = getPercentage(aofCurrentSize, aofBaseSize);
                if (aofCurrentSize >= aofThresholdSize
                        //大于64Mb
                        && aofCurrentSize > (64 * 1024 * 1024)) {
                    //bgRewriteAof
                    boolean isInvoke = invokeBgRewriteAof(jedis);
                    if (!isInvoke) {
                        logger.error("{}:{} invokeBgRewriteAof failed", host, port);
                        continue;
                    } else {
                        logger.warn("{}:{} invokeBgRewriteAof started percentage={}", host, port, percentage);
                    }
                    while (true) {
                        try {
                            //before wait 1s
                            TimeUnit.SECONDS.sleep(1);
                            Map<String, String> loopMap = parseMap(jedis);
                            Integer aofRewriteInProgress = MapUtils.getInteger(loopMap, "aof_rewrite_in_progress", null);
                            if (aofRewriteInProgress == null) {
                                logger.error("loop watch:{}:{} return failed", host, port);
                                break;
                            } else if (aofRewriteInProgress <= 0) {
                                //bgrewriteaof Done
                                logger.warn("{}:{} bgrewriteaof Done lastSize:{}Mb,currentSize:{}Mb", host, port, getMb(aofCurrentSize), getMb(MapUtils.getLongValue(loopMap, "aof_current_size")));
                                break;
                            } else {
                                //wait 1s
                                TimeUnit.SECONDS.sleep(1);
                            }
                        } catch (Exception e) {
                            logger.error(e.getMessage(), e);
                        }
                    }
                } else {
                    if (percentage > 50D) {
                        long currentSize = getMb(aofCurrentSize);
                        logger.info("checked {}:{} aof increase percentage:{}% currentSize:{}Mb", host, port, percentage, currentSize > 0 ? currentSize : "<1");
                    }
                }
            } finally {
                jedis.close();
            }
        }
    }
    return true;
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:76,代码来源:RedisIsolationPersistenceInspector.java

示例9: isAofEnabled

import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
private boolean isAofEnabled(Map<String, String> infoMap) {
    Integer aofEnabled = MapUtils.getInteger(infoMap, "aof_enabled", null);
    return aofEnabled != null && aofEnabled == 1;
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:5,代码来源:RedisIsolationPersistenceInspector.java

示例10: generate

import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
private AppClientValueDistriStatTotal generate(long collectTime, long reportTime, Map<String, Object> map) {
    String valueDistri = MapUtils.getString(map, ClientReportConstant.VALUE_DISTRI, "");
    ValueSizeDistriEnum valueSizeDistriEnum = ValueSizeDistriEnum.getByValue(valueDistri);
    if (valueSizeDistriEnum == null) {
        logger.warn("valueDistri {} is wrong, not in enums {}", valueDistri, ValueSizeDistriEnum.values());
    }

    // 次数
    Integer count = MapUtils.getInteger(map, ClientReportConstant.VALUE_COUNT, 0);

    // 命令
    String command = MapUtils.getString(map, ClientReportConstant.VALUE_COMMAND, "");
    if (StringUtils.isBlank(command)) {
        logger.warn("command is empty!");
        return null;
    }
    if (excludeCommands.contains(command)) {
        return null;
    }

    // 实例host:port
    String hostPort = MapUtils.getString(map, ClientReportConstant.VALUE_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;
    }
    String host = hostPort.substring(0, index);
    int 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;
    }

    AppClientValueDistriStatTotal stat = new AppClientValueDistriStatTotal();
    stat.setAppId(instanceInfo.getAppId());
    stat.setCollectTime(collectTime);
    stat.setUpdateTime(new Date());
    stat.setCommand(command);
    stat.setDistributeType(valueSizeDistriEnum.getType());
    stat.setCount(count);

    return stat;
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:53,代码来源:ClientReportValueDistriServiceImplV2.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

示例12: batchSave

import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
@Override
public void batchSave(ClientReportBean clientReportBean) {
    try {
        // 1.client上报
        final String clientIp = clientReportBean.getClientIp();
        final long collectTime = clientReportBean.getCollectTime();
        final long reportTime = clientReportBean.getReportTimeStamp();
        final List<Map<String, Object>> datas = clientReportBean.getDatas();
        if (datas == null || datas.isEmpty()) {
            logger.warn("datas field {} is empty", clientReportBean);
            return;
        }
        
        // 2.结果集
        List<AppClientCostTimeStat> appClientCostTimeStatList = new ArrayList<AppClientCostTimeStat>();

        // 3.解析结果
        for (Map<String, Object> map : datas) {
            Integer clientDataType = MapUtils.getInteger(map, ClientReportConstant.CLIENT_DATA_TYPE, -1);
            ClientCollectDataTypeEnum clientCollectDataTypeEnum = ClientCollectDataTypeEnum.MAP.get(clientDataType);
            if (clientCollectDataTypeEnum == null) {
                continue;
            }
            if (ClientCollectDataTypeEnum.COST_TIME_DISTRI_TYPE.equals(clientCollectDataTypeEnum)) {
                AppClientCostTimeStat appClientCostTimeStat = generate(clientIp, collectTime, reportTime, map);
                if (appClientCostTimeStat != null) {
                    appClientCostTimeStatList.add(appClientCostTimeStat);
                }
            }
        }
        
        if (CollectionUtils.isNotEmpty(appClientCostTimeStatList)) {
            // 4.批量保存
            appClientCostTimeStatDao.batchSave(appClientCostTimeStatList);
            // 5.合并app统计结果
            List<AppClientCostTimeTotalStat> appClientCostTimeTotalStatList = mergeAppClientCostTimeStat(appClientCostTimeStatList);
            if (CollectionUtils.isNotEmpty(appClientCostTimeTotalStatList)) {
                appClientCostTimeTotalStatDao.batchSave(appClientCostTimeTotalStatList);
            }
            // 6.保存应用下节点和客户端关系
            appInstanceClientRelationService.batchSave(appClientCostTimeStatList);
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:47,代码来源:ClientReportCostDistriServiceImpl.java

示例13: generate

import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
private AppClientCostTimeStat generate(String clientIp, long collectTime, long reportTime, Map<String, Object> map) {
        try {
            Integer count = MapUtils.getInteger(map, ClientReportConstant.COST_COUNT, 0);
            String command = MapUtils.getString(map, ClientReportConstant.COST_COMMAND, "");
            if (StringUtils.isBlank(command)) {
                logger.warn("command is empty!");
                return null;
            }
            String hostPort = MapUtils.getString(map, ClientReportConstant.COST_HOST_PORT, "");
            if (StringUtils.isBlank(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;
            }
            String host = hostPort.substring(0, index);
            int 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;
            }
            long appId = instanceInfo.getAppId();
            // 耗时分布详情
            double mean = MapUtils.getDouble(map, ClientReportConstant.COST_TIME_MEAN, 0.0);
            Integer median = MapUtils.getInteger(map, ClientReportConstant.COST_TIME_MEDIAN, 0);
            Integer ninetyPercentMax = MapUtils.getInteger(map, ClientReportConstant.COST_TIME_90_MAX, 0);
            Integer ninetyNinePercentMax = MapUtils.getInteger(map, ClientReportConstant.COST_TIME_99_MAX, 0);
            Integer hunredMax = MapUtils.getInteger(map, ClientReportConstant.COST_TIME_100_MAX, 0);

            AppClientCostTimeStat stat = new AppClientCostTimeStat();
            stat.setAppId(appId);
            stat.setClientIp(clientIp);
            stat.setReportTime(new Date(reportTime));
            stat.setCollectTime(collectTime);
            stat.setCreateTime(new Date());
            stat.setCommand(command);
            stat.setCount(count);
            stat.setInstanceHost(host);
            stat.setInstancePort(port);
            stat.setMean(NumberUtils.toDouble(new DecimalFormat("#.00").format(mean)));
            stat.setMedian(median);
            stat.setNinetyPercentMax(ninetyPercentMax);
            stat.setNinetyNinePercentMax(ninetyNinePercentMax);
            stat.setHundredMax(hunredMax);
            stat.setInstanceId(instanceInfo.getId());

            return stat;
            
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:60,代码来源:ClientReportCostDistriServiceImpl.java

示例14: stopMigrate

import org.apache.commons.collections.MapUtils; //导入方法依赖的package包/类
@Override
public AppDataMigrateResult stopMigrate(long id) {
    // 获取基本信息
    AppDataMigrateStatus appDataMigrateStatus = appDataMigrateStatusDao.get(id);
    if (appDataMigrateStatus == null) {
        return AppDataMigrateResult.fail("id=" + id + "迁移记录不存在!");
    }
    // 获取进程号
    String migrateMachineIp = appDataMigrateStatus.getMigrateMachineIp();
    String migrateMachineHostPort = migrateMachineIp + ":" + appDataMigrateStatus.getMigrateMachinePort();
    Map<RedisMigrateToolConstant, Map<String, Object>> redisMigrateToolStatMap = showMiragteToolProcess(id);
    if (MapUtils.isEmpty(redisMigrateToolStatMap)) {
        return AppDataMigrateResult.fail("获取" + migrateMachineHostPort + "相关信息失败,可能是进程不存在或者客户端超时,请查找原因或重试!");
    }
    Map<String, Object> serverMap = redisMigrateToolStatMap.get(RedisMigrateToolConstant.Server);
    int pid = MapUtils.getInteger(serverMap, "process_id", -1);
    if (pid <= 0) {
        return AppDataMigrateResult.fail("获取" + migrateMachineHostPort + "的进程号" + pid + "异常");
    }

    // 确认进程号是redis-migrate-tool进程
    Boolean exist = checkPidWhetherIsRmt(migrateMachineIp, pid);
    if (exist == null) {
        return AppDataMigrateResult.fail("执行过程中发生异常,请查看系统日志!");
    } else if (exist.equals(false)) {
        return AppDataMigrateResult.fail(migrateMachineIp + "进程号" + pid + "不存在,请确认!");
    }

    // kill掉进程
    try {
        String cmd = "kill " + pid;
        SSHUtil.execute(migrateMachineIp, cmd);
        exist = checkPidWhetherIsRmt(migrateMachineIp, pid);
        if (exist == null) {
            return AppDataMigrateResult.fail(ErrorMessageEnum.INNER_ERROR_MSG.getMessage());
        } else if (exist.equals(false)) {
            // 更新记录完成更新
            appDataMigrateStatusDao.updateStatus(id, AppDataMigrateStatusEnum.END.getStatus());
            return AppDataMigrateResult.success("已经成功停止了id=" + id + "的迁移任务");
        } else {
            return AppDataMigrateResult.fail(migrateMachineIp + "进程号" + pid + "仍然存在,没有kill掉,请确认!");
        }
    } catch (Exception e) {
        logger.error(e.getMessage());
        return AppDataMigrateResult.fail(ErrorMessageEnum.INNER_ERROR_MSG.getMessage());
    }
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:48,代码来源:AppDataMigrateCenterImpl.java


注:本文中的org.apache.commons.collections.MapUtils.getInteger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。