本文整理了Java中com.ke.kob.basic.constant.ZkPathConstant.clientNodePath()
方法的一些代码示例,展示了ZkPathConstant.clientNodePath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkPathConstant.clientNodePath()
方法的具体详情如下:
包路径:com.ke.kob.basic.constant.ZkPathConstant
类名称:ZkPathConstant
方法名:clientNodePath
暂无
代码示例来源:origin: LianjiaTech/kob
@Override
public Map<String, ClientPath> getClientPaths(String projectCode) {
String clientNodePath = ZkPathConstant.clientNodePath(cluster, projectCode);
if (!zkClient.exists(clientNodePath)) {
return null;
}
List<String> nodePathStrList = zkClient.getChildren(clientNodePath);
Map<String, ClientPath> projectClientPath = new HashMap<>(10);
if (!KobUtils.isEmpty(nodePathStrList)) {
for (String child : nodePathStrList) {
ClientPath clientPath = JSONObject.parseObject(child, ClientPath.class);
projectClientPath.put(clientPath.getIdentification(), clientPath);
}
}
return projectClientPath;
}
}
代码示例来源:origin: LianjiaTech/kob
@Override
public Map<String, ClientInfo> getClientNodes(String projectCode) {
String clientNodePath = ZkPathConstant.clientNodePath(cluster, projectCode);
if (!zkClient.exists(clientNodePath)) {
return new HashMap<>(0);
}
List<String> nodeClientStrList = zkClient.getChildren(clientNodePath);
Map<String, ClientInfo> projectClientNode = new HashMap<>(10);
if (!KobUtils.isEmpty(nodeClientStrList)) {
for (String child : nodeClientStrList) {
ClientPath clientPath = JSONObject.parseObject(child, ClientPath.class);
String path = ZkPathConstant.clientNodePath(cluster, projectCode) + ZkPathConstant.BACKSLASH + child;
String dataStr = zkClient.readData(path, true);
if (!KobUtils.isEmpty(dataStr)) {
ClientData clientData = JSONObject.parseObject(dataStr, ClientData.class);
projectClientNode.put(clientPath.getIdentification(), new ClientInfo(path, clientPath, clientData));
}
}
}
return projectClientNode;
}
代码示例来源:origin: LianjiaTech/kob
private void refreshClientNode(List<String> currentChilds, String project) {
Map<String, ClientInfo> projectClientNode = new ConcurrentHashMap<>();
if (!KobUtils.isEmpty(currentChilds)) {
for (String child : currentChilds) {
ClientPath clientPath = JSONObject.parseObject(child, ClientPath.class);
String path = ZkPathConstant.clientNodePath(serverContext.getCluster(), project) + ZkPathConstant.BACKSLASH + child;
String dataStr = zkClient.readData(path, true);
if (!KobUtils.isEmpty(dataStr)) {
ClientData clientData = JSONObject.parseObject(dataStr, ClientData.class);
projectClientNode.put(clientPath.getIdentification(), new ClientInfo(path, clientPath, clientData));
}
}
}
serverContext.getClientNodeMap().put(project, projectClientNode);
}
代码示例来源:origin: LianjiaTech/kob
/**
* 保存项目接入信息
*
* @return ResponseData
*/
@RequestMapping(value = "/save_project_access.json")
@ResponseBody
public ResponseData saveProjectAccess() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
User user = (User) request.getSession().getAttribute(Attribute.SESSION_USER);
String projectCode = request.getParameter("project_code");
String regex = "([A-Z]|[a-z]|_){6,60}";
if (KobUtils.isEmpty(projectCode) || !projectCode.matches(regex)) {
return ResponseData.error("项目标识有误");
}
String projectName = request.getParameter("project_name");
if (KobUtils.isEmpty(projectName) || projectName.length() > 60) {
return ResponseData.error("项目名称有误");
}
boolean zkExist = zkClient.exists(ZkPathConstant.clientNodePath(cluster, projectCode));
boolean dbExist = indexService.existProject(projectCode);
if (zkExist || dbExist) {
return ResponseData.error("项目已存在");
}
indexService.initProject(user.getCode(), user.getName(), user.getConfiguration(), projectCode, projectName);
zkClient.createPersistent(ZkPathConstant.clientNodePath(cluster, projectCode), true);
zkClient.createPersistent(ZkPathConstant.clientTaskPath(cluster, projectCode), true);
return ResponseData.success();
}
代码示例来源:origin: LianjiaTech/kob
for (final String currentProjectCode : currentProjectCodeSet) {
if (localProjectCodeSet.add(currentProjectCode)) {
zkClient.subscribeChildChanges(ZkPathConstant.clientNodePath(serverContext.getCluster(), currentProjectCode), new IZkChildListener() {
@Override
public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
代码示例来源:origin: LianjiaTech/kob
okHttpClient = okHttpClientBuilder.build();
clientTaskPath = ZkPathConstant.clientTaskPath(prop.getCluster(), prop.getProjectCode());
clientNodePath = ZkPathConstant.clientNodePath(prop.getCluster(), prop.getProjectCode());
buildKobRunner(beans);
buildClientInfo(prop);
代码示例来源:origin: LianjiaTech/kob
innerParams.setTaskPushNode(serverIdentification);
if (LoadBalanceType.NODE_HASH.name().equals(tw.getLoadBalance())) {
List<String> clientNodePathList = zkClient.getChildren(ZkPathConstant.clientNodePath(cluster, tw.getProjectCode()));
List<String> nodeList = new ArrayList<>();
if (!KobUtils.isEmpty(clientNodePathList)) {
内容来源于网络,如有侵权,请联系作者删除!