Class AccountDao


  • public class AccountDao
    extends java.lang.Object
    Account Data Access Object.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  AccountDao.StatementType
      Types of MySql statements.
    • Constructor Summary

      Constructors 
      Constructor Description
      AccountDao​(com.github.ambry.mysql.MySqlDataAccessor dataAccessor)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.github.ambry.account.Container getContainerById​(int accountId, int containerId)
      Gets container by its Id and parent account Id.
      com.github.ambry.account.Container getContainerByName​(int accountId, java.lang.String containerName)
      Gets container by its name and parent account Id.
      java.util.List<com.github.ambry.account.Container> getContainers​(int accountId)
      Gets the containers in a specified account.
      java.util.List<com.github.ambry.account.Account> getNewAccounts​(long updatedSince)
      Gets all accounts that have been created or modified since the specified time.
      java.util.List<com.github.ambry.account.Container> getNewContainers​(long updatedSince)
      Gets all containers that have been created or modified since the specified time.
      void updateAccounts​(java.util.List<AccountUtils.AccountUpdateInfo> accountsInfo, int batchSize)
      Adds/Updates accounts and their containers to the database in batches atomically using transaction.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AccountDao

        public AccountDao​(com.github.ambry.mysql.MySqlDataAccessor dataAccessor)
    • Method Detail

      • getNewAccounts

        public java.util.List<com.github.ambry.account.Account> getNewAccounts​(long updatedSince)
                                                                        throws java.sql.SQLException
        Gets all accounts that have been created or modified since the specified time.
        Parameters:
        updatedSince - the last modified time used to filter.
        Returns:
        a list of Accounts.
        Throws:
        java.sql.SQLException
      • getContainers

        public java.util.List<com.github.ambry.account.Container> getContainers​(int accountId)
                                                                         throws java.sql.SQLException
        Gets the containers in a specified account.
        Parameters:
        accountId - the id for the parent account.
        Returns:
        a list of Containers.
        Throws:
        java.sql.SQLException
      • getNewContainers

        public java.util.List<com.github.ambry.account.Container> getNewContainers​(long updatedSince)
                                                                            throws java.sql.SQLException
        Gets all containers that have been created or modified since the specified time.
        Parameters:
        updatedSince - the last modified time used to filter.
        Returns:
        a list of Containers.
        Throws:
        java.sql.SQLException
      • getContainerByName

        public com.github.ambry.account.Container getContainerByName​(int accountId,
                                                                     java.lang.String containerName)
                                                              throws java.sql.SQLException
        Gets container by its name and parent account Id.
        Parameters:
        accountId - the id for the parent account.
        containerName - name of the container.
        Returns:
        Container if found in mysql db or null if it doesn't exist.
        Throws:
        java.sql.SQLException
      • getContainerById

        public com.github.ambry.account.Container getContainerById​(int accountId,
                                                                   int containerId)
                                                            throws java.sql.SQLException
        Gets container by its Id and parent account Id.
        Parameters:
        accountId - the id for the parent account.
        containerId - the id of the container.
        Returns:
        Container if found in mysql db or null if it doesn't exist.
        Throws:
        java.sql.SQLException
      • updateAccounts

        public void updateAccounts​(java.util.List<AccountUtils.AccountUpdateInfo> accountsInfo,
                                   int batchSize)
                            throws java.sql.SQLException
        Adds/Updates accounts and their containers to the database in batches atomically using transaction.
        Parameters:
        accountsInfo - information of updated Accounts
        batchSize - number of statements to be executed in one batch
        Throws:
        java.sql.SQLException