RMNodeLabelsManager extends CommonNodeLabelsManager { protected void checkRemoveFromClusterNodeLabelsOfQueue( Collection<String> labelsToRemove) throws IOException { for (String label : labelsToRemove) { label = normalizeLabel(label); for (Entry<String, Queue> entry : queueCollections.entrySet()) { String queueName = entry.getKey(); Set<String> queueLabels = entry.getValue().accessibleNodeLabels; if (queueLabels.contains(label)) { throw new IOException("Cannot remove label=" + label + ", because queue=" + queueName + " is using this label. " + "Please remove label on queue before remove the label"); } } } }  @Override void addLabelsToNode(Map<NodeId, Set<String>> addedLabelsToNode); @Override void removeFromClusterNodeLabels(Collection<String> labelsToRemove); @Override void removeLabelsFromNode(Map<NodeId, Set<String>> removeLabelsFromNode); @Override void replaceLabelsOnNode(Map<NodeId, Set<String>> replaceLabelsToNode); void activateNode(NodeId nodeId, Resource resource); void deactivateNode(NodeId nodeId); void updateNodeResource(NodeId node, Resource newResource); void reinitializeQueueLabels(Map<String, Set<String>> queueToLabels); Resource getQueueResource(String queueName, Set<String> queueLabels,
      Resource clusterResource); Set<String> getLabelsOnNode(NodeId nodeId); boolean containsNodeLabel(String label); Resource getResourceByLabel(String label, Resource clusterResource); boolean checkAccess(UserGroupInformation user); void setRMContext(RMContext rmContext); List<RMNodeLabel> pullRMNodeLabelsInfo();  }
@Test(timeout = 60000) public void testcheckRemoveFromClusterNodeLabelsOfQueue() throws Exception { class TestRMLabelManger extends RMNodeLabelsManager { @Override protected void checkRemoveFromClusterNodeLabelsOfQueue( Collection<String> labelsToRemove) throws IOException { checkQueueCall = true; } } lmgr = new TestRMLabelManger(); Configuration conf = new Configuration(); File tempDir = File.createTempFile("nlb", ".tmp"); tempDir.delete(); tempDir.mkdirs(); tempDir.deleteOnExit(); conf.set(YarnConfiguration.FS_NODE_LABELS_STORE_ROOT_DIR, tempDir.getAbsolutePath()); conf.setBoolean(YarnConfiguration.NODE_LABELS_ENABLED, true); MockRM rm = new MockRM(conf) { @Override public RMNodeLabelsManager createNodeLabelManager() { return lmgr; } }; lmgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("a")); lmgr.removeFromClusterNodeLabels(Arrays.asList(new String[] { "a" })); rm.getRMContext().setNodeLabelManager(lmgr); rm.start(); lmgr.addToCluserNodeLabelsWithDefaultExclusivity(toSet("a")); Assert.assertEquals(false, checkQueueCall); lmgr.removeFromClusterNodeLabels(Arrays.asList(new String[] { "a" })); Assert.assertEquals(true, checkQueueCall); lmgr.stop(); lmgr.close(); rm.stop(); }