Class MySqlAccountStore


  • public class MySqlAccountStore
    extends java.lang.Object
    Wrapper class to handle MySql store operations on Account and Container tables
    • Constructor Summary

      Constructors 
      Constructor Description
      MySqlAccountStore​(java.util.List<com.github.ambry.mysql.MySqlUtils.DbEndpoint> dbEndpoints, java.lang.String localDatacenter, com.github.ambry.mysql.MySqlMetrics metrics, com.github.ambry.config.MySqlAccountServiceConfig config)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addAccount​(com.github.ambry.account.Account account)
      Adds new Account to Account table in MySql DB
      void addAccounts​(java.util.Collection<com.github.ambry.account.Account> accounts)
      Adds new Accounts to Account table in MySql DB
      void addContainer​(com.github.ambry.account.Container container)
      Adds new Container to Container table in MySql DB
      void addContainers​(int accountId, java.util.Collection<com.github.ambry.account.Container> containers)
      Adds new Containers of a given Account to Container table in MySql DB
      java.util.Collection<com.github.ambry.account.Container> getContainersByAccount​(short accountId)
      Gets all Containers of a given account
      com.github.ambry.mysql.MySqlDataAccessor getMySqlDataAccessor()
      Used for tests.
      java.util.Collection<com.github.ambry.account.Account> getNewAccounts​(long updatedSince)
      Gets all Accounts that have been created or modified since the specified time.
      java.util.Collection<com.github.ambry.account.Container> getNewContainers​(long updatedSince)
      Gets all Containers that have been created or modified since the specified time.
      void updateAccount​(com.github.ambry.account.Account account)
      Updates existing Account in Account table in MySql DB
      void updateAccounts​(java.util.Collection<com.github.ambry.account.Account> accounts)
      Updates existing Accounts in Account table in MySql DB
      void updateContainer​(com.github.ambry.account.Container container)
      Updates existing Container in Container table in MySql DB
      void updateContainers​(int accountId, java.util.Collection<com.github.ambry.account.Container> containers)
      Updates existing Containers of a given Account in Container table in MySql DB
      • Methods inherited from class java.lang.Object

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

      • MySqlAccountStore

        public MySqlAccountStore​(java.util.List<com.github.ambry.mysql.MySqlUtils.DbEndpoint> dbEndpoints,
                                 java.lang.String localDatacenter,
                                 com.github.ambry.mysql.MySqlMetrics metrics,
                                 com.github.ambry.config.MySqlAccountServiceConfig config)
                          throws java.sql.SQLException
        Constructor.
        Parameters:
        dbEndpoints - MySql DB end points
        localDatacenter - name of the local data center
        metrics - metrics to track mysql operations
        config - configuration associated with MySqlAccountService
        Throws:
        java.sql.SQLException
    • Method Detail

      • getMySqlDataAccessor

        public com.github.ambry.mysql.MySqlDataAccessor getMySqlDataAccessor()
        Used for tests.
        Returns:
        MySqlDataAccessor
      • addAccounts

        public void addAccounts​(java.util.Collection<com.github.ambry.account.Account> accounts)
                         throws java.sql.SQLException
        Adds new Accounts to Account table in MySql DB
        Parameters:
        accounts - collection of Accounts to be inserted
        Throws:
        java.sql.SQLException
      • addAccount

        public void addAccount​(com.github.ambry.account.Account account)
                        throws java.sql.SQLException
        Adds new Account to Account table in MySql DB
        Parameters:
        account - Account to be inserted
        Throws:
        java.sql.SQLException
      • addContainers

        public void addContainers​(int accountId,
                                  java.util.Collection<com.github.ambry.account.Container> containers)
                           throws java.sql.SQLException
        Adds new Containers of a given Account to Container table in MySql DB
        Parameters:
        accountId - id of Account
        containers - collection of Containers to be inserted
        Throws:
        java.sql.SQLException
      • addContainer

        public void addContainer​(com.github.ambry.account.Container container)
                          throws java.sql.SQLException
        Adds new Container to Container table in MySql DB
        Parameters:
        container - Container to be inserted
        Throws:
        java.sql.SQLException
      • updateAccounts

        public void updateAccounts​(java.util.Collection<com.github.ambry.account.Account> accounts)
                            throws java.sql.SQLException
        Updates existing Accounts in Account table in MySql DB
        Parameters:
        accounts - collection of Accounts to be updated
        Throws:
        java.sql.SQLException
      • updateAccount

        public void updateAccount​(com.github.ambry.account.Account account)
                           throws java.sql.SQLException
        Updates existing Account in Account table in MySql DB
        Parameters:
        account - Account to be updated
        Throws:
        java.sql.SQLException
      • updateContainers

        public void updateContainers​(int accountId,
                                     java.util.Collection<com.github.ambry.account.Container> containers)
                              throws java.sql.SQLException
        Updates existing Containers of a given Account in Container table in MySql DB
        Parameters:
        accountId - id of Account
        containers - collection of Containers to be updated
        Throws:
        java.sql.SQLException
      • updateContainer

        public void updateContainer​(com.github.ambry.account.Container container)
                             throws java.sql.SQLException
        Updates existing Container in Container table in MySql DB
        Parameters:
        container - Container to be updated
        Throws:
        java.sql.SQLException
      • getNewAccounts

        public java.util.Collection<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 collection of Accounts
        Throws:
        java.sql.SQLException
      • getNewContainers

        public java.util.Collection<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 collection of Containers
        Throws:
        java.sql.SQLException
      • getContainersByAccount

        public java.util.Collection<com.github.ambry.account.Container> getContainersByAccount​(short accountId)
                                                                                        throws java.sql.SQLException
        Gets all Containers of a given account
        Parameters:
        accountId - ID of the account
        Returns:
        a collection of Containers
        Throws:
        java.sql.SQLException