Search in sources :

Example 41 with SaturnStatistics

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

the class DashboardServiceImpl method saveOrUpdateJobRankDistribution.

private void saveOrUpdateJobRankDistribution(List<JobStatistics> jobList, String zkAddr) {
    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, zkAddr);
        if (jobDegreeMapFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.JOB_RANK_DISTRIBUTION, zkAddr, 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) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) JobConsoleException(com.vip.saturn.job.console.exception.JobConsoleException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException)

Example 42 with SaturnStatistics

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

the class DashboardServiceImpl method saveOrUpdateVersionExecutorNumber.

private void saveOrUpdateVersionExecutorNumber(Map<String, Long> versionExecutorNumber, String zkAddr) {
    try {
        String versionExecutorNumberJsonString = JSON.toJSONString(versionExecutorNumber);
        SaturnStatistics versionExecutorNumberFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.VERSION_EXECUTOR_NUMBER, zkAddr);
        if (versionExecutorNumberFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.VERSION_EXECUTOR_NUMBER, zkAddr, versionExecutorNumberJsonString);
            saturnStatisticsService.create(ss);
        } else {
            versionExecutorNumberFromDB.setResult(versionExecutorNumberJsonString);
            saturnStatisticsService.updateByPrimaryKey(versionExecutorNumberFromDB);
        }
    } 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 43 with SaturnStatistics

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

the class DashboardServiceImpl method allUnnormalJobByAllZkCluster.

@Override
public String allUnnormalJobByAllZkCluster() {
    List<AbnormalJob> abnormalJobList = new ArrayList<>();
    Collection<ZkCluster> zkClusterList = registryCenterService.getZkClusterList();
    for (ZkCluster zkCluster : zkClusterList) {
        SaturnStatistics saturnStatistics = allUnnormalJob(zkCluster.getZkAddr());
        if (saturnStatistics != null) {
            String result = saturnStatistics.getResult();
            List<AbnormalJob> tempList = JSON.parseArray(result, AbnormalJob.class);
            if (tempList != null) {
                abnormalJobList.addAll(tempList);
            }
        }
    }
    abnormalJobList = DashboardServiceHelper.sortUnnormaoJobByTimeDesc(abnormalJobList);
    return JSON.toJSONString(abnormalJobList);
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 44 with SaturnStatistics

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

the class DashboardServiceImpl method saveOrUpdateTimeout4AlarmJob.

private void saveOrUpdateTimeout4AlarmJob(List<Timeout4AlarmJob> timeout4AlarmJobList, String zkAddr) {
    try {
        String timeout4AlarmJobJsonString = JSON.toJSONString(timeout4AlarmJobList);
        SaturnStatistics timeout4AlarmJobFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.TIMEOUT_4_ALARM_JOB, zkAddr);
        if (timeout4AlarmJobFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.TIMEOUT_4_ALARM_JOB, zkAddr, timeout4AlarmJobJsonString);
            saturnStatisticsService.create(ss);
        } else {
            List<Timeout4AlarmJob> oldTimeout4AlarmJobs = JSON.parseArray(timeout4AlarmJobFromDB.getResult(), Timeout4AlarmJob.class);
            dealWithReadStatus4Timeout4AlarmJob(timeout4AlarmJobList, oldTimeout4AlarmJobs);
            timeout4AlarmJobFromDB.setResult(JSON.toJSONString(timeout4AlarmJobList));
            saturnStatisticsService.updateByPrimaryKey(timeout4AlarmJobFromDB);
        }
    } 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 45 with SaturnStatistics

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

the class DashboardServiceImpl method saveOrUpdateUnableFailoverJob.

private void saveOrUpdateUnableFailoverJob(List<AbnormalJob> unableFailoverJobList, String zkAddr) {
    try {
        String unableFailoverJobJsonString = JSON.toJSONString(unableFailoverJobList);
        SaturnStatistics unableFailoverJobFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.UNABLE_FAILOVER_JOB, zkAddr);
        if (unableFailoverJobFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.UNABLE_FAILOVER_JOB, zkAddr, unableFailoverJobJsonString);
            saturnStatisticsService.create(ss);
        } else {
            unableFailoverJobFromDB.setResult(unableFailoverJobJsonString);
            saturnStatisticsService.updateByPrimaryKey(unableFailoverJobFromDB);
        }
    } 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)

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