ZooKeeperManager { public ClusterInfo getClusterInfo() throws Exception { byte[] data = zkClient.get().getData("/" + this.clusterName, false, new Stat()); if (data == null) { return null; } String json = new String(data); ClusterInfo info; try { info = ClusterInfo.fromJson(json.getBytes()); } catch (Exception e) { LOG.info("Invalid cluster info " + json); return null; } return info; } ZooKeeperManager(ZooKeeperClient zkClient, String clusterName); void createClusterPaths(); void registerWatchAllFileSets(); void lockFileSet(String fileSet,
                          FileSetInfo fileSetInfo,
                          CreateMode mode); void lockFileSet(String fileSet,
                          FileSetInfo fileSetInfo); void unlockFileSet(String fileSet); void setFileSetInfo(String fileSet,
                             FileSetInfo fileSetInfo); void deleteFileSetInfo(String fileSet); FileSetInfo getFileSetInfo(String fileSet); ViewInfo getViewInfo(String resource); void setViewInfo(ViewInfo viewInfo); void deleteViewInfo(String resource); FileSetInfo getFileSetInfoForced(String fileSet); FileSetInfo getLockedFileSetInfo(String fileSet); Map<String, Pair<FileSetInfo, FileSetInfo>> getCandidateHdfsDirMap(); InetSocketAddress getControllerLeader(); ClusterInfo getClusterInfo(); void setClusterInfo(ClusterInfo info); Map<String, FileSetInfo> getFileSetInfoMap(); List<String> getLockedFileSets(); List<String> getLiveInstances();  }
@Test public void testGetClusterInfo() throws Exception { String hdfsNameNode = "namenode001"; int replicaFactor = 3; ClusterInfo clusterInfo = new ClusterInfo(hdfsNameNode, replicaFactor); when(zk.getData(eq("/" + CLUSTER_NAME), anyBoolean(), any(Stat.class))) .thenReturn(clusterInfo.toJson()); ClusterInfo returnedInfo = zkManager.getClusterInfo(); assertEquals(hdfsNameNode, returnedInfo.hdfsNameNode); assertEquals(replicaFactor, returnedInfo.hdfsReplicationFactor); }