Search in sources :

Example 21 with SaturnStatistics

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

the class DashboardServiceImpl method top10LoadJobByAllZkCluster.

@Override
public String top10LoadJobByAllZkCluster() throws SaturnJobConsoleException {
    List<JobStatistics> jobStatisticsList = new ArrayList<>();
    Collection<ZkCluster> zkClusterList = registryCenterService.getOnlineZkClusterList();
    for (ZkCluster zkCluster : zkClusterList) {
        SaturnStatistics saturnStatistics = top10LoadJob(zkCluster.getZkAddr());
        if (saturnStatistics != null) {
            String result = saturnStatistics.getResult();
            List<JobStatistics> tempList = JSON.parseArray(result, JobStatistics.class);
            if (tempList != null) {
                jobStatisticsList.addAll(tempList);
            }
        }
    }
    jobStatisticsList = DashboardServiceHelper.sortJobByLoadLevel(jobStatisticsList);
    List<JobStatistics> top10LoadJob = jobStatisticsList.subList(0, jobStatisticsList.size() > 9 ? 10 : jobStatisticsList.size());
    return JSON.toJSONString(top10LoadJob);
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 22 with SaturnStatistics

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

the class StatisticsPersistence method saveOrUpdateAbnormalJob.

private void saveOrUpdateAbnormalJob(List<AbnormalJob> unnormalJobList, String zkAddr) {
    try {
        unnormalJobList = DashboardServiceHelper.sortUnnormaoJobByTimeDesc(unnormalJobList);
        SaturnStatistics unnormalJobFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.UNNORMAL_JOB, zkAddr);
        if (unnormalJobFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.UNNORMAL_JOB, zkAddr, JSON.toJSONString(unnormalJobList));
            saturnStatisticsService.create(ss);
        } else {
            List<AbnormalJob> oldUnnormalJobList = JSON.parseArray(unnormalJobFromDB.getResult(), AbnormalJob.class);
            // 再次同步数据库中最新的read状态
            dealWithReadStatus(unnormalJobList, oldUnnormalJobList);
            unnormalJobFromDB.setResult(JSON.toJSONString(unnormalJobList));
            saturnStatisticsService.updateByPrimaryKey(unnormalJobFromDB);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 23 with SaturnStatistics

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

the class StatisticsPersistence method saveOrUpdateTop10LoadJob.

private void saveOrUpdateTop10LoadJob(List<JobStatistics> jobList, String zkAddr) {
    try {
        jobList = DashboardServiceHelper.sortJobByLoadLevel(jobList);
        List<JobStatistics> top10LoadJob = jobList.subList(0, jobList.size() > 9 ? 10 : jobList.size());
        String top10LoadJobJsonString = JSON.toJSONString(top10LoadJob);
        SaturnStatistics top10LoadJobFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.TOP_10_LOAD_JOB, zkAddr);
        if (top10LoadJobFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.TOP_10_LOAD_JOB, zkAddr, top10LoadJobJsonString);
            saturnStatisticsService.create(ss);
        } else {
            top10LoadJobFromDB.setResult(top10LoadJobJsonString);
            saturnStatisticsService.updateByPrimaryKey(top10LoadJobFromDB);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 24 with SaturnStatistics

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

the class StatisticsPersistence 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);
            // 再次同步数据库中最新的read状态
            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)

Example 25 with SaturnStatistics

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

the class StatisticsPersistence method saveOrUpdateJobCount.

private void saveOrUpdateJobCount(int jobCount, String zkAddr) {
    try {
        String jobCountString = JSON.toJSONString(jobCount);
        SaturnStatistics jobCountFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.JOB_COUNT, zkAddr);
        if (jobCountFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.JOB_COUNT, zkAddr, jobCountString);
            saturnStatisticsService.create(ss);
        } else {
            jobCountFromDB.setResult(jobCountString);
            saturnStatisticsService.updateByPrimaryKey(jobCountFromDB);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
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