RouterWebServiceUtil { public static void mergeMetrics(ClusterMetricsInfo metrics, ClusterMetricsInfo metricsResponse) { metrics.setAppsSubmitted( metrics.getAppsSubmitted() + metricsResponse.getAppsSubmitted()); metrics.setAppsCompleted( metrics.getAppsCompleted() + metricsResponse.getAppsCompleted()); metrics.setAppsPending( metrics.getAppsPending() + metricsResponse.getAppsPending()); metrics.setAppsRunning( metrics.getAppsRunning() + metricsResponse.getAppsRunning()); metrics.setAppsFailed( metrics.getAppsFailed() + metricsResponse.getAppsFailed()); metrics.setAppsKilled( metrics.getAppsKilled() + metricsResponse.getAppsKilled()); metrics.setReservedMB( metrics.getReservedMB() + metricsResponse.getReservedMB()); metrics.setAvailableMB( metrics.getAvailableMB() + metricsResponse.getAvailableMB()); metrics.setAllocatedMB( metrics.getAllocatedMB() + metricsResponse.getAllocatedMB()); metrics.setReservedVirtualCores(metrics.getReservedVirtualCores() + metricsResponse.getReservedVirtualCores()); metrics.setAvailableVirtualCores(metrics.getAvailableVirtualCores() + metricsResponse.getAvailableVirtualCores()); metrics.setAllocatedVirtualCores(metrics.getAllocatedVirtualCores() + metricsResponse.getAllocatedVirtualCores()); metrics.setContainersAllocated(metrics.getContainersAllocated() + metricsResponse.getContainersAllocated()); metrics.setContainersReserved(metrics.getReservedContainers() + metricsResponse.getReservedContainers()); metrics.setContainersPending(metrics.getPendingContainers() + metricsResponse.getPendingContainers()); metrics.setTotalMB(metrics.getTotalMB() + metricsResponse.getTotalMB()); metrics.setTotalVirtualCores(metrics.getTotalVirtualCores() + metricsResponse.getTotalVirtualCores()); metrics.setTotalNodes(metrics.getTotalNodes() + metricsResponse.getTotalNodes()); metrics.setLostNodes(metrics.getLostNodes() + metricsResponse.getLostNodes()); metrics.setUnhealthyNodes(metrics.getUnhealthyNodes() + metricsResponse.getUnhealthyNodes()); metrics.setDecommissioningNodes(metrics.getDecommissioningNodes() + metricsResponse.getDecommissioningNodes()); metrics.setDecommissionedNodes(metrics.getDecommissionedNodes() + metricsResponse.getDecommissionedNodes()); metrics.setRebootedNodes(metrics.getRebootedNodes() + metricsResponse.getRebootedNodes()); metrics.setActiveNodes(metrics.getActiveNodes() + metricsResponse.getActiveNodes()); metrics.setShutdownNodes(metrics.getShutdownNodes() + metricsResponse.getShutdownNodes()); } private  RouterWebServiceUtil(); static Response clientResponseToResponse(ClientResponse r); static void retrieveException(ClientResponse response); static AppsInfo mergeAppsInfo(ArrayList<AppInfo> appsInfo,
      boolean returnPartialResult); static NodesInfo deleteDuplicateNodesInfo(ArrayList<NodeInfo> nodes); static void mergeMetrics(ClusterMetricsInfo metrics,
      ClusterMetricsInfo metricsResponse);  }
@Test public void testMergeMetrics() { ClusterMetricsInfo metrics = new ClusterMetricsInfo(); ClusterMetricsInfo metricsResponse = new ClusterMetricsInfo(); long seed = System.currentTimeMillis(); setUpClusterMetrics(metrics, seed); seed += 1000000000; setUpClusterMetrics(metricsResponse, seed); ClusterMetricsInfo metricsClone = createClusterMetricsClone(metrics); RouterWebServiceUtil.mergeMetrics(metrics, metricsResponse); Assert.assertEquals( metricsResponse.getAppsSubmitted() + metricsClone.getAppsSubmitted(), metrics.getAppsSubmitted()); Assert.assertEquals( metricsResponse.getAppsCompleted() + metricsClone.getAppsCompleted(), metrics.getAppsCompleted()); Assert.assertEquals( metricsResponse.getAppsPending() + metricsClone.getAppsPending(), metrics.getAppsPending()); Assert.assertEquals( metricsResponse.getAppsRunning() + metricsClone.getAppsRunning(), metrics.getAppsRunning()); Assert.assertEquals( metricsResponse.getAppsFailed() + metricsClone.getAppsFailed(), metrics.getAppsFailed()); Assert.assertEquals( metricsResponse.getAppsKilled() + metricsClone.getAppsKilled(), metrics.getAppsKilled()); Assert.assertEquals( metricsResponse.getReservedMB() + metricsClone.getReservedMB(), metrics.getReservedMB()); Assert.assertEquals( metricsResponse.getAvailableMB() + metricsClone.getAvailableMB(), metrics.getAvailableMB()); Assert.assertEquals( metricsResponse.getAllocatedMB() + metricsClone.getAllocatedMB(), metrics.getAllocatedMB()); Assert.assertEquals( metricsResponse.getReservedVirtualCores() + metricsClone.getReservedVirtualCores(), metrics.getReservedVirtualCores()); Assert.assertEquals( metricsResponse.getAvailableVirtualCores() + metricsClone.getAvailableVirtualCores(), metrics.getAvailableVirtualCores()); Assert.assertEquals( metricsResponse.getAllocatedVirtualCores() + metricsClone.getAllocatedVirtualCores(), metrics.getAllocatedVirtualCores()); Assert.assertEquals( metricsResponse.getContainersAllocated() + metricsClone.getContainersAllocated(), metrics.getContainersAllocated()); Assert.assertEquals( metricsResponse.getReservedContainers() + metricsClone.getReservedContainers(), metrics.getReservedContainers()); Assert.assertEquals( metricsResponse.getPendingContainers() + metricsClone.getPendingContainers(), metrics.getPendingContainers()); Assert.assertEquals( metricsResponse.getTotalMB() + metricsClone.getTotalMB(), metrics.getTotalMB()); Assert.assertEquals( metricsResponse.getTotalVirtualCores() + metricsClone.getTotalVirtualCores(), metrics.getTotalVirtualCores()); Assert.assertEquals( metricsResponse.getTotalNodes() + metricsClone.getTotalNodes(), metrics.getTotalNodes()); Assert.assertEquals( metricsResponse.getLostNodes() + metricsClone.getLostNodes(), metrics.getLostNodes()); Assert.assertEquals( metricsResponse.getUnhealthyNodes() + metricsClone.getUnhealthyNodes(), metrics.getUnhealthyNodes()); Assert.assertEquals( metricsResponse.getDecommissioningNodes() + metricsClone.getDecommissioningNodes(), metrics.getDecommissioningNodes()); Assert.assertEquals( metricsResponse.getDecommissionedNodes() + metricsClone.getDecommissionedNodes(), metrics.getDecommissionedNodes()); Assert.assertEquals( metricsResponse.getRebootedNodes() + metricsClone.getRebootedNodes(), metrics.getRebootedNodes()); Assert.assertEquals( metricsResponse.getActiveNodes() + metricsClone.getActiveNodes(), metrics.getActiveNodes()); Assert.assertEquals( metricsResponse.getShutdownNodes() + metricsClone.getShutdownNodes(), metrics.getShutdownNodes()); }