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;
}
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));
}
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);
}
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);
}
}
Aggregations