@Override
  public void updateAccounts(Collection<Account> accounts) throws AccountServiceException {
    if (hasDuplicateAccountIdOrName(accounts)) {
      accountServiceMetrics.updateAccountErrorCount.inc();
      throw new AccountServiceException("Duplicate account id or name exist in the accounts to update",
          AccountServiceErrorCode.ResourceConflict);
    }

    if (accountInfoMapRef.get().hasConflictingAccount(accounts, true)) {
      throw new AccountServiceException("Input accounts conflict with the accounts in local cache",
          AccountServiceErrorCode.ResourceConflict);
    }

    for (Account account : accounts) {
      if (accountInfoMapRef.get().hasConflictingContainer(account.getAllContainers(), account.getId(), true)) {
        throw new AccountServiceException("Containers in account " + account.getId() + " conflict with local cache",
            AccountServiceErrorCode.ResourceConflict);
      }
    }

    accountInfoMapRef.get().addOrUpdateAccounts(accounts);
  }
Adds accounts

@param accounts The collection of {@link Account}s to update. Cannot be {@code null}.
ambry-account/src/main/java/com/github/ambry/account/InMemoryAccountService.java