zookeeper获取kafka相应分区的offset(java语言)

limeng_zxj 2016-07-13 06:53:55
看kafka在zookeeper的存储路径为 ///consumers/[groupId]/offsets/[topic]/[partitionId] -> long (offset),但是不知道具体怎么取。
求大神帮忙,万分感谢
public List<String> getOffSet(String topic) {
List<String> results = null;
// zookeeper中保存partitions的路径
String partitions = "/consumers/group1/offsets/help/0";
System.out.println(partitions);
///consumers/[groupId]/offsets/[topic]/[partitionId] -> long (offset)
try {
// 获取子节点
results = this.zookeeper.getChildren(partitions, true);
} catch (KeeperException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
return results;
}
...全文
224 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,527

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧