use of com.vip.saturn.job.console.domain.RegistryCenterConfiguration in project Saturn by vipshop.
the class InitRegistryCenterService method initTreeJson.
public static void initTreeJson(ArrayList<RegistryCenterConfiguration> registryCenterConfiguration, String zkBsk) {
TreeNode treeData = new TreeNode();
for (RegistryCenterConfiguration conf : registryCenterConfiguration) {
String nameAndnameSpace = conf.getNameAndNamespace();
if (nameAndnameSpace.startsWith("/")) {
nameAndnameSpace = nameAndnameSpace.substring(1);
}
treeData = parseDirectory2Tree(nameAndnameSpace, treeData, conf.getNameAndNamespace(), conf.getDegree());
}
ZKBSKEY_TO_TREENODE_MAP.put(zkBsk, treeData);
log.info("init {} tree data: {}", zkBsk, treeData);
}
use of com.vip.saturn.job.console.domain.RegistryCenterConfiguration in project Saturn by vipshop.
the class AbstractController method getNamespace.
public String getNamespace() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
RegistryCenterConfiguration configuration = (RegistryCenterConfiguration) request.getSession().getAttribute(SessionAttributeKeys.ACTIVATED_CONFIG_SESSION_KEY);
if (configuration != null) {
return configuration.getNamespace();
}
return null;
}
use of com.vip.saturn.job.console.domain.RegistryCenterConfiguration in project Saturn by vipshop.
the class JobConfigController method load.
@RequestMapping(value = "jobconfig/getExportRegList", method = RequestMethod.GET)
@ResponseBody
public RequestResult load(HttpServletRequest request) {
RequestResult requestResult = new RequestResult();
try {
List<RegistryCenterConfiguration> regCenterConfList = jobConfigInitializationService.getRegistryCenterConfigurations();
requestResult.setSuccess(true);
requestResult.setObj(regCenterConfList);
} catch (Throwable t) {
LOGGER.error(t.getMessage(), t);
requestResult.setSuccess(false);
requestResult.setMessage(t.toString());
}
return requestResult;
}
use of com.vip.saturn.job.console.domain.RegistryCenterConfiguration in project Saturn by vipshop.
the class CuratorSessionClientInterceptor method preHandle.
@Override
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) throws Exception {
String nns = request.getParameter(AbstractController.REQUEST_NAMESPACE_PARAM);
if (!Strings.isNullOrEmpty(nns)) {
RegistryCenterClient client = registryCenterService.connect(nns);
ThreadLocalCuratorClient.setCuratorClient(client.getCuratorClient());
RegistryCenterConfiguration conf = registryCenterService.findConfig(client.getNameAndNamespace());
if (conf == null) {
response.sendRedirect(request.getContextPath() + "/registry_center_page");
return false;
}
request.getSession().setAttribute(SessionAttributeKeys.ACTIVATED_CONFIG_SESSION_KEY, conf);
request.getSession().setAttribute(SessionAttributeKeys.CURRENT_ZK_CLUSTER_KEY, conf.getZkClusterKey());
return true;
}
RegistryCenterConfiguration reg = (RegistryCenterConfiguration) request.getSession().getAttribute(SessionAttributeKeys.ACTIVATED_CONFIG_SESSION_KEY);
if (reg == null) {
response.sendRedirect(request.getContextPath() + "/registry_center_page");
return false;
}
RegistryCenterClient client = registryCenterService.getCuratorByNameAndNamespace(reg.getNameAndNamespace());
if (null == client || !client.isConnected()) {
response.sendRedirect(request.getContextPath() + "/registry_center_page");
return false;
}
ThreadLocalCuratorClient.setCuratorClient(client.getCuratorClient());
return true;
}
use of com.vip.saturn.job.console.domain.RegistryCenterConfiguration in project Saturn by vipshop.
the class RestApiServiceImplTest method setUp.
@Before
public void setUp() throws Exception {
when(registryCenterService.findConfigByNamespace(anyString())).thenReturn(new RegistryCenterConfiguration());
RegistryCenterClient registryCenterClient = new RegistryCenterClient();
registryCenterClient.setCuratorClient(curatorFramework);
registryCenterClient.setConnected(true);
when(registryCenterService.connectByNamespace(anyString())).thenReturn(registryCenterClient);
when(curatorRepository.newCuratorFrameworkOp(any(CuratorFramework.class))).thenReturn(curatorFrameworkOp);
when(curatorFrameworkOp.checkExists(JobNodePath.getJobNodePath(anyString()))).thenReturn(true);
}
Aggregations