Search in sources :

Example 46 with SaturnStatistics

use of com.vip.saturn.job.console.mybatis.entity.SaturnStatistics in project Saturn by vipshop.

the class DashboardServiceImpl method saveOrUpdateTop10ActiveJob.

private void saveOrUpdateTop10ActiveJob(List<JobStatistics> jobList, String zkAddr) {
    try {
        jobList = DashboardServiceHelper.sortJobByDayProcessCount(jobList);
        List<JobStatistics> top10ActiveJob = jobList.subList(0, jobList.size() > 9 ? 10 : jobList.size());
        String top10ActiveJobJsonString = JSON.toJSONString(top10ActiveJob);
        SaturnStatistics top10ActiveJobFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.TOP_10_ACTIVE_JOB, zkAddr);
        if (top10ActiveJobFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.TOP_10_ACTIVE_JOB, zkAddr, top10ActiveJobJsonString);
            saturnStatisticsService.create(ss);
        } else {
            top10ActiveJobFromDB.setResult(top10ActiveJobJsonString);
            saturnStatisticsService.updateByPrimaryKey(top10ActiveJobFromDB);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) JobConsoleException(com.vip.saturn.job.console.exception.JobConsoleException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException)

Example 47 with SaturnStatistics

use of com.vip.saturn.job.console.mybatis.entity.SaturnStatistics in project Saturn by vipshop.

the class DashboardServiceImpl method saveOrUpdateTop10LoadExecutor.

private void saveOrUpdateTop10LoadExecutor(List<ExecutorStatistics> executorList, String zkAddr) {
    try {
        executorList = DashboardServiceHelper.sortExecutorByLoadLevel(executorList);
        List<ExecutorStatistics> top10LoadExecutor = executorList.subList(0, executorList.size() > 9 ? 10 : executorList.size());
        String top10LoadExecutorJsonString = JSON.toJSONString(top10LoadExecutor);
        SaturnStatistics top10LoadExecutorFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.TOP_10_LOAD_EXECUTOR, zkAddr);
        if (top10LoadExecutorFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.TOP_10_LOAD_EXECUTOR, zkAddr, top10LoadExecutorJsonString);
            saturnStatisticsService.create(ss);
        } else {
            top10LoadExecutorFromDB.setResult(top10LoadExecutorJsonString);
            saturnStatisticsService.updateByPrimaryKey(top10LoadExecutorFromDB);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) JobConsoleException(com.vip.saturn.job.console.exception.JobConsoleException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException)

Example 48 with SaturnStatistics

use of com.vip.saturn.job.console.mybatis.entity.SaturnStatistics in project Saturn by vipshop.

the class DashboardServiceImpl method getCountFromDB.

private int getCountFromDB(String name, String zkList) {
    SaturnStatistics ss = saturnStatisticsService.findStatisticsByNameAndZkList(name, zkList);
    if (ss == null || StringUtils.isBlank(ss.getResult())) {
        return 0;
    }
    String result = ss.getResult();
    try {
        Integer count = JSON.parseObject(result, new TypeReference<Integer>() {
        });
        return count == null ? 0 : count;
    } catch (Exception e) {
        log.error("exception throws during get count from DB. name:" + name, e);
        return 0;
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException)

Example 49 with SaturnStatistics

use of com.vip.saturn.job.console.mybatis.entity.SaturnStatistics in project Saturn by vipshop.

the class AlarmStatisticsServiceImpl method getAbnormalJobsStringByZKCluster.

public String getAbnormalJobsStringByZKCluster(String zkClusterKey) throws SaturnJobConsoleException {
    ZkCluster zkCluster = validateAndGetZKCluster(zkClusterKey);
    SaturnStatistics saturnStatistics = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.UNNORMAL_JOB, zkCluster.getZkAddr());
    return saturnStatistics != null ? saturnStatistics.getResult() : null;
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 50 with SaturnStatistics

use of com.vip.saturn.job.console.mybatis.entity.SaturnStatistics in project Saturn by vipshop.

the class AlarmStatisticsServiceImpl method getUnableFailoverJobsStringByZKCluster.

@Override
public String getUnableFailoverJobsStringByZKCluster(String zkClusterKey) throws SaturnJobConsoleException {
    ZkCluster zkCluster = validateAndGetZKCluster(zkClusterKey);
    SaturnStatistics saturnStatistics = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.UNABLE_FAILOVER_JOB, zkCluster.getZkAddr());
    return saturnStatistics != null ? saturnStatistics.getResult() : null;
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Aggregations

SaturnStatistics (com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)68 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)21 JobConsoleException (com.vip.saturn.job.console.exception.JobConsoleException)19 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)19 SuccessResponseEntity (com.vip.saturn.job.console.controller.SuccessResponseEntity)8 ZkCluster (com.vip.saturn.job.console.domain.ZkCluster)8 ApiResponses (io.swagger.annotations.ApiResponses)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 CuratorFrameworkOp (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)1 HashMap (java.util.HashMap)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1