void addOrUpdateAccounts(Collection<Account> accounts) {
    for (Account account : accounts) {
      Account accountToUpdate = idToAccountMap.get(account.getId());
      if (accountToUpdate == null) {
        accountToUpdate = account;
      } else {
        // Remove name to Account mapping for existing account as name might have been updated.
        nameToAccountMap.remove(accountToUpdate.getName());
        AccountBuilder accountBuilder = new AccountBuilder(accountToUpdate).name(account.getName())
            .status(account.getStatus())
            .snapshotVersion(account.getSnapshotVersion())
            .lastModifiedTime(account.getLastModifiedTime())
            .aclInheritedByContainer(account.isAclInheritedByContainer())
            .quotaResourceType(account.getQuotaResourceType());
        account.getAllContainers().forEach(accountBuilder::addOrUpdateContainer);
        accountToUpdate = accountBuilder.build();
      }
      idToAccountMap.put(accountToUpdate.getId(), accountToUpdate);
      nameToAccountMap.put(accountToUpdate.getName(), accountToUpdate);
    }
  }
Adds or updates the {@code AccountInfoMap} with the input {@link Collection} of {@link Account}s.
@param accounts collection of {@link Account}s to be added.
ambry-account/src/main/java/com/github/ambry/account/AccountInfoMap.java