use of org.apache.pulsar.broker.loadbalance.impl.SimpleLoadCalculatorImpl in project incubator-pulsar by apache.
the class SimpleLoadManagerImplTest method testResourceDescription.
@Test
public void testResourceDescription() {
PulsarResourceDescription rd = new PulsarResourceDescription();
rd.put("memory", new ResourceUsage(1024, 4096));
rd.put("cpu", new ResourceUsage(10, 100));
rd.put("bandwidthIn", new ResourceUsage(250 * 1024, 1024 * 1024));
rd.put("bandwidthOut", new ResourceUsage(550 * 1024, 1024 * 1024));
PulsarResourceDescription rd1 = new PulsarResourceDescription();
rd1.put("memory", new ResourceUsage(2048, 4096));
rd1.put("cpu", new ResourceUsage(50, 100));
rd1.put("bandwidthIn", new ResourceUsage(550 * 1024, 1024 * 1024));
rd1.put("bandwidthOut", new ResourceUsage(850 * 1024, 1024 * 1024));
assertTrue(rd.compareTo(rd1) == 1);
assertTrue(rd1.calculateRank() > rd.calculateRank());
SimpleLoadCalculatorImpl calc = new SimpleLoadCalculatorImpl();
calc.recaliberateResourceUsagePerServiceUnit(null);
assertNull(calc.getResourceDescription(null));
}
Aggregations