ClusterNodeTracker { public int nodeCount() { readLock.lock(); try { return nodes.size(); } finally { readLock.unlock(); } } ClusterNodeTracker(); void addNode(N node); boolean exists(NodeId nodeId); N getNode(NodeId nodeId); SchedulerNodeReport getNodeReport(NodeId nodeId); int nodeCount(); int nodeCount(String rackName); Resource getClusterCapacity(); N removeNode(NodeId nodeId); void setConfiguredMaxAllocation(Resource resource); void setConfiguredMaxAllocationWaitTime(
      long configuredMaxAllocationWaitTime); Resource getMaxAllowedAllocation(); @VisibleForTesting void setForceConfiguredMaxAllocation(boolean flag); List<N> getAllNodes(); List<N> getNodes(NodeFilter nodeFilter); List<NodeId> getAllNodeIds(); List<NodeId> getNodeIds(NodeFilter nodeFilter); List<N> sortedNodeList(Comparator<N> comparator); List<N> getNodesByResourceName(final String resourceName); List<NodeId> getNodeIdsByResourceName(final String resourceName); void updateNodesPerPartition(String partition, Set<NodeId> nodeIds); List<N> getNodesPerPartition(String partition);  }
@Test public void testGetNodeCount() { addEight4x4Nodes(); assertEquals("Incorrect number of nodes in the cluster", 8, nodeTracker.nodeCount()); assertEquals("Incorrect number of nodes in each rack", 4, nodeTracker.nodeCount("rack0")); }