Search in sources :

Example 6 with SaturnStatistics

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

the class DashboardServiceImpl method saveOrUpdateExecutorInDockerCount.

private void saveOrUpdateExecutorInDockerCount(int exeInDocker, String zkAddr) {
    try {
        String exeInDockerString = JSON.toJSONString(exeInDocker);
        SaturnStatistics exeInDockerFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.EXECUTOR_IN_DOCKER_COUNT, zkAddr);
        if (exeInDockerFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.EXECUTOR_IN_DOCKER_COUNT, zkAddr, exeInDockerString);
            saturnStatisticsService.create(ss);
        } else {
            exeInDockerFromDB.setResult(exeInDockerString);
            saturnStatisticsService.updateByPrimaryKey(exeInDockerFromDB);
        }
    } 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 7 with SaturnStatistics

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

the class DashboardServiceImpl method setUnnormalJobMonitorStatusToRead.

@Override
public void setUnnormalJobMonitorStatusToRead(String currentZkAddr, String uuid) {
    if (StringUtils.isBlank(uuid)) {
        return;
    }
    SaturnStatistics saturnStatistics = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.UNNORMAL_JOB, currentZkAddr);
    if (saturnStatistics != null) {
        String result = saturnStatistics.getResult();
        List<AbnormalJob> jobs = JSON.parseArray(result, AbnormalJob.class);
        if (jobs != null) {
            boolean find = false;
            for (AbnormalJob job : jobs) {
                if (uuid.equals(job.getUuid())) {
                    job.setRead(true);
                    find = true;
                    break;
                }
            }
            if (find) {
                saturnStatistics.setResult(JSON.toJSONString(jobs));
                saturnStatisticsService.updateByPrimaryKeySelective(saturnStatistics);
            }
        }
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 8 with SaturnStatistics

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

the class DashboardServiceImpl method saveOrUpdateAbnormalContainer.

private void saveOrUpdateAbnormalContainer(List<AbnormalContainer> abnormalContainerList, String zkAddr) {
    try {
        String abnormalContainerJsonString = JSON.toJSONString(abnormalContainerList);
        SaturnStatistics abnormalContainerFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.ABNORMAL_CONTAINER, zkAddr);
        if (abnormalContainerFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.ABNORMAL_CONTAINER, zkAddr, abnormalContainerJsonString);
            saturnStatisticsService.create(ss);
        } else {
            abnormalContainerFromDB.setResult(abnormalContainerJsonString);
            saturnStatisticsService.updateByPrimaryKey(abnormalContainerFromDB);
        }
    } 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 9 with SaturnStatistics

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

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

Example 10 with SaturnStatistics

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

the class DashboardServiceImpl method setTimeout4AlarmJobMonitorStatusToRead.

@Override
public void setTimeout4AlarmJobMonitorStatusToRead(String currentZkAddr, String uuid) {
    if (StringUtils.isBlank(uuid)) {
        return;
    }
    SaturnStatistics saturnStatistics = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.TIMEOUT_4_ALARM_JOB, currentZkAddr);
    if (saturnStatistics != null) {
        String result = saturnStatistics.getResult();
        List<Timeout4AlarmJob> jobs = JSON.parseArray(result, Timeout4AlarmJob.class);
        if (jobs != null) {
            boolean find = false;
            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);
            }
        }
    }
}
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