Search in sources :

Example 26 with SaturnStatistics

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

the class StatisticsPersistence method saveOrUpdateDomainProcessCount.

private void saveOrUpdateDomainProcessCount(ZkStatistics zks, String zkAddr) {
    try {
        String domainListJsonString = JSON.toJSONString(zks);
        SaturnStatistics domainProcessCountFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.DOMAIN_PROCESS_COUNT_OF_THE_DAY, zkAddr);
        if (domainProcessCountFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.DOMAIN_PROCESS_COUNT_OF_THE_DAY, zkAddr, domainListJsonString);
            saturnStatisticsService.create(ss);
        } else {
            domainProcessCountFromDB.setResult(domainListJsonString);
            saturnStatisticsService.updateByPrimaryKey(domainProcessCountFromDB);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 27 with SaturnStatistics

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

the class StatisticsPersistence method saveOrUpdateExecutorInDockerCount.

private void saveOrUpdateExecutorInDockerCount(int exeInDocker, String zkAddr) {
    try {
        String exeInDockerString = JSON.toJSONString(exeInDocker);
        SaturnStatistics exeInDockerFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.EXECUTOR_IN_DOCKER_COUNT, zkAddr);
        if (exeInDockerFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.EXECUTOR_IN_DOCKER_COUNT, zkAddr, exeInDockerString);
            saturnStatisticsService.create(ss);
        } else {
            exeInDockerFromDB.setResult(exeInDockerString);
            saturnStatisticsService.updateByPrimaryKey(exeInDockerFromDB);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 28 with SaturnStatistics

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

the class StatisticsPersistence method saveOrUpdateJobRankDistribution.

private void saveOrUpdateJobRankDistribution(List<JobStatistics> jobList, String zkBsKey) {
    try {
        Map<Integer, Integer> jobDegreeCountMap = new HashMap<>();
        for (JobStatistics jobStatistics : jobList) {
            int jobDegree = jobStatistics.getJobDegree();
            Integer count = jobDegreeCountMap.get(jobDegree);
            jobDegreeCountMap.put(jobDegree, count == null ? 1 : count + 1);
        }
        String jobDegreeMapString = JSON.toJSONString(jobDegreeCountMap);
        SaturnStatistics jobDegreeMapFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.JOB_RANK_DISTRIBUTION, zkBsKey);
        if (jobDegreeMapFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.JOB_RANK_DISTRIBUTION, zkBsKey, jobDegreeMapString);
            saturnStatisticsService.create(ss);
        } else {
            jobDegreeMapFromDB.setResult(jobDegreeMapString);
            saturnStatisticsService.updateByPrimaryKey(jobDegreeMapFromDB);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics) HashMap(java.util.HashMap)

Example 29 with SaturnStatistics

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

the class StatisticsRefreshServiceImpl method getOldTimeout4AlarmJobs.

private List<Timeout4AlarmJob> getOldTimeout4AlarmJobs(ZkCluster zkCluster) {
    SaturnStatistics saturnStatistics = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.TIMEOUT_4_ALARM_JOB, zkCluster.getZkAddr());
    List<Timeout4AlarmJob> oldTimeout4AlarmJobs = new ArrayList<>();
    if (saturnStatistics != null) {
        String result = saturnStatistics.getResult();
        if (StringUtils.isNotBlank(result)) {
            oldTimeout4AlarmJobs = JSON.parseArray(result, Timeout4AlarmJob.class);
        }
    }
    return oldTimeout4AlarmJobs;
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 30 with SaturnStatistics

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

the class StatisticsRefreshServiceImpl method getOldAbnormalJobs.

private List<AbnormalJob> getOldAbnormalJobs(ZkCluster zkCluster) {
    SaturnStatistics saturnStatistics = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.UNNORMAL_JOB, zkCluster.getZkAddr());
    List<AbnormalJob> oldAbnormalJobs = new ArrayList<>();
    if (saturnStatistics != null) {
        String result = saturnStatistics.getResult();
        if (StringUtils.isNotBlank(result)) {
            oldAbnormalJobs = JSON.parseArray(result, AbnormalJob.class);
        }
    }
    return oldAbnormalJobs;
}
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