Search in sources :

Example 31 with SaturnStatistics

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

the class AlarmStatisticsServiceImpl method getTimeout4AlarmJobsStringByZKCluster.

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

Example 32 with SaturnStatistics

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

the class AlarmStatisticsServiceImpl method getAbnormalContainers.

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

Example 33 with SaturnStatistics

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

the class DashboardServiceImpl method top10FailureExecutorByAllZkCluster.

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

Example 34 with SaturnStatistics

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

the class DashboardServiceImpl 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) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) JobConsoleException(com.vip.saturn.job.console.exception.JobConsoleException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException)

Example 35 with SaturnStatistics

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

the class DashboardServiceImpl method setTimeout4AlarmJobMonitorStatusToReadByAllZkCluster.

@Override
public void setTimeout4AlarmJobMonitorStatusToReadByAllZkCluster(String uuid) {
    if (StringUtils.isBlank(uuid)) {
        return;
    }
    Collection<ZkCluster> zkClusterList = registryCenterService.getZkClusterList();
    for (ZkCluster zkCluster : zkClusterList) {
        String zkAddr = zkCluster.getZkAddr();
        SaturnStatistics saturnStatistics = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.TIMEOUT_4_ALARM_JOB, zkAddr);
        if (saturnStatistics != null) {
            boolean find = false;
            String result = saturnStatistics.getResult();
            List<Timeout4AlarmJob> jobs = JSON.parseArray(result, Timeout4AlarmJob.class);
            if (jobs != null) {
                for (Timeout4AlarmJob job : jobs) {
                    if (uuid.equals(job.getUuid())) {
                        job.setRead(true);
                        find = true;
                        break;
                    }
                }
            }
            if (find) {
                saturnStatistics.setResult(JSON.toJSONString(jobs));
                saturnStatisticsService.updateByPrimaryKeySelective(saturnStatistics);
                return;
            }
        }
    }
}
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