Search in sources :

Example 1 with BrokerAssignment

use of com.yahoo.pulsar.common.policies.data.BrokerAssignment in project pulsar by yahoo.

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.isPrimaryBrokerAvailable(brkStatus)) {
            primaryCandidates.add(brkStatus);
        }
    } else if (brokerAssignment == BrokerAssignment.secondary) {
        secondaryCandidates.add(brkStatus);
    } else if (brokerAssignment == BrokerAssignment.shared) {
        sharedCandidates.add(brkStatus);
    }
}
Also used : NamespaceIsolationPolicy(com.yahoo.pulsar.common.policies.NamespaceIsolationPolicy) BrokerAssignment(com.yahoo.pulsar.common.policies.data.BrokerAssignment)

Aggregations

NamespaceIsolationPolicy (com.yahoo.pulsar.common.policies.NamespaceIsolationPolicy)1 BrokerAssignment (com.yahoo.pulsar.common.policies.data.BrokerAssignment)1