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);
}
Aggregations