use of org.apache.pulsar.common.policies.data.OldPolicies in project incubator-pulsar by apache.
the class NamespaceIsolationPolicyImplTest method testConstructor.
@Test
public void testConstructor() throws Exception {
NamespaceIsolationPolicyImpl defaultPolicy = this.getDefaultPolicy();
NamespaceIsolationData policyData = new NamespaceIsolationData();
policyData.namespaces = new ArrayList<String>();
policyData.namespaces.add("pulsar/use/test.*");
policyData.primary = new ArrayList<String>();
policyData.primary.add("prod1-broker[1-3].messaging.use.example.com");
policyData.secondary = new ArrayList<String>();
policyData.secondary.add("prod1-broker.*.use.example.com");
policyData.auto_failover_policy = new AutoFailoverPolicyData();
policyData.auto_failover_policy.policy_type = AutoFailoverPolicyType.min_available;
policyData.auto_failover_policy.parameters = new HashMap<String, String>();
policyData.auto_failover_policy.parameters.put("min_limit", "3");
policyData.auto_failover_policy.parameters.put("usage_threshold", "90");
NamespaceIsolationPolicyImpl newPolicy = new NamespaceIsolationPolicyImpl(policyData);
assertTrue(defaultPolicy.equals(newPolicy));
policyData.auto_failover_policy.parameters.put("usage_threshold", "80");
newPolicy = new NamespaceIsolationPolicyImpl(policyData);
assertTrue(!defaultPolicy.equals(newPolicy));
assertTrue(!newPolicy.equals(new OldPolicies()));
}
use of org.apache.pulsar.common.policies.data.OldPolicies in project incubator-pulsar by apache.
the class MinAvailablePolicyTest method testMinAvailablePolicty.
@Test
public void testMinAvailablePolicty() {
MinAvailablePolicy m = new MinAvailablePolicy(3, 10);
Assert.assertFalse(m.equals(new OldPolicies()));
Assert.assertFalse(m.shouldFailoverToSecondary(15));
Assert.assertTrue(m.shouldFailoverToSecondary(2));
}
Aggregations