Class CompositeAccountService

  • All Implemented Interfaces:
    com.github.ambry.account.AccountService, java.io.Closeable, java.lang.AutoCloseable

    public class CompositeAccountService
    extends java.lang.Object
    implements com.github.ambry.account.AccountService
    An implementation of AccountService that combines two sources. The "primary" acts as the source of truth for users of this class, but results obtained are compared against the "secondary" source. This class can be useful for safe migrations between account service implementations using different backing stores.
    • Constructor Summary

      Constructors 
      Constructor Description
      CompositeAccountService​(com.github.ambry.account.AccountService primaryAccountService, com.github.ambry.account.AccountService secondaryAccountService, AccountServiceMetrics metrics, com.github.ambry.config.CompositeAccountServiceConfig config)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean addAccountUpdateConsumer​(java.util.function.Consumer<java.util.Collection<com.github.ambry.account.Account>> accountUpdateConsumer)  
      void close()  
      com.github.ambry.account.Account getAccountById​(short accountId)  
      com.github.ambry.account.Account getAccountByName​(java.lang.String accountName)  
      int getAccountsMismatchCount()  
      java.util.Collection<com.github.ambry.account.Account> getAllAccounts()  
      com.github.ambry.account.Container getContainer​(java.lang.String accountName, java.lang.String containerName)  
      java.util.Set<com.github.ambry.account.Container> getContainersByStatus​(com.github.ambry.account.Container.ContainerStatus containerStatus)  
      boolean removeAccountUpdateConsumer​(java.util.function.Consumer<java.util.Collection<com.github.ambry.account.Account>> accountUpdateConsumer)  
      void selectInactiveContainersAndMarkInStore​(com.github.ambry.server.StatsSnapshot statsSnapshot)  
      void updateAccounts​(java.util.Collection<com.github.ambry.account.Account> accounts)  
      java.util.Collection<com.github.ambry.account.Container> updateContainers​(java.lang.String accountName, java.util.Collection<com.github.ambry.account.Container> containers)  
      • Methods inherited from class java.lang.Object

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

      • CompositeAccountService

        public CompositeAccountService​(com.github.ambry.account.AccountService primaryAccountService,
                                       com.github.ambry.account.AccountService secondaryAccountService,
                                       AccountServiceMetrics metrics,
                                       com.github.ambry.config.CompositeAccountServiceConfig config)
    • Method Detail

      • getAccountById

        public com.github.ambry.account.Account getAccountById​(short accountId)
        Specified by:
        getAccountById in interface com.github.ambry.account.AccountService
      • getAccountByName

        public com.github.ambry.account.Account getAccountByName​(java.lang.String accountName)
        Specified by:
        getAccountByName in interface com.github.ambry.account.AccountService
      • updateAccounts

        public void updateAccounts​(java.util.Collection<com.github.ambry.account.Account> accounts)
                            throws com.github.ambry.account.AccountServiceException
        Specified by:
        updateAccounts in interface com.github.ambry.account.AccountService
        Throws:
        com.github.ambry.account.AccountServiceException
      • getAllAccounts

        public java.util.Collection<com.github.ambry.account.Account> getAllAccounts()
        Specified by:
        getAllAccounts in interface com.github.ambry.account.AccountService
      • addAccountUpdateConsumer

        public boolean addAccountUpdateConsumer​(java.util.function.Consumer<java.util.Collection<com.github.ambry.account.Account>> accountUpdateConsumer)
        Specified by:
        addAccountUpdateConsumer in interface com.github.ambry.account.AccountService
      • removeAccountUpdateConsumer

        public boolean removeAccountUpdateConsumer​(java.util.function.Consumer<java.util.Collection<com.github.ambry.account.Account>> accountUpdateConsumer)
        Specified by:
        removeAccountUpdateConsumer in interface com.github.ambry.account.AccountService
      • updateContainers

        public java.util.Collection<com.github.ambry.account.Container> updateContainers​(java.lang.String accountName,
                                                                                         java.util.Collection<com.github.ambry.account.Container> containers)
                                                                                  throws com.github.ambry.account.AccountServiceException
        Specified by:
        updateContainers in interface com.github.ambry.account.AccountService
        Throws:
        com.github.ambry.account.AccountServiceException
      • getContainer

        public com.github.ambry.account.Container getContainer​(java.lang.String accountName,
                                                               java.lang.String containerName)
                                                        throws com.github.ambry.account.AccountServiceException
        Specified by:
        getContainer in interface com.github.ambry.account.AccountService
        Throws:
        com.github.ambry.account.AccountServiceException
      • getContainersByStatus

        public java.util.Set<com.github.ambry.account.Container> getContainersByStatus​(com.github.ambry.account.Container.ContainerStatus containerStatus)
        Specified by:
        getContainersByStatus in interface com.github.ambry.account.AccountService
      • selectInactiveContainersAndMarkInStore

        public void selectInactiveContainersAndMarkInStore​(com.github.ambry.server.StatsSnapshot statsSnapshot)
        Specified by:
        selectInactiveContainersAndMarkInStore in interface com.github.ambry.account.AccountService
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • getAccountsMismatchCount

        public int getAccountsMismatchCount()
        Returns:
        number of mismatch accounts and containers between primary and secondary sources.