Search in sources :

Example 46 with CuratorFrameworkOp

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

the class ExecutorServiceImpl method getExecutorRunningInfo.

@Override
public ServerRunningInfo getExecutorRunningInfo(String namespace, String executorName) throws SaturnJobConsoleException {
    CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = getCuratorFrameworkOp(namespace);
    List<JobConfig> unSystemJobs = jobService.getUnSystemJobs(namespace);
    ServerRunningInfo serverRunningInfo = new ServerRunningInfo(executorName);
    for (JobConfig jobConfig : unSystemJobs) {
        boolean needToCheckFailover = needToCheckFailover(jobConfig);
        String jobName = jobConfig.getJobName();
        String serverNodePath = JobNodePath.getServerNodePath(jobName);
        if (!curatorFrameworkOp.checkExists(serverNodePath)) {
            continue;
        }
        String sharding = curatorFrameworkOp.getData(JobNodePath.getServerNodePath(jobName, executorName, "sharding"));
        Set<String> shardingItems = getShardingItems(sharding);
        if (needToCheckFailover) {
            obtainServerRunningInfoWhileNeedToCheckFailover(executorName, curatorFrameworkOp, jobName, shardingItems, serverRunningInfo);
        } else if (!shardingItems.isEmpty()) {
            obtainServerRunningInfoWhileNoNeedToCheckFailover(curatorFrameworkOp, jobConfig, shardingItems, serverRunningInfo);
        }
    }
    return serverRunningInfo;
}
Also used : CuratorRepository(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository) CuratorFrameworkOp(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)

Example 47 with CuratorFrameworkOp

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

the class ExecutorServiceImpl method recoverTraffic.

@Override
public void recoverTraffic(String namespace, String executorName) throws SaturnJobConsoleException {
    CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = getCuratorFrameworkOp(namespace);
    validateIfExecutorNameExisted(executorName, curatorFrameworkOp);
    curatorFrameworkOp.deleteRecursive(ExecutorNodePath.getExecutorNoTrafficNodePath(executorName));
}
Also used : CuratorRepository(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository) CuratorFrameworkOp(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)

Example 48 with CuratorFrameworkOp

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

the class ExecutorServiceImpl method shardAll.

@Override
public void shardAll(String namespace) throws SaturnJobConsoleException {
    CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = getCuratorFrameworkOp(namespace);
    String shardAllAtOnceNodePath = ExecutorNodePath.getExecutorShardingNodePath("shardAllAtOnce");
    curatorFrameworkOp.deleteRecursive(shardAllAtOnceNodePath);
    curatorFrameworkOp.create(shardAllAtOnceNodePath);
}
Also used : CuratorRepository(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository) CuratorFrameworkOp(com.vip.saturn.job.console.repository.zookeeper.CuratorRepository.CuratorFrameworkOp)

Example 49 with CuratorFrameworkOp

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

the class NamespaceZkClusterMappingServiceImpl method initNamespaceZkClusterMapping.

@Override
public void initNamespaceZkClusterMapping(String createdBy) throws SaturnJobConsoleException {
    try {
        List<ZkClusterInfo> allZkClusterInfo = zkClusterInfoService.getAllZkClusterInfo();
        if (allZkClusterInfo != null) {
            for (ZkClusterInfo zkClusterInfo : allZkClusterInfo) {
                String zkClusterKey = zkClusterInfo.getZkClusterKey();
                String connectString = zkClusterInfo.getConnectString();
                CuratorFramework curatorFramework = null;
                CuratorRepository.CuratorFrameworkOp curatorFrameworkOp = registryCenterService.connectOnly(connectString, null);
                if (curatorFrameworkOp != null) {
                    curatorFramework = curatorFrameworkOp.getCuratorFramework();
                }
                if (curatorFramework != null) {
                    // not offline
                    updateNamepsaceAndZKClusterMapping(createdBy, zkClusterKey, curatorFramework);
                }
            }
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new SaturnJobConsoleException(e);
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) 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) ZkClusterInfo(com.vip.saturn.job.console.mybatis.entity.ZkClusterInfo) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException)

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