當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。