Search in sources :

Example 1 with BrokerUsage

use of com.yahoo.pulsar.common.policies.data.loadbalancer.BrokerUsage in project pulsar by yahoo.

the class SimpleLoadManagerImplTest method testUsage.

@Test
public void testUsage() {
    Map<String, Object> metrics = Maps.newHashMap();
    metrics.put("brk_conn_cnt", new Long(1));
    metrics.put("brk_repl_conn_cnt", new Long(1));
    metrics.put("jvm_thread_cnt", new Long(1));
    BrokerUsage brokerUsage = BrokerUsage.populateFrom(metrics);
    assertEquals(brokerUsage.getConnectionCount(), 1);
    assertEquals(brokerUsage.getReplicationConnectionCount(), 1);
    JvmUsage jvmUage = JvmUsage.populateFrom(metrics);
    assertEquals(jvmUage.getThreadCount(), 1);
    SystemResourceUsage usage = new SystemResourceUsage();
    double usageLimit = 10.0;
    usage.setBandwidthIn(new ResourceUsage(usageLimit, usageLimit));
    assertEquals(usage.getBandwidthIn().usage, usageLimit);
    usage.reset();
    assertNotEquals(usage.getBandwidthIn().usage, usageLimit);
}
Also used : SystemResourceUsage(com.yahoo.pulsar.common.policies.data.loadbalancer.SystemResourceUsage) ResourceUsage(com.yahoo.pulsar.common.policies.data.loadbalancer.ResourceUsage) SystemResourceUsage(com.yahoo.pulsar.common.policies.data.loadbalancer.SystemResourceUsage) JvmUsage(com.yahoo.pulsar.common.policies.data.loadbalancer.JvmUsage) BrokerUsage(com.yahoo.pulsar.common.policies.data.loadbalancer.BrokerUsage) Test(org.testng.annotations.Test)

Aggregations

BrokerUsage (com.yahoo.pulsar.common.policies.data.loadbalancer.BrokerUsage)1 JvmUsage (com.yahoo.pulsar.common.policies.data.loadbalancer.JvmUsage)1 ResourceUsage (com.yahoo.pulsar.common.policies.data.loadbalancer.ResourceUsage)1 SystemResourceUsage (com.yahoo.pulsar.common.policies.data.loadbalancer.SystemResourceUsage)1 Test (org.testng.annotations.Test)1