Search in sources :

Example 11 with SaturnStatistics

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

the class DashboardServiceImpl method setUnnormalJobMonitorStatusToReadByAllZkCluster.

@Override
public void setUnnormalJobMonitorStatusToReadByAllZkCluster(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.UNNORMAL_JOB, zkAddr);
        if (saturnStatistics != null) {
            boolean find = false;
            String result = saturnStatistics.getResult();
            List<AbnormalJob> abnormalJobList = JSON.parseArray(result, AbnormalJob.class);
            if (abnormalJobList != null) {
                for (AbnormalJob abnormalJob : abnormalJobList) {
                    if (uuid.equals(abnormalJob.getUuid())) {
                        abnormalJob.setRead(true);
                        find = true;
                        break;
                    }
                }
            }
            if (find) {
                saturnStatistics.setResult(JSON.toJSONString(abnormalJobList));
                saturnStatisticsService.updateByPrimaryKeySelective(saturnStatistics);
                return;
            }
        }
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 12 with SaturnStatistics

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

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

Example 13 with SaturnStatistics

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

the class DashboardServiceImpl method allUnableFailoverJobByAllZkCluster.

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

Example 14 with SaturnStatistics

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

the class DashboardController method top10LoadJob.

@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@GetMapping(value = "/top10LoadJob")
public SuccessResponseEntity top10LoadJob(@RequestParam(required = false) String zkClusterKey) throws SaturnJobConsoleException {
    if (StringUtils.isNotBlank(zkClusterKey)) {
        ZkCluster zkCluster = checkAndGetZkCluster(zkClusterKey);
        SaturnStatistics ss = dashboardService.top10LoadJob(zkCluster.getZkAddr());
        return ss == null ? new SuccessResponseEntity() : new SuccessResponseEntity(ss.getResult());
    }
    return new SuccessResponseEntity(dashboardService.top10LoadJobByAllZkCluster());
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics) SuccessResponseEntity(com.vip.saturn.job.console.controller.SuccessResponseEntity) ZkCluster(com.vip.saturn.job.console.domain.ZkCluster) ApiResponses(io.swagger.annotations.ApiResponses)

Example 15 with SaturnStatistics

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

the class DashboardController method top10ActiveJob.

@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@GetMapping(value = "/top10ActiveJob")
public SuccessResponseEntity top10ActiveJob(@RequestParam(required = false) String zkClusterKey) throws SaturnJobConsoleException {
    if (StringUtils.isNotBlank(zkClusterKey)) {
        ZkCluster zkCluster = checkAndGetZkCluster(zkClusterKey);
        SaturnStatistics ss = dashboardService.top10AactiveJob(zkCluster.getZkAddr());
        return ss == null ? new SuccessResponseEntity() : new SuccessResponseEntity(ss.getResult());
    }
    return new SuccessResponseEntity(dashboardService.top10AactiveJobByAllZkCluster());
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics) SuccessResponseEntity(com.vip.saturn.job.console.controller.SuccessResponseEntity) ZkCluster(com.vip.saturn.job.console.domain.ZkCluster) ApiResponses(io.swagger.annotations.ApiResponses)

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