Search in sources :

Example 1 with SimpleLoadCalculatorImpl

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));
}
Also used : PulsarResourceDescription(org.apache.pulsar.broker.loadbalance.impl.PulsarResourceDescription) SystemResourceUsage(org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage) ResourceUsage(org.apache.pulsar.policies.data.loadbalancer.ResourceUsage) SimpleLoadCalculatorImpl(org.apache.pulsar.broker.loadbalance.impl.SimpleLoadCalculatorImpl) Test(org.testng.annotations.Test)

Aggregations

PulsarResourceDescription (org.apache.pulsar.broker.loadbalance.impl.PulsarResourceDescription)1 SimpleLoadCalculatorImpl (org.apache.pulsar.broker.loadbalance.impl.SimpleLoadCalculatorImpl)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