Search in sources :

Example 1 with BrokerAssignment

use of org.apache.pulsar.common.policies.data.BrokerAssignment in project incubator-pulsar by apache.

the class NamespaceIsolationPolicies method assignBroker.

public void assignBroker(NamespaceName nsname, BrokerStatus brkStatus, SortedSet<BrokerStatus> primaryCandidates, SortedSet<BrokerStatus> secondaryCandidates, SortedSet<BrokerStatus> sharedCandidates) {
    NamespaceIsolationPolicy nsPolicy = this.getPolicyByNamespace(nsname);
    BrokerAssignment brokerAssignment = this.getBrokerAssignment(nsPolicy, brkStatus.getBrokerAddress());
    if (brokerAssignment == BrokerAssignment.primary) {
        // Only add to candidates if allowed by policy
        if (nsPolicy != null && nsPolicy.isPrimaryBrokerAvailable(brkStatus)) {
            primaryCandidates.add(brkStatus);
        }
    } else if (brokerAssignment == BrokerAssignment.secondary) {
        secondaryCandidates.add(brkStatus);
    } else if (brokerAssignment == BrokerAssignment.shared) {
        sharedCandidates.add(brkStatus);
    }
}
Also used : NamespaceIsolationPolicy(org.apache.pulsar.common.policies.NamespaceIsolationPolicy) BrokerAssignment(org.apache.pulsar.common.policies.data.BrokerAssignment)

Aggregations

NamespaceIsolationPolicy (org.apache.pulsar.common.policies.NamespaceIsolationPolicy)1 BrokerAssignment (org.apache.pulsar.common.policies.data.BrokerAssignment)1