补充获取ZK的namespace的方法

This commit is contained in:
zengqiao
2022-10-29 13:27:54 +08:00
committed by EricZeng
parent da00c8c877
commit 0f11a65df8

View File

@@ -16,7 +16,7 @@ public class ZookeeperUtils {
* 解析ZK地址
* @see ConnectStringParser
*/
public static List<Tuple<String, Integer>> connectStringParser(String connectString) throws Exception {
public static List<Tuple<String, Integer>> connectStringParser(String connectString) {
List<Tuple<String, Integer>> ipPortList = new ArrayList<>();
if (connectString == null) {
@@ -55,5 +55,14 @@ public class ZookeeperUtils {
return ipPortList;
}
public static String getNamespace(String zookeeperAddress) {
int index = zookeeperAddress.indexOf('/');
String namespace = "/";
if (index != -1) {
namespace = zookeeperAddress.substring(index);
}
return namespace;
}
}