ClusterStatusServlet extends HttpServlet { public static List<FileSetStatusRow> getFileSetStatusTable( ZooKeeperManager zkManager, List<FileSetWithErrorRow> fileSetsWithError) { List<FileSetStatusRow> rows = new ArrayList<FileSetStatusRow>(); Map<String, FileSetInfo> fileSetMap = zkManager.getFileSetInfoMap(); for (Map.Entry<String, FileSetInfo> entry : fileSetMap.entrySet()) { String fileSet = entry.getKey(); FileSetInfo fileSetInfo = entry.getValue(); if (fileSetInfo.servingInfo == null) { fileSetsWithError.add(new FileSetWithErrorRow(fileSet, FileSetError.NO_SERVING_INFO)); continue; } ViewInfo viewInfo = zkManager.getViewInfo(fileSetInfo.servingInfo.helixResource); if (viewInfo == null) { fileSetsWithError.add(new FileSetWithErrorRow(fileSet, FileSetError.NO_VIEW_INFO)); continue; } rows.add(new FileSetStatusRow( fileSet, fileSetInfo.servingInfo.numPartitions, viewInfo.getNumOnlinePartitions(), fileSetInfo.servingInfo.hdfsPath )); } Collections.sort(rows); return rows; }  static long parseTimestampFromHdfsPath(String hdfsPath); static List<FileSetStatusRow> getFileSetStatusTable(
      ZooKeeperManager zkManager, List<FileSetWithErrorRow> fileSetsWithError); static List<LoadingFileSetRow> getLoadingFileSetTable(
      ZooKeeperManager zkManager, List<FileSetWithErrorRow> fileSetsWithError); static List<String> getAllNodeNames(DFSClient hdfsClient); @Override void doGet(HttpServletRequest request, HttpServletResponse response); static final String BASE_URI; }
@Test public void testGetFileSetStatusTable() { when(mockZKManager.getFileSetInfoMap()).thenReturn( ImmutableMap.of( "fileset1", mockFileSetInfo1, "fileset2", mockFileSetInfo2, "fileset3", mockFileSetInfo3, "fileset4", mockFileSetInfo4 ) ); when(mockZKManager.getViewInfo(eq("$fileset1$1234423233333"))).thenReturn(mockViewInfo1); when(mockZKManager.getViewInfo(eq("$fileset2$1344423233333"))).thenReturn(mockViewInfo2); when(mockZKManager.getViewInfo(eq("$fileset4$1344423233333"))).thenReturn(null); when(mockViewInfo1.getNumOnlinePartitions()).thenReturn(23); when(mockViewInfo2.getNumOnlinePartitions()).thenReturn(16); List<ClusterStatusServlet.FileSetWithErrorRow> fileSetsWithError = new ArrayList<ClusterStatusServlet.FileSetWithErrorRow>(); List<ClusterStatusServlet.FileSetStatusRow> fileSets = ClusterStatusServlet.getFileSetStatusTable(mockZKManager, fileSetsWithError); assertEquals(2, fileSets.size()); assertEquals( new ClusterStatusServlet.FileSetStatusRow("fileset1", 32, 23, "/fileset1/1234423233333"), fileSets.get(0) ); assertEquals( new ClusterStatusServlet.FileSetStatusRow("fileset2", 16, 16, "/fileset2/1344423233333"), fileSets.get(1) ); assertEquals(2, fileSetsWithError.size()); assertEquals( new ClusterStatusServlet.FileSetWithErrorRow("fileset3", ClusterStatusServlet.FileSetError.NO_SERVING_INFO), fileSetsWithError.get(0) ); assertEquals( new ClusterStatusServlet.FileSetWithErrorRow("fileset4", ClusterStatusServlet.FileSetError.NO_VIEW_INFO), fileSetsWithError.get(1) ); }