Package com.github.ambry.account.mysql
Class AccountDao
- java.lang.Object
-
- com.github.ambry.account.mysql.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.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ACCOUNT_ID
static java.lang.String
ACCOUNT_INFO
static java.lang.String
ACCOUNT_TABLE
static java.lang.String
CONTAINER_ID
static java.lang.String
CONTAINER_INFO
static java.lang.String
CONTAINER_NAME
static java.lang.String
CONTAINER_TABLE
static java.lang.String
CREATION_TIME
static java.lang.String
LAST_MODIFIED_TIME
static java.lang.String
VERSION
-
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.
-
-
-
Field Detail
-
ACCOUNT_TABLE
public static final java.lang.String ACCOUNT_TABLE
- See Also:
- Constant Field Values
-
ACCOUNT_INFO
public static final java.lang.String ACCOUNT_INFO
- See Also:
- Constant Field Values
-
ACCOUNT_ID
public static final java.lang.String ACCOUNT_ID
- See Also:
- Constant Field Values
-
CONTAINER_TABLE
public static final java.lang.String CONTAINER_TABLE
- See Also:
- Constant Field Values
-
CONTAINER_ID
public static final java.lang.String CONTAINER_ID
- See Also:
- Constant Field Values
-
CONTAINER_NAME
public static final java.lang.String CONTAINER_NAME
- See Also:
- Constant Field Values
-
CONTAINER_INFO
public static final java.lang.String CONTAINER_INFO
- See Also:
- Constant Field Values
-
VERSION
public static final java.lang.String VERSION
- See Also:
- Constant Field Values
-
CREATION_TIME
public static final java.lang.String CREATION_TIME
- See Also:
- Constant Field Values
-
LAST_MODIFIED_TIME
public static final java.lang.String LAST_MODIFIED_TIME
- See Also:
- Constant Field Values
-
-
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
Account
s. - 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
Container
s. - 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
Container
s. - 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 ornull
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 ornull
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 AccountsbatchSize
- number of statements to be executed in one batch- Throws:
java.sql.SQLException
-
-