Search in sources :

Example 1 with BrokerVersionFilter

use of org.apache.pulsar.broker.loadbalance.impl.BrokerVersionFilter in project incubator-pulsar by apache.

the class BrokerVersionFilterTest method testLatestVersion.

@Test
public void testLatestVersion() {
    LoadData loadData = initLoadData();
    Set<String> brokers = new TreeSet<>();
    brokers.add("broker1");
    brokers.add("broker2");
    brokers.add("broker3");
    BrokerVersionFilter filter = new BrokerVersionFilter();
    try {
        Version latestVersion = filter.getLatestVersionNumber(brokers, loadData);
        Assert.assertEquals(latestVersion.getMajorVersion(), 1);
        Assert.assertEquals(latestVersion.getMinorVersion(), 2);
        Assert.assertEquals(latestVersion.getPatchVersion(), 0);
    } catch (BrokerFilterBadVersionException bad) {
        Assert.fail(bad.getMessage(), bad);
    }
    ServiceConfiguration configuration = new ServiceConfiguration();
    configuration.setPreferLaterVersions(true);
    try {
        filter.filter(brokers, null, loadData, configuration);
        // Only one broker is running the latest version
        Assert.assertEquals(brokers.size(), 1);
    } catch (BrokerFilterBadVersionException bad) {
        Assert.fail(bad.getMessage(), bad);
    }
}
Also used : BrokerFilterBadVersionException(org.apache.pulsar.broker.loadbalance.BrokerFilterBadVersionException) BrokerVersionFilter(org.apache.pulsar.broker.loadbalance.impl.BrokerVersionFilter) LoadData(org.apache.pulsar.broker.loadbalance.LoadData) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) Version(com.github.zafarkhaja.semver.Version) TreeSet(java.util.TreeSet) Test(org.testng.annotations.Test)

Aggregations

Version (com.github.zafarkhaja.semver.Version)1 TreeSet (java.util.TreeSet)1 ServiceConfiguration (org.apache.pulsar.broker.ServiceConfiguration)1 BrokerFilterBadVersionException (org.apache.pulsar.broker.loadbalance.BrokerFilterBadVersionException)1 LoadData (org.apache.pulsar.broker.loadbalance.LoadData)1 BrokerVersionFilter (org.apache.pulsar.broker.loadbalance.impl.BrokerVersionFilter)1 Test (org.testng.annotations.Test)1