CSQueueStore { public void add(CSQueue queue) { String fullName = queue.getQueuePath(); String shortName = queue.getQueueShortName(); try { modificationLock.writeLock().lock(); fullNameQueues.put(fullName, queue); getMap.put(fullName, queue); if (!shortName.equals(CapacitySchedulerConfiguration.ROOT)) { Set<String> fullNamesSet = this.shortNameToLongNames.getOrDefault(shortName, new HashSet<>()); fullNamesSet.add(fullName); this.shortNameToLongNames.put(shortName, fullNamesSet); } updateGetMapForShortName(shortName); } finally { modificationLock.writeLock().unlock(); } }  void add(CSQueue queue); void remove(CSQueue queue); void remove(String name); CSQueue get(String name); void clear(); Collection<CSQueue> getQueues();  }
@Test public void testSimpleMapping() throws IOException { CSQueueStore store = new CSQueueStore(); CSQueue main = createParentQueue("main", root); CSQueue mainA = createLeafQueue("A", main); CSQueue mainB = createParentQueue("B", main); CSQueue mainBC = createLeafQueue("C", mainB); store.add(main); store.add(mainA); store.add(mainB); store.add(mainBC); assertAccessibleByAllNames(store, main); assertAccessibleByAllNames(store, mainA); assertAccessibleByAllNames(store, mainB); assertAccessibleByAllNames(store, mainBC); }
@Test public void testAmbiguousMapping() throws IOException { CSQueueStore store = new CSQueueStore(); CSQueue main = createParentQueue("main", root); CSQueue mainA = createParentQueue("A", main); CSQueue mainAC = createLeafQueue("C", mainA); CSQueue mainAD = createParentQueue("D", mainA); CSQueue mainADE = createLeafQueue("E", mainAD); CSQueue mainADF = createLeafQueue("F", mainAD); CSQueue mainB = createParentQueue("B", main); CSQueue mainBC = createLeafQueue("C", mainB); CSQueue mainBD = createParentQueue("D", mainB); CSQueue mainBDE = createLeafQueue("E", mainBD); CSQueue mainBDG = createLeafQueue("G", mainBD); store.add(main); store.add(mainA); store.add(mainAC); store.add(mainAD); store.add(mainADE); store.add(mainADF); store.add(mainB); store.add(mainBC); store.add(mainBD); store.add(mainBDE); store.add(mainBDG); assertAccessibleByAllNames(store, main); assertAccessibleByAllNames(store, mainA); assertAccessibleByAllNames(store, mainB); assertAccessibleByAllNames(store, mainADF); assertAccessibleByAllNames(store, mainBDG); assertAmbiguous(store, mainAC); assertAmbiguous(store, mainAD); assertAmbiguous(store, mainADE); assertAmbiguous(store, mainBC); assertAmbiguous(store, mainBD); assertAmbiguous(store, mainBDE); }
@Test public void testQueueOverwrites() throws IOException { CSQueueStore store = new CSQueueStore(); CSQueue main = createParentQueue("main", root); CSQueue mainA = createLeafQueue("A", main); CSQueue newA = createLeafQueue("A", main); store.add(main); store.add(mainA); assertAccessibleByAllNames(store, mainA); store.add(newA); assertAccessibleByAllNames(store, newA); }
@Test public void testQueueReferencePrecedence() throws IOException { CSQueueStore store = new CSQueueStore(); CSQueue main = createParentQueue("main", root); CSQueue mainA = createParentQueue("A", main); CSQueue mainAB = createLeafQueue("B", mainA); CSQueue second = createParentQueue("second", root); CSQueue secondA = createParentQueue("A", second); CSQueue secondAD = createParentQueue("D", secondA); CSQueue secondADB = createParentQueue("B", secondAD); CSQueue secondADBC = createLeafQueue("C", secondADB); store.add(main); store.add(mainA); store.add(mainAB); store.add(second); store.add(secondA); store.add(secondAD); store.add(secondADB); store.add(secondADBC); assertAccessibleByAllNames(store, main); assertAccessibleByAllNames(store, second); assertAmbiguous(store, mainA); assertAmbiguous(store, secondA); assertAmbiguous(store, mainAB); assertAccessibleByAllNames(store, secondAD); assertAmbiguous(store, secondADB); assertAccessibleByAllNames(store, secondADBC); }