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);

      //we only update short queue name ambiguity for non root queues
      if (!shortName.equals(CapacitySchedulerConfiguration.ROOT)) {
        //getting or creating the ambiguity set for the current queue
        Set<String> fullNamesSet =
            this.shortNameToLongNames.getOrDefault(shortName, new HashSet<>());

        //adding the full name to the queue
        fullNamesSet.add(fullName);
        this.shortNameToLongNames.put(shortName, fullNamesSet);
      }

      //updating the getMap references for the queue
      updateGetMapForShortName(shortName);
    } finally {
      modificationLock.writeLock().unlock();
    }
  }
@Test
  public void testQueueReferencePrecedence() throws IOException {
    CSQueueStore store = new CSQueueStore();

    //root.main.a.b
    //root.second.a.d.b.c
    // a - ambiguous both instances are parent queues
    // b - leaf queue b takes precedence over parent queue b

    //root.main
    CSQueue main = createParentQueue("main", root);
    //root.main.A
    CSQueue mainA = createParentQueue("A", main);
    //root.main.A.B
    CSQueue mainAB = createLeafQueue("B", mainA);
    //root.second
    CSQueue second = createParentQueue("second", root);
    //root.second.A
    CSQueue secondA = createParentQueue("A", second);
    //root.second.A.B
    CSQueue secondAD = createParentQueue("D", secondA);
    //root.second.A.B.D
    CSQueue secondADB = createParentQueue("B", secondAD);
    //root.second.A.B.D.C
    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);
  }