Search in sources :

Example 61 with SaturnStatistics

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

the class StatisticsPersistence method saveOrUpdateUnableFailoverJob.

private void saveOrUpdateUnableFailoverJob(List<AbnormalJob> unableFailoverJobList, String zkAddr) {
    try {
        String unableFailoverJobJsonString = JSON.toJSONString(unableFailoverJobList);
        SaturnStatistics unableFailoverJobFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.UNABLE_FAILOVER_JOB, zkAddr);
        if (unableFailoverJobFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.UNABLE_FAILOVER_JOB, zkAddr, unableFailoverJobJsonString);
            saturnStatisticsService.create(ss);
        } else {
            unableFailoverJobFromDB.setResult(unableFailoverJobJsonString);
            saturnStatisticsService.updateByPrimaryKey(unableFailoverJobFromDB);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 62 with SaturnStatistics

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

the class StatisticsPersistence method saveOrUpdateTop10LoadExecutor.

private void saveOrUpdateTop10LoadExecutor(List<ExecutorStatistics> executorList, String zkAddr) {
    try {
        executorList = DashboardServiceHelper.sortExecutorByLoadLevel(executorList);
        List<ExecutorStatistics> top10LoadExecutor = executorList.subList(0, executorList.size() > 9 ? 10 : executorList.size());
        String top10LoadExecutorJsonString = JSON.toJSONString(top10LoadExecutor);
        SaturnStatistics top10LoadExecutorFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.TOP_10_LOAD_EXECUTOR, zkAddr);
        if (top10LoadExecutorFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.TOP_10_LOAD_EXECUTOR, zkAddr, top10LoadExecutorJsonString);
            saturnStatisticsService.create(ss);
        } else {
            top10LoadExecutorFromDB.setResult(top10LoadExecutorJsonString);
            saturnStatisticsService.updateByPrimaryKey(top10LoadExecutorFromDB);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 63 with SaturnStatistics

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

the class StatisticsPersistence method saveOrUpdateVersionExecutorNumber.

private void saveOrUpdateVersionExecutorNumber(Map<String, Long> versionExecutorNumber, String zkAddr) {
    try {
        String versionExecutorNumberJsonString = JSON.toJSONString(versionExecutorNumber);
        SaturnStatistics versionExecutorNumberFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.VERSION_EXECUTOR_NUMBER, zkAddr);
        if (versionExecutorNumberFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.VERSION_EXECUTOR_NUMBER, zkAddr, versionExecutorNumberJsonString);
            saturnStatisticsService.create(ss);
        } else {
            versionExecutorNumberFromDB.setResult(versionExecutorNumberJsonString);
            saturnStatisticsService.updateByPrimaryKey(versionExecutorNumberFromDB);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 64 with SaturnStatistics

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

the class StatisticsPersistence method saveOrUpdateVersionDomainNumber.

private void saveOrUpdateVersionDomainNumber(Map<String, Long> versionDomainNumber, String zkAddr) {
    try {
        String versionDomainNumberJsonString = JSON.toJSONString(versionDomainNumber);
        SaturnStatistics versionDomainNumberFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.VERSION_DOMAIN_NUMBER, zkAddr);
        if (versionDomainNumberFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.VERSION_DOMAIN_NUMBER, zkAddr, versionDomainNumberJsonString);
            saturnStatisticsService.create(ss);
        } else {
            versionDomainNumberFromDB.setResult(versionDomainNumberJsonString);
            saturnStatisticsService.updateByPrimaryKey(versionDomainNumberFromDB);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)

Example 65 with SaturnStatistics

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

the class StatisticsPersistence method saveOrUpdateTop10FailDomain.

private void saveOrUpdateTop10FailDomain(List<DomainStatistics> domainList, String zkAddr) {
    try {
        domainList = DashboardServiceHelper.sortDomainByAllTimeFailureRate(domainList);
        List<DomainStatistics> top10FailDomainList = domainList.subList(0, domainList.size() > 9 ? 10 : domainList.size());
        String top10FailDomainJsonString = JSON.toJSONString(top10FailDomainList);
        SaturnStatistics top10FailDomainFromDB = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.TOP_10_FAIL_DOMAIN, zkAddr);
        if (top10FailDomainFromDB == null) {
            SaturnStatistics ss = new SaturnStatistics(StatisticsTableKeyConstant.TOP_10_FAIL_DOMAIN, zkAddr, top10FailDomainJsonString);
            saturnStatisticsService.create(ss);
        } else {
            top10FailDomainFromDB.setResult(top10FailDomainJsonString);
            saturnStatisticsService.updateByPrimaryKey(top10FailDomainFromDB);
        }
    } 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