use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.
the class JobServiceImpl method removeJob.
@Transactional(rollbackFor = Exception.class)
@Override
public void removeJob(String namespace, String jobName) throws SaturnJobConsoleException {
JobConfig4DB jobConfig4DB = currentJobConfigService.findConfigByNamespaceAndJobName(namespace, jobName);
if (jobConfig4DB == null) {
throw new SaturnJobConsoleException(ERROR_CODE_NOT_EXISTED, "不能删除该作业(" + jobName + "),因为该作业不存在");
}
String upStream = jobConfig4DB.getUpStream();
if (StringUtils.isNotBlank(upStream)) {
throw new SaturnJobConsoleException(ERROR_CODE_NOT_EXISTED, "不能删除该作业(" + jobName + "),因为该作业存在上游作业(" + upStream + "),请先断开上下游关系再删除");
}
String downStream = jobConfig4DB.getDownStream();
if (StringUtils.isNotBlank(downStream)) {
throw new SaturnJobConsoleException(ERROR_CODE_NOT_EXISTED, "不能删除该作业(" + jobName + "),因为该作业存在下游作业(" + downStream + "),请先断开上下游关系再删除");
}
CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = registryCenterService.getCuratorFrameworkOp(namespace);
JobStatus jobStatus = getJobStatus(jobName, curatorFrameworkOp, jobConfig4DB.getEnabled());
if (JobStatus.STOPPED != jobStatus) {
throw new SaturnJobConsoleException(ERROR_CODE_BAD_REQUEST, String.format("不能删除该作业(%s),因为该作业不处于STOPPED状态", jobName));
}
Stat stat = curatorFrameworkOp.getStat(JobNodePath.getJobNodePath(jobName));
if (stat != null) {
long createTimeDiff = System.currentTimeMillis() - stat.getCtime();
if (createTimeDiff < SaturnConstants.JOB_CAN_BE_DELETE_TIME_LIMIT) {
throw new SaturnJobConsoleException(ERROR_CODE_BAD_REQUEST, String.format("不能删除该作业(%s),因为该作业创建时间距离现在不超过%d分钟", jobName, SaturnConstants.JOB_CAN_BE_DELETE_TIME_LIMIT / 60000));
}
}
// remove job from db
currentJobConfigService.deleteByPrimaryKey(jobConfig4DB.getId());
// remove job from zk
removeJobFromZk(jobName, curatorFrameworkOp);
}
use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.
the class DashboardServiceImpl method cleanShardingCount.
@Override
public void cleanShardingCount(String namespace) throws SaturnJobConsoleException {
CuratorFrameworkOp curatorFrameworkOp = registryCenterService.getCuratorFrameworkOp(namespace);
curatorFrameworkOp.update(ExecutorNodePath.SHARDING_COUNT_PATH, "0");
asyncForceRefreshStatistics(namespace);
}
use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.
the class DashboardServiceImpl method cleanOneJobAnalyse.
@Override
public void cleanOneJobAnalyse(String namespace, String jobName) throws SaturnJobConsoleException {
CuratorFrameworkOp curatorFrameworkOp = registryCenterService.getCuratorFrameworkOp(namespace);
updateResetValue(curatorFrameworkOp, jobName, ResetCountType.RESET_ANALYSE);
resetOneJobAnalyse(jobName, curatorFrameworkOp);
asyncForceRefreshStatistics(namespace);
}
use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.
the class ExecutorServiceImpl method getExecutorAllocation.
@Override
public ServerAllocationInfo getExecutorAllocation(String namespace, String executorName) throws SaturnJobConsoleException {
CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = getCuratorFrameworkOp(namespace);
List<JobConfig> unSystemJobs = jobService.getUnSystemJobs(namespace);
ServerAllocationInfo serverAllocationInfo = new ServerAllocationInfo(executorName);
for (JobConfig jobConfig : unSystemJobs) {
String jobName = jobConfig.getJobName();
String serverNodePath = JobNodePath.getServerNodePath(jobName);
if (!curatorFrameworkOp.checkExists(serverNodePath)) {
continue;
}
String sharding = curatorFrameworkOp.getData(JobNodePath.getServerNodePath(jobName, executorName, "sharding"));
if (StringUtils.isNotBlank(sharding)) {
// 作业状态为STOPPED的即使有残留分片也不显示该分片
if (JobStatus.STOPPED.equals(jobService.getJobStatus(namespace, jobName))) {
continue;
}
// concat executorSharding
serverAllocationInfo.getAllocationMap().put(jobName, sharding);
// calculate totalLoad
String loadLevelNode = curatorFrameworkOp.getData(JobNodePath.getConfigNodePath(jobName, "loadLevel"));
Integer loadLevel = 1;
if (StringUtils.isNotBlank(loadLevelNode)) {
loadLevel = Integer.valueOf(loadLevelNode);
}
int shardingItemNum = sharding.split(",").length;
int curJobLoad = shardingItemNum * loadLevel;
int totalLoad = serverAllocationInfo.getTotalLoadLevel();
serverAllocationInfo.setTotalLoadLevel(totalLoad + curJobLoad);
}
}
return serverAllocationInfo;
}
use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.
the class ExecutorServiceImpl method extractTraffic.
@Override
public void extractTraffic(String namespace, String executorName) throws SaturnJobConsoleException {
CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = getCuratorFrameworkOp(namespace);
validateIfExecutorNameExisted(executorName, curatorFrameworkOp);
curatorFrameworkOp.create(ExecutorNodePath.getExecutorNoTrafficNodePath(executorName));
}
Aggregations