Search in sources :

Example 1 with AmbryCUQuotaSource

use of com.github.ambry.quota.capacityunit.AmbryCUQuotaSource in project ambry by linkedin.

the class AmbryQuotaManagerUpdateNotificationTest method ambryQuotaManagerUpdateNotificationTest.

@Test
public void ambryQuotaManagerUpdateNotificationTest() throws Exception {
    VerifiableProperties verifiableProperties = new VerifiableProperties(new Properties());
    MetricRegistry metricRegistry = new MetricRegistry();
    QuotaConfig quotaConfig = new QuotaConfig(verifiableProperties);
    QuotaRecommendationMergePolicy quotaRecommendationMergePolicy = new SimpleQuotaRecommendationMergePolicy(quotaConfig);
    AccountServiceForConsumerTest accountService = new AccountServiceForConsumerTest(new AccountServiceConfig(verifiableProperties), new AccountServiceMetrics(metricRegistry), null);
    AmbryQuotaManager ambryQuotaManager = new AmbryQuotaManager(quotaConfig, quotaRecommendationMergePolicy, accountService, null, new QuotaMetrics(metricRegistry));
    AmbryCUQuotaSource quotaSource = (AmbryCUQuotaSource) getQuotaSourceMember(ambryQuotaManager);
    assertTrue("updated accounts should be empty", quotaSource.getAllQuota().isEmpty());
    Set<Short> accountIdSet = new HashSet<>();
    accountIdSet.add((short) 1);
    accountIdSet.add((short) 2);
    Map<Short, Account> idToRefAccountMap = new HashMap<>();
    AccountTestUtils.generateRefAccounts(idToRefAccountMap, new HashMap<>(), accountIdSet, 2, 3);
    accountService.notifyAccountUpdateConsumers(idToRefAccountMap.values());
    assertEquals("Invalid size of updated accounts", quotaSource.getAllQuota().size(), 2);
}
Also used : Account(com.github.ambry.account.Account) VerifiableProperties(com.github.ambry.config.VerifiableProperties) HashMap(java.util.HashMap) MetricRegistry(com.codahale.metrics.MetricRegistry) AccountServiceConfig(com.github.ambry.config.AccountServiceConfig) Properties(java.util.Properties) VerifiableProperties(com.github.ambry.config.VerifiableProperties) AccountServiceMetrics(com.github.ambry.account.AccountServiceMetrics) QuotaConfig(com.github.ambry.config.QuotaConfig) AmbryCUQuotaSource(com.github.ambry.quota.capacityunit.AmbryCUQuotaSource) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)1 Account (com.github.ambry.account.Account)1 AccountServiceMetrics (com.github.ambry.account.AccountServiceMetrics)1 AccountServiceConfig (com.github.ambry.config.AccountServiceConfig)1 QuotaConfig (com.github.ambry.config.QuotaConfig)1 VerifiableProperties (com.github.ambry.config.VerifiableProperties)1 AmbryCUQuotaSource (com.github.ambry.quota.capacityunit.AmbryCUQuotaSource)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Properties (java.util.Properties)1 Test (org.junit.Test)1