Search in sources :

Example 66 with SaturnStatistics

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

the class StatisticsPersistence method saveOrUpdateTop10UnstableDomain.

private void saveOrUpdateTop10UnstableDomain(List<DomainStatistics> domainList, String zkAddr) {
    try {
        domainList = DashboardServiceHelper.sortDomainByShardingCount(domainList);
        List<DomainStatistics> top10UnstableDomain = domainList.subList(0, domainList.size() > 9 ? 10 : domainList.size());
        String top10UnstableDomainJsonString = JSON.toJSONString(top10UnstableDomain);
        SaturnStatistics top10UnstableDomainFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.TOP_10_UNSTABLE_DOMAIN, zkAddr);
        if (top10UnstableDomainFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.TOP_10_UNSTABLE_DOMAIN, zkAddr, top10UnstableDomainJsonString);
            saturnStatisticsService.create(ss);
        } else {
            top10UnstableDomainFromDB.setResult(top10UnstableDomainJsonString);
            saturnStatisticsService.updateByPrimaryKey(top10UnstableDomainFromDB);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 67 with SaturnStatistics

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

the class StatisticsPersistence method saveOrUpdateTop10FailJob.

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

Example 68 with SaturnStatistics

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

the class StatisticsPersistence 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)

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