@Test public void testInitCacheOnStartUp() throws SQLException, IOException { Container testContainer = new ContainerBuilder((short) 1, "testContainer", Container.ContainerStatus.ACTIVE, "testContainer", (short) 1).build(); Account testAccount = new AccountBuilder((short) 1, "testAccount", Account.AccountStatus.ACTIVE).containers( Collections.singleton(testContainer)).build(); MySqlAccountStore mockMySqlAccountStore = mock(MySqlAccountStore.class); when(mockMySqlAccountStore.getNewAccounts(0)).thenReturn(new ArrayList<>(Collections.singletonList(testAccount))); mySqlAccountService = new MySqlAccountService(new AccountServiceMetrics(new MetricRegistry()), new MySqlAccountServiceConfig(new VerifiableProperties(mySqlConfigProps)), mockMySqlAccountStore); List<Account> accounts = new ArrayList<>(mySqlAccountService.getAllAccounts()); assertEquals("Mismatch in number of accounts", 1, accounts.size()); assertEquals("Mismatch in account information", testAccount, accounts.get(0)); }
@Override public Collection<Account> getAllAccounts() { infoMapLock.readLock().lock(); try { return accountInfoMapRef.get().getAccounts(); } finally { infoMapLock.readLock().unlock(); } }
MySqlAccountService extends AbstractAccountService { @Override public Collection<Account> getAllAccounts() { infoMapLock.readLock().lock(); try { return accountInfoMapRef.get().getAccounts(); } finally { infoMapLock.readLock().unlock(); } } }
MySqlAccountService extends AbstractAccountService { @Override public Collection<Account> getAllAccounts() { infoMapLock.readLock().lock(); try { return accountInfoMapRef.get().getAccounts(); } finally { infoMapLock.readLock().unlock(); } } MySqlAccountService(AccountServiceMetrics accountServiceMetrics, MySqlAccountServiceConfig config,
      MySqlAccountStore mySqlAccountStore); }
MySqlAccountService extends AbstractAccountService { @Override public Collection<Account> getAllAccounts() { infoMapLock.readLock().lock(); try { return accountInfoMapRef.get().getAccounts(); } finally { infoMapLock.readLock().unlock(); } } MySqlAccountService(AccountServiceMetrics accountServiceMetrics, MySqlAccountServiceConfig config,
      MySqlAccountStore mySqlAccountStore); @Override Account getAccountById(short accountId); @Override Account getAccountByName(String accountName); @Override boolean updateAccounts(Collection<Account> accounts); @Override Collection<Account> getAllAccounts(); @Override boolean addAccountUpdateConsumer(Consumer<Collection<Account>> accountUpdateConsumer); @Override boolean removeAccountUpdateConsumer(Consumer<Collection<Account>> accountUpdateConsumer); @Override void selectInactiveContainersAndMarkInZK(StatsSnapshot statsSnapshot); @Override void close(); }
MySqlAccountService extends AbstractAccountService { @Override public Collection<Account> getAllAccounts() { infoMapLock.readLock().lock(); try { return accountInfoMapRef.get().getAccounts(); } finally { infoMapLock.readLock().unlock(); } } MySqlAccountService(AccountServiceMetrics accountServiceMetrics, MySqlAccountServiceConfig config,
      MySqlAccountStore mySqlAccountStore); @Override Account getAccountById(short accountId); @Override Account getAccountByName(String accountName); @Override boolean updateAccounts(Collection<Account> accounts); @Override Collection<Account> getAllAccounts(); @Override boolean addAccountUpdateConsumer(Consumer<Collection<Account>> accountUpdateConsumer); @Override boolean removeAccountUpdateConsumer(Consumer<Collection<Account>> accountUpdateConsumer); @Override void selectInactiveContainersAndMarkInZK(StatsSnapshot statsSnapshot); @Override void close();  }