Search in sources :

Example 1 with ResourceQuotaCache

use of com.yahoo.pulsar.broker.cache.ResourceQuotaCache in project pulsar by yahoo.

the class ResourceQuotaCacheTest method testGetSetBundleQuota.

@Test
public void testGetSetBundleQuota() throws Exception {
    ResourceQuotaCache cache = new ResourceQuotaCache(zkCache);
    NamespaceBundle testBundle = bundleFactory.getFullBundle(new NamespaceName("pulsar/test/ns-2"));
    ResourceQuota quota1 = ResourceQuotaCache.getInitialQuotaValue();
    ResourceQuota quota2 = new ResourceQuota();
    quota2.setMsgRateIn(10);
    quota2.setMsgRateOut(20);
    quota2.setBandwidthIn(10000);
    quota2.setBandwidthOut(20000);
    quota2.setMemory(100);
    quota2.setDynamic(false);
    assertEquals(cache.getQuota(testBundle), quota1);
    cache.setQuota(testBundle, quota2);
    assertEquals(cache.getQuota(testBundle), quota2);
    cache.unsetQuota(testBundle);
    assertEquals(cache.getQuota(testBundle), quota1);
}
Also used : ResourceQuotaCache(com.yahoo.pulsar.broker.cache.ResourceQuotaCache) NamespaceBundle(com.yahoo.pulsar.common.naming.NamespaceBundle) NamespaceName(com.yahoo.pulsar.common.naming.NamespaceName) ResourceQuota(com.yahoo.pulsar.common.policies.data.ResourceQuota) Test(org.testng.annotations.Test)

Example 2 with ResourceQuotaCache

use of com.yahoo.pulsar.broker.cache.ResourceQuotaCache in project pulsar by yahoo.

the class ResourceQuotaCacheTest method testGetSetDefaultQuota.

@Test
public void testGetSetDefaultQuota() throws Exception {
    ResourceQuotaCache cache = new ResourceQuotaCache(zkCache);
    ResourceQuota quota1 = ResourceQuotaCache.getInitialQuotaValue();
    ResourceQuota quota2 = new ResourceQuota();
    quota2.setMsgRateIn(10);
    quota2.setMsgRateOut(20);
    quota2.setBandwidthIn(10000);
    quota2.setBandwidthOut(20000);
    quota2.setMemory(100);
    quota2.setDynamic(false);
    assertEquals(cache.getDefaultQuota(), quota1);
    cache.setDefaultQuota(quota2);
    assertEquals(cache.getDefaultQuota(), quota2);
}
Also used : ResourceQuotaCache(com.yahoo.pulsar.broker.cache.ResourceQuotaCache) ResourceQuota(com.yahoo.pulsar.common.policies.data.ResourceQuota) Test(org.testng.annotations.Test)

Aggregations

ResourceQuotaCache (com.yahoo.pulsar.broker.cache.ResourceQuotaCache)2 ResourceQuota (com.yahoo.pulsar.common.policies.data.ResourceQuota)2 Test (org.testng.annotations.Test)2 NamespaceBundle (com.yahoo.pulsar.common.naming.NamespaceBundle)1 NamespaceName (com.yahoo.pulsar.common.naming.NamespaceName)1