Class NamespaceIsolationPolicyImpl
- java.lang.Object
-
- org.apache.pulsar.common.policies.impl.NamespaceIsolationPolicyImpl
-
- All Implemented Interfaces:
NamespaceIsolationPolicy
public class NamespaceIsolationPolicyImpl extends java.lang.Object implements NamespaceIsolationPolicy
Implementation of the namespace isolation policy.
-
-
Constructor Summary
Constructors Constructor Description NamespaceIsolationPolicyImpl(org.apache.pulsar.common.policies.data.NamespaceIsolationData policyData)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.util.List<java.net.URL>findPrimaryBrokers(java.util.List<java.net.URL> availableBrokers, NamespaceName namespace)Get the list of primary brokers for the namespace according to the policy.java.util.List<java.net.URL>findSecondaryBrokers(java.util.List<java.net.URL> availableBrokers, NamespaceName namespace)Get the list of secondary brokers for the namespace according to the policy.java.util.SortedSet<org.apache.pulsar.common.policies.data.BrokerStatus>getAvailablePrimaryBrokers(java.util.SortedSet<org.apache.pulsar.common.policies.data.BrokerStatus> primaryCandidates)According to the namespace isolation policy, find the allowed available primary brokers.java.util.List<java.lang.String>getPrimaryBrokers()Get the list of regex for the set of primary brokers.java.util.List<java.lang.String>getSecondaryBrokers()Get the list of regex for the set of secondary brokers.inthashCode()booleanisPrimaryBroker(java.lang.String broker)Check to see whether the specific host is a primary broker.booleanisPrimaryBrokerAvailable(org.apache.pulsar.common.policies.data.BrokerStatus brkStatus)booleanisSecondaryBroker(java.lang.String broker)Check to see whether the specific host is a secondary broker.booleanshouldFailover(int totalPrimaryResourceUnits)Check to see whether the primary brokers can still handle a new namespace or has to failover.booleanshouldFailover(java.util.SortedSet<org.apache.pulsar.common.policies.data.BrokerStatus> brokerStatus)Check to see whether the primary brokers can still handle a new namespace or has to failover.booleanshouldFallback(java.util.SortedSet<org.apache.pulsar.common.policies.data.BrokerStatus> primaryBrokers)Check to see whether the namespace ownership should fallback to the primary brokers.java.lang.StringtoString()
-
-
-
Method Detail
-
getPrimaryBrokers
public java.util.List<java.lang.String> getPrimaryBrokers()
Description copied from interface:NamespaceIsolationPolicyGet the list of regex for the set of primary brokers.- Specified by:
getPrimaryBrokersin interfaceNamespaceIsolationPolicy- Returns:
-
getSecondaryBrokers
public java.util.List<java.lang.String> getSecondaryBrokers()
Description copied from interface:NamespaceIsolationPolicyGet the list of regex for the set of secondary brokers.- Specified by:
getSecondaryBrokersin interfaceNamespaceIsolationPolicy- Returns:
-
findPrimaryBrokers
public java.util.List<java.net.URL> findPrimaryBrokers(java.util.List<java.net.URL> availableBrokers, NamespaceName namespace)Description copied from interface:NamespaceIsolationPolicyGet the list of primary brokers for the namespace according to the policy.- Specified by:
findPrimaryBrokersin interfaceNamespaceIsolationPolicy- Parameters:
availableBrokers- brokers identified by service URL.namespace- the namespace- Returns:
- a list brokers by service URL.
-
findSecondaryBrokers
public java.util.List<java.net.URL> findSecondaryBrokers(java.util.List<java.net.URL> availableBrokers, NamespaceName namespace)Description copied from interface:NamespaceIsolationPolicyGet the list of secondary brokers for the namespace according to the policy.- Specified by:
findSecondaryBrokersin interfaceNamespaceIsolationPolicy- Parameters:
availableBrokers- brokers identified by service URL.namespace- the namespace- Returns:
- a list brokers by service URL.
-
shouldFallback
public boolean shouldFallback(java.util.SortedSet<org.apache.pulsar.common.policies.data.BrokerStatus> primaryBrokers)
Description copied from interface:NamespaceIsolationPolicyCheck to see whether the namespace ownership should fallback to the primary brokers.- Specified by:
shouldFallbackin interfaceNamespaceIsolationPolicy- Returns:
-
isPrimaryBroker
public boolean isPrimaryBroker(java.lang.String broker)
Description copied from interface:NamespaceIsolationPolicyCheck to see whether the specific host is a primary broker.- Specified by:
isPrimaryBrokerin interfaceNamespaceIsolationPolicy- Returns:
-
isSecondaryBroker
public boolean isSecondaryBroker(java.lang.String broker)
Description copied from interface:NamespaceIsolationPolicyCheck to see whether the specific host is a secondary broker.- Specified by:
isSecondaryBrokerin interfaceNamespaceIsolationPolicy- Returns:
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
getAvailablePrimaryBrokers
public java.util.SortedSet<org.apache.pulsar.common.policies.data.BrokerStatus> getAvailablePrimaryBrokers(java.util.SortedSet<org.apache.pulsar.common.policies.data.BrokerStatus> primaryCandidates)
Description copied from interface:NamespaceIsolationPolicyAccording to the namespace isolation policy, find the allowed available primary brokers.- Specified by:
getAvailablePrimaryBrokersin interfaceNamespaceIsolationPolicy- Returns:
-
shouldFailover
public boolean shouldFailover(java.util.SortedSet<org.apache.pulsar.common.policies.data.BrokerStatus> brokerStatus)
Description copied from interface:NamespaceIsolationPolicyCheck to see whether the primary brokers can still handle a new namespace or has to failover.- Specified by:
shouldFailoverin interfaceNamespaceIsolationPolicy- Returns:
-
shouldFailover
public boolean shouldFailover(int totalPrimaryResourceUnits)
Description copied from interface:NamespaceIsolationPolicyCheck to see whether the primary brokers can still handle a new namespace or has to failover.- Specified by:
shouldFailoverin interfaceNamespaceIsolationPolicy- Returns:
-
isPrimaryBrokerAvailable
public boolean isPrimaryBrokerAvailable(org.apache.pulsar.common.policies.data.BrokerStatus brkStatus)
- Specified by:
isPrimaryBrokerAvailablein interfaceNamespaceIsolationPolicy
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-