Znode信息中,补充当前节点路径信息

This commit is contained in:
zengqiao
2022-10-29 13:36:54 +08:00
committed by EricZeng
parent 0e71ecc587
commit e98ec562a2
6 changed files with 12 additions and 404 deletions

View File

@@ -16,4 +16,7 @@ public class Znode {
@ApiModelProperty(value = "节点属性", example = "")
private Stat stat;
@ApiModelProperty(value = "节点路径", example = "")
private String namespace;
}

View File

@@ -19,4 +19,7 @@ public class ZnodeVO {
@ApiModelProperty(value = "节点属性", example = "")
private ZnodeStatVO stat;
@ApiModelProperty(value = "节点路径", example = "/cluster")
private String namespace;
}

View File

@@ -1,7 +1,9 @@
package com.xiaojukeji.know.streaming.km.common.converter;
import com.xiaojukeji.know.streaming.km.common.bean.entity.cluster.ClusterPhy;
import com.xiaojukeji.know.streaming.km.common.bean.entity.zookeeper.Znode;
import com.xiaojukeji.know.streaming.km.common.utils.Tuple;
import com.xiaojukeji.know.streaming.km.common.utils.zookeeper.ZookeeperUtils;
import org.apache.zookeeper.data.Stat;
public class ZnodeConverter {
@@ -9,11 +11,13 @@ public class ZnodeConverter {
}
public static Znode convert2Znode(Tuple<byte[], Stat> dataAndStat, String path) {
public static Znode convert2Znode(ClusterPhy clusterPhy, Tuple<byte[], Stat> dataAndStat, String path) {
Znode znode = new Znode();
znode.setStat(dataAndStat.getV2());
znode.setData(dataAndStat.getV1() == null ? null : new String(dataAndStat.getV1()));
znode.setName(path.substring(path.lastIndexOf('/') + 1));
znode.setNamespace(ZookeeperUtils.getNamespace(clusterPhy.getZookeeper()));
return znode;
}
}