Search in sources :

Example 6 with CuratorFrameworkOp

use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.

the class JobServiceImpl method getJobShardingAllocatedExecutorList.

@Override
public List<String> getJobShardingAllocatedExecutorList(String namespace, String jobName) throws SaturnJobConsoleException {
    CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = registryCenterService.getCuratorFrameworkOp(namespace);
    String executorsPath = JobNodePath.getServerNodePath(jobName);
    List<String> executors = curatorFrameworkOp.getChildren(executorsPath);
    if (CollectionUtils.isEmpty(executors)) {
        return Lists.newArrayList();
    }
    List<String> shardingList = Lists.newArrayList();
    for (String executor : executors) {
        String sharding = curatorFrameworkOp.getData(JobNodePath.getServerNodePath(jobName, executor, "sharding"));
        if (StringUtils.isNotBlank(sharding)) {
            shardingList.add(executor);
        }
    }
    return shardingList;
}
Also used : CuratorRepository(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository) CuratorFrameworkOp(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)

Example 7 with CuratorFrameworkOp

use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.

the class ExecutorServiceImpl method dump.

@Override
public void dump(String namespace, String executorName) throws SaturnJobConsoleException {
    CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = getCuratorFrameworkOp(namespace);
    String version = curatorFrameworkOp.getData(ExecutorNodePath.getExecutorVersionNodePath(executorName));
    if (!isVersionSupportedDump(version)) {
        throw new SaturnJobConsoleException(SaturnJobConsoleException.ERROR_CODE_BAD_REQUEST, "Saturn executor版本低于3.0.0无法进行一键dump");
    }
    String dumpNodePath = ExecutorNodePath.getExecutorDumpNodePath(executorName);
    curatorFrameworkOp.delete(dumpNodePath);
    curatorFrameworkOp.create(dumpNodePath);
}
Also used : CuratorRepository(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) CuratorFrameworkOp(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)

Example 8 with CuratorFrameworkOp

use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.

the class ExecutorServiceImpl method restart.

@Override
public void restart(String namespace, String executorName) throws SaturnJobConsoleException {
    CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = getCuratorFrameworkOp(namespace);
    String restartNodePath = ExecutorNodePath.getExecutorRestartNodePath(executorName);
    curatorFrameworkOp.delete(restartNodePath);
    curatorFrameworkOp.create(restartNodePath);
}
Also used : CuratorRepository(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository) CuratorFrameworkOp(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)

Example 9 with CuratorFrameworkOp

use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.

the class ExecutorServiceImpl method removeExecutor.

@Override
public void removeExecutor(String namespace, String executorName) throws SaturnJobConsoleException {
    CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = getCuratorFrameworkOp(namespace);
    curatorFrameworkOp.deleteRecursive(ExecutorNodePath.getExecutorNodePath(executorName));
    List<String> jobNames = jobService.getAllJobNamesFromZK(namespace);
    if (CollectionUtils.isEmpty(jobNames)) {
        return;
    }
    for (String jobName : jobNames) {
        String executorNode = JobNodePath.getServerNodePath(jobName, executorName);
        curatorFrameworkOp.deleteRecursive(executorNode);
    }
}
Also used : CuratorRepository(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository) CuratorFrameworkOp(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)

Example 10 with CuratorFrameworkOp

use of com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp in project Saturn by vipshop.

the class ExecutorServiceImpl method getExecutors.

@Override
public List<ServerBriefInfo> getExecutors(String namespace, ServerStatus expectedServerStatus) throws SaturnJobConsoleException {
    CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = getCuratorFrameworkOp(namespace);
    List<String> executors = curatorFrameworkOp.getChildren(ExecutorNodePath.getExecutorNodePath());
    if (executors == null || executors.isEmpty()) {
        return Lists.newArrayList();
    }
    List<ServerBriefInfo> executorInfoList = Lists.newArrayList();
    for (String executor : executors) {
        ServerBriefInfo executorInfo = getServerBriefInfo(executor, curatorFrameworkOp);
        if (expectedServerStatus == null || executorInfo.getStatus() == expectedServerStatus) {
            executorInfoList.add(executorInfo);
        }
    }
    return executorInfoList;
}
Also used : CuratorRepository(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository) CuratorFrameworkOp(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)

Aggregations

CuratorFrameworkOp (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)49 CuratorRepository (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository)35 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)22 Transactional (org.springframework.transaction.annotation.Transactional)9 JobConfig4DB (com.vip.saturn.job.console.mybatis.entity.JobConfig4DB)8 SaturnJobConsoleHttpException (com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)6 ParseException (java.text.ParseException)6 Stat (org.apache.zookeeper.data.Stat)3 RequestResult (com.vip.saturn.job.console.domain.RequestResult)2 Boolean (java.lang.Boolean)2 CuratorFramework (org.apache.curator.framework.CuratorFramework)2 JobConsoleException (com.vip.saturn.job.console.exception.JobConsoleException)1 CurrentJobConfig (com.vip.saturn.job.console.mybatis.entity.CurrentJobConfig)1 SaturnStatistics (com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)1 ZkClusterInfo (com.vip.saturn.job.console.mybatis.entity.ZkClusterInfo)1 GetJobConfigVo (com.vip.saturn.job.console.vo.GetJobConfigVo)1 File (java.io.File)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Label (jxl.write.Label)1 WritableSheet (jxl.write.WritableSheet)1