use of com.vip.saturn.job.console.mybatis.entity.SaturnStatistics in project Saturn by vipshop.
the class DashboardServiceImpl 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);
}
}
use of com.vip.saturn.job.console.mybatis.entity.SaturnStatistics in project Saturn by vipshop.
the class DashboardServiceImpl 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);
}
}
use of com.vip.saturn.job.console.mybatis.entity.SaturnStatistics in project Saturn by vipshop.
the class DashboardServiceImpl method getCountFromDB.
private int getCountFromDB(String name, String zkList) {
SaturnStatistics ss = saturnStatisticsService.findStatisticsByNameAndZkList(name, zkList);
if (ss == null || StringUtils.isBlank(ss.getResult())) {
return 0;
}
String result = ss.getResult();
try {
Integer count = JSON.parseObject(result, new TypeReference<Integer>() {
});
return count == null ? 0 : count;
} catch (Exception e) {
log.error("exception throws during get count from DB. name:" + name, e);
return 0;
}
}
use of com.vip.saturn.job.console.mybatis.entity.SaturnStatistics in project Saturn by vipshop.
the class AlarmStatisticsServiceImpl method getAbnormalJobsStringByZKCluster.
public String getAbnormalJobsStringByZKCluster(String zkClusterKey) throws SaturnJobConsoleException {
ZkCluster zkCluster = validateAndGetZKCluster(zkClusterKey);
SaturnStatistics saturnStatistics = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.UNNORMAL_JOB, zkCluster.getZkAddr());
return saturnStatistics != null ? saturnStatistics.getResult() : null;
}
use of com.vip.saturn.job.console.mybatis.entity.SaturnStatistics in project Saturn by vipshop.
the class AlarmStatisticsServiceImpl method getUnableFailoverJobsStringByZKCluster.
@Override
public String getUnableFailoverJobsStringByZKCluster(String zkClusterKey) throws SaturnJobConsoleException {
ZkCluster zkCluster = validateAndGetZKCluster(zkClusterKey);
SaturnStatistics saturnStatistics = saturnStatisticsService.findStatisticsByNameAndZkList(StatisticsTableKeyConstant.UNABLE_FAILOVER_JOB, zkCluster.getZkAddr());
return saturnStatistics != null ? saturnStatistics.getResult() : null;
}
Aggregations