Search in sources :

Example 1 with JvmUsage

use of org.apache.pulsar.policies.data.loadbalancer.JvmUsage in project incubator-pulsar by apache.

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(org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage) ResourceUsage(org.apache.pulsar.policies.data.loadbalancer.ResourceUsage) SystemResourceUsage(org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage) JvmUsage(org.apache.pulsar.policies.data.loadbalancer.JvmUsage) BrokerUsage(org.apache.pulsar.policies.data.loadbalancer.BrokerUsage) Test(org.testng.annotations.Test)

Aggregations

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