從Zookeeper獲取HDFS的Active名稱節點信息

String hadoopZkNode = "/hadoop-ha/${cluster_name}/ActiveStandbyElectorLock"; ZooKeeper  keeper = new ZooKeeper(${zookeeperConnection}, 10000, new SimpleWatcher()); Stat stat = new Stat(); byte[] data = keeper.getData(hadoopZkNode, new SimpleWatcher(), stat); //因爲HDFS在向Zookeeper上寫數據以前對數據進行了序列化,因此在獲取到字節數組時須要調用相應的反序列化方法進行反序列化 ActiveNodeInfo activeNodeInfo = HAZKInfoProtos.ActiveNodeInfo.parseFrom(data);
相關文章
相關標籤/搜索