boolean hasConflictingContainer(Collection<Container> containersToSet, short parentAccountId, boolean ignoreVersion) {
    Account account = idToAccountMap.get(parentAccountId);
    if (account == null) {
      return false;
    }
    for (Container container : containersToSet) {
      // if the container already exists, check that the snapshot version matches the expected value.
      Container containerInMap = account.getContainerByName(container.getName());
      if (!ignoreVersion && containerInMap != null
          && container.getSnapshotVersion() != containerInMap.getSnapshotVersion()) {
        // Snapshot version only matters if other container properties are modified
        if (!container.isSameContainer(containerInMap)) {
          logger.error(
              "Container to update in AccountId {} (containerId={} containerName={}) has an unexpected snapshot version in store (expected={}, encountered={})",
              parentAccountId, container.getId(), container.getName(), container.getSnapshotVersion(),
              containerInMap.getSnapshotVersion());
          return true;
        }
      }

      // check that there are no other containers that conflict with the name of the container to update
      if (containerInMap != null && containerInMap.getId() != (container.getId())) {
        logger.error(
            "Container to update in AccountId {} (containerId={} containerName={}) conflicts with an existing record (containerId={} containerName={})",
            parentAccountId, container.getId(), container.getName(), containerInMap.getId(), containerInMap.getName());
        return true;
      }
    }
    return false;
  }
Checks if there are any name/ID conflicts between {@link Container}s being updated with existing {@link Container}s
under its parent {@link Account}. Two {@link Container}s can be conflicting with each other if they have
different {@link Container} Ids but the same {@link Container} name.
@param containersToSet {@link Container}s to check for conflict
@param parentAccountId parent {@link Account} id of the {@link Container}.
@param ignoreVersion {@code true} if mismatch in account version can be ignored.
@return true if there is any container under given parent account with same name but different id.
ambry-account/src/main/java/com/github/ambry/account/AccountInfoMap.java