Search in sources :

Example 1 with JobConfigInfo

use of com.vip.saturn.job.integrate.entity.JobConfigInfo in project Saturn by vipshop.

the class UpdateJobConfigServiceImpl method batchUpdatePreferList.

@Override
public void batchUpdatePreferList(List<JobConfigInfo> jobConfigInfos) throws UpdateJobConfigException {
    if (CollectionUtils.isEmpty(jobConfigInfos)) {
        return;
    }
    List<JobConfig4DB> currentJobConfigs = new ArrayList<JobConfig4DB>();
    JobConfig4DB currentJobConfig = null;
    for (JobConfigInfo jobConfigInfo : jobConfigInfos) {
        currentJobConfig = new JobConfig4DB();
        currentJobConfig.setNamespace(jobConfigInfo.getNamespace());
        currentJobConfig.setJobName(jobConfigInfo.getJobName());
        currentJobConfig.setPreferList(jobConfigInfo.getPerferList());
        currentJobConfigs.add(currentJobConfig);
    }
    try {
        currentJobConfigService.batchUpdatePreferList(currentJobConfigs);
    } catch (SaturnJobConsoleException e) {
        throw new UpdateJobConfigException(e);
    }
}
Also used : UpdateJobConfigException(com.vip.saturn.job.integrate.exception.UpdateJobConfigException) JobConfigInfo(com.vip.saturn.job.integrate.entity.JobConfigInfo) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) ArrayList(java.util.ArrayList) JobConfig4DB(com.vip.saturn.job.console.mybatis.entity.JobConfig4DB)

Example 2 with JobConfigInfo

use of com.vip.saturn.job.integrate.entity.JobConfigInfo in project Saturn by vipshop.

the class ExecutorCleanService method clean.

/**
 * delete $SaturnExecutors/executors/xxx<br> delete $Jobs/job/servers/xxx<br> delete $Jobs/job/config/preferList
 * content about xxx
 */
public void clean(String executorName) {
    List<JobConfigInfo> jobConfigInfos = new ArrayList<>();
    try {
        String cleanNodePath = SaturnExecutorsNode.getExecutorCleanNodePath(executorName);
        byte[] cleanNodeBytes = curatorFramework.getData().forPath(cleanNodePath);
        if (cleanNodeBytes == null || cleanNodeBytes.length == 0) {
            return;
        }
        String cleanNodeData = new String(cleanNodeBytes, "UTF-8");
        if (!Boolean.parseBoolean(cleanNodeData)) {
            return;
        }
        if (curatorFramework.checkExists().forPath(SaturnExecutorsNode.getExecutorIpNodePath(executorName)) == null) {
            log.info("Clean the executor {}", executorName);
            // delete $SaturnExecutors/executors/xxx
            deleteExecutor(executorName);
            List<String> jobs = getJobList();
            for (String jobName : jobs) {
                // delete $Jobs/job/servers/xxx
                deleteJobServerExecutor(jobName, executorName);
                // delete $Jobs/job/config/preferList content about xxx
                String preferList = updateJobConfigPreferListContentToRemoveDeletedExecutor(jobName, executorName);
                if (preferList != null) {
                    JobConfigInfo jobConfigInfo = new JobConfigInfo(curatorFramework.getNamespace(), jobName, preferList);
                    jobConfigInfos.add(jobConfigInfo);
                }
            }
        } else {
            log.info("The executor {} is online now, no necessary to clean", executorName);
        }
    } catch (NoNodeException e) {
        log.debug("No clean node found for executor:" + executorName, e);
    } catch (Exception e) {
        log.error("Clean the executor " + executorName + " error", e);
    } finally {
        updatePreferListQuietly(jobConfigInfos);
    }
}
Also used : JobConfigInfo(com.vip.saturn.job.integrate.entity.JobConfigInfo) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) ArrayList(java.util.ArrayList) BadVersionException(org.apache.zookeeper.KeeperException.BadVersionException) KeeperException(org.apache.zookeeper.KeeperException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException)

Aggregations

JobConfigInfo (com.vip.saturn.job.integrate.entity.JobConfigInfo)2 ArrayList (java.util.ArrayList)2 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)1 JobConfig4DB (com.vip.saturn.job.console.mybatis.entity.JobConfig4DB)1 UpdateJobConfigException (com.vip.saturn.job.integrate.exception.UpdateJobConfigException)1 KeeperException (org.apache.zookeeper.KeeperException)1 BadVersionException (org.apache.zookeeper.KeeperException.BadVersionException)1 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)1