mgr.addNodeAttributes(toAddAttributes); mgr.getAttributesForNode("host0").size()); mgr.removeNodeAttributes(toAddAttributes); mgr.addNodeAttributes(toAddAttributes); mgr.replaceNodeAttributes(NodeAttribute.PREFIX_CENTRALIZED, toAddAttributes); mgr.addNodeAttributes(toAddAttributes); mgr.stop(); mgr = new MockNodeAttrbuteManager(); mgr.init(conf); mgr.start(); mgr.getAttributesForNode("host0").size()); Assert.assertEquals("host1 size", 2, mgr.getAttributesForNode("host1").size()); NodeAttribute.newInstance("GPU2", NodeAttributeType.STRING, "nvidia2"); toAddAttributes.put("host0", ImmutableSet.of(replaced)); mgr.replaceNodeAttributes(NodeAttribute.PREFIX_CENTRALIZED, toAddAttributes); mgr.stop();
@Test(timeout = 10000) public void testEmptyRecoverSkipInternalUdpate() throws Exception { // Stop manager mgr.stop(); // Start new attribute manager with same path mgr = spy(new MockNodeAttrbuteManager()); mgr.init(conf); mgr.start(); verify(mgr, times(0)) .internalUpdateAttributesOnNodes(any(), any(), any(), any()); }
mgr.addNodeAttributes(toAddAttributes); mgr.getAttributesForNode("host0").size()); mgr.removeNodeAttributes(toAddAttributes); mgr.replaceNodeAttributes(NodeAttribute.PREFIX_CENTRALIZED, toAddAttributes); Map<NodeAttribute, AttributeValue> attrs = mgr.getAttributesForNode("host0"); Assert.assertEquals(attrs.size(), 1); Assert.assertEquals(attrs.keySet().toArray()[0], docker); mgr.stop(); mgr = new MockNodeAttrbuteManager(); mgr.init(conf); mgr.start(); mgr.getAttributesForNode("host0"); Assert.assertEquals("host0 size", 1, mgr.getAttributesForNode("host0").size()); Assert.assertEquals("host1 size", 1, mgr.getAttributesForNode("host1").size()); attrs = mgr.getAttributesForNode("host0"); Assert.assertEquals(attrs.size(), 1); Assert.assertEquals(attrs.keySet().toArray()[0], docker); mgr.replaceNodeAttributes(NodeAttribute.PREFIX_CENTRALIZED, toAddAttributes);
@After public void after() throws IOException { FileSystemNodeAttributeStore fsStore = ((FileSystemNodeAttributeStore) mgr.store); fsStore.getFs().delete(fsStore.getFsWorkingPath(), true); mgr.stop(); }
@Before public void before() throws IOException { mgr = new MockNodeAttrbuteManager(); conf = new Configuration(); conf.setClass(YarnConfiguration.FS_NODE_ATTRIBUTE_STORE_IMPL_CLASS, FileSystemNodeAttributeStore.class, NodeAttributeStore.class); conf = NodeAttributeTestUtils.getRandomDirConf(conf); mgr.init(conf); mgr.start(); }