Package com.github.ambry.account.mysql
Class MySqlAccountStore
- java.lang.Object
-
- com.github.ambry.account.mysql.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)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAccount(com.github.ambry.account.Account account)
Adds newAccount
to Account table in MySql DBvoid
addAccounts(java.util.Collection<com.github.ambry.account.Account> accounts)
Adds newAccount
s to Account table in MySql DBvoid
addContainer(com.github.ambry.account.Container container)
Adds newContainer
to Container table in MySql DBvoid
addContainers(java.util.Collection<com.github.ambry.account.Container> containers)
Adds newContainer
s to Container table in MySql DBjava.util.Collection<com.github.ambry.account.Container>
getContainersByAccount(short accountId)
Gets allContainer
s of a given accountcom.github.ambry.mysql.MySqlDataAccessor
getMySqlDataAccessor()
Used for tests.java.util.Collection<com.github.ambry.account.Account>
getNewAccounts(long updatedSince)
Gets allAccount
s that have been created or modified since the specified time.java.util.Collection<com.github.ambry.account.Container>
getNewContainers(long updatedSince)
Gets allContainer
s that have been created or modified since the specified time.void
updateAccount(com.github.ambry.account.Account account)
Updates existingAccount
in Account table in MySql DBvoid
updateAccounts(java.util.Collection<com.github.ambry.account.Account> accounts)
Updates existingAccount
s in Account table in MySql DBvoid
updateContainer(com.github.ambry.account.Container container)
Updates existingContainer
in Container table in MySql DBvoid
updateContainers(java.util.Collection<com.github.ambry.account.Container> containers)
Updates existingContainer
s in Container table in MySql DB
-
-
-
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) throws java.sql.SQLException
Constructor.- Parameters:
dbEndpoints
- MySql DB end pointsmetrics
- metrics to track mysql operations- 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 newAccount
s to Account table in MySql DB- Parameters:
accounts
- collection ofAccount
s to be inserted- Throws:
java.sql.SQLException
-
addAccount
public void addAccount(com.github.ambry.account.Account account) throws java.sql.SQLException
Adds newAccount
to Account table in MySql DB- Parameters:
account
-Account
to be inserted- Throws:
java.sql.SQLException
-
addContainers
public void addContainers(java.util.Collection<com.github.ambry.account.Container> containers) throws java.sql.SQLException
Adds newContainer
s to Container table in MySql DB- Parameters:
containers
- collection ofContainer
s to be inserted- Throws:
java.sql.SQLException
-
addContainer
public void addContainer(com.github.ambry.account.Container container) throws java.sql.SQLException
Adds newContainer
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 existingAccount
s in Account table in MySql DB- Parameters:
accounts
- collection ofAccount
s to be updated- Throws:
java.sql.SQLException
-
updateAccount
public void updateAccount(com.github.ambry.account.Account account) throws java.sql.SQLException
Updates existingAccount
in Account table in MySql DB- Parameters:
account
-Account
to be updated- Throws:
java.sql.SQLException
-
updateContainers
public void updateContainers(java.util.Collection<com.github.ambry.account.Container> containers) throws java.sql.SQLException
Updates existingContainer
s in Container table in MySql DB- Parameters:
containers
- collection ofContainer
s to be updated- Throws:
java.sql.SQLException
-
updateContainer
public void updateContainer(com.github.ambry.account.Container container) throws java.sql.SQLException
Updates existingContainer
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 allAccount
s that have been created or modified since the specified time.- Parameters:
updatedSince
- the last modified time used to filter.- Returns:
- a collection of
Account
s - Throws:
java.sql.SQLException
-
getNewContainers
public java.util.Collection<com.github.ambry.account.Container> getNewContainers(long updatedSince) throws java.sql.SQLException
Gets allContainer
s that have been created or modified since the specified time.- Parameters:
updatedSince
- the last modified time used to filter.- Returns:
- a collection of
Container
s - Throws:
java.sql.SQLException
-
getContainersByAccount
public java.util.Collection<com.github.ambry.account.Container> getContainersByAccount(short accountId) throws java.sql.SQLException
Gets allContainer
s of a given account- Parameters:
accountId
- ID of the account- Returns:
- a collection of
Container
s - Throws:
java.sql.SQLException
-
-