Class ResourceUnitRanking
- java.lang.Object
-
- org.apache.pulsar.policies.data.loadbalancer.ResourceUnitRanking
-
- All Implemented Interfaces:
java.lang.Comparable<ResourceUnitRanking>
public class ResourceUnitRanking extends java.lang.Object implements java.lang.Comparable<ResourceUnitRanking>
The class containing information about system resources, allocated quota, and loaded bundles.
-
-
Constructor Summary
Constructors Constructor Description ResourceUnitRanking(SystemResourceUsage systemResourceUsage, java.util.Set<java.lang.String> loadedBundles, org.apache.pulsar.common.policies.data.ResourceQuota allocatedQuota, java.util.Set<java.lang.String> preAllocatedBundles, org.apache.pulsar.common.policies.data.ResourceQuota preAllocatedQuota)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPreAllocatedServiceUnit(java.lang.String suName, org.apache.pulsar.common.policies.data.ResourceQuota quota)Pre-allocate a ServiceUnit to this ResourceUnit.static longcalculateBrokerMaxCapacity(SystemResourceUsage systemResourceUsage, org.apache.pulsar.common.policies.data.ResourceQuota defaultQuota)Estimate the maximum number namespace bundles a ResourceUnit is able to handle with all resource.intcompareMessageRateTo(ResourceUnitRanking other)Compare two loads based on message rate only.intcompareTo(ResourceUnitRanking other)longestimateMaxCapacity(org.apache.pulsar.common.policies.data.ResourceQuota defaultQuota)Estimate the maximum number of namespace bundles ths ResourceUnit is able to handle with all resource.doublegetAllocatedLoadPercentageBandwidthIn()Percentage of inbound bandwidth allocated to bundle's quota.doublegetAllocatedLoadPercentageBandwidthOut()Percentage of outbound bandwidth allocated to bundle's quota.doublegetAllocatedLoadPercentageCPU()Percentage of CPU allocated to bundle's quota.doublegetAllocatedLoadPercentageMemory()Percetage of memory allocated to bundle's quota.doublegetEstimatedLoadPercentage()Get the estimated load percentage.java.lang.StringgetEstimatedLoadPercentageString()Get the load percentage in String, with detail resource usages.doublegetEstimatedMessageRate()Get the estimated message rate.java.util.Set<java.lang.String>getLoadedBundles()Get the loaded bundles.java.util.Set<java.lang.String>getPreAllocatedBundles()Get the pre-allocated bundles.booleanisIdle()If the ResourceUnit is idle.booleanisServiceUnitLoaded(java.lang.String suName)Check if a ServiceUnit is already loaded by this ResourceUnit.booleanisServiceUnitPreAllocated(java.lang.String suName)Check if a ServiceUnit is pre-allocated to this ResourceUnit.voidremoveLoadedServiceUnit(java.lang.String suName, org.apache.pulsar.common.policies.data.ResourceQuota quota)Remove a service unit from the loaded bundle list.static voidsetCpuUsageByMsgRate(double cpuUsageByMsgRate)
-
-
-
Constructor Detail
-
ResourceUnitRanking
public ResourceUnitRanking(SystemResourceUsage systemResourceUsage, java.util.Set<java.lang.String> loadedBundles, org.apache.pulsar.common.policies.data.ResourceQuota allocatedQuota, java.util.Set<java.lang.String> preAllocatedBundles, org.apache.pulsar.common.policies.data.ResourceQuota preAllocatedQuota)
-
-
Method Detail
-
setCpuUsageByMsgRate
public static void setCpuUsageByMsgRate(double cpuUsageByMsgRate)
-
compareTo
public int compareTo(ResourceUnitRanking other)
- Specified by:
compareToin interfacejava.lang.Comparable<ResourceUnitRanking>
-
compareMessageRateTo
public int compareMessageRateTo(ResourceUnitRanking other)
Compare two loads based on message rate only.
-
isIdle
public boolean isIdle()
If the ResourceUnit is idle.
-
isServiceUnitLoaded
public boolean isServiceUnitLoaded(java.lang.String suName)
Check if a ServiceUnit is already loaded by this ResourceUnit.
-
isServiceUnitPreAllocated
public boolean isServiceUnitPreAllocated(java.lang.String suName)
Check if a ServiceUnit is pre-allocated to this ResourceUnit.
-
addPreAllocatedServiceUnit
public void addPreAllocatedServiceUnit(java.lang.String suName, org.apache.pulsar.common.policies.data.ResourceQuota quota)Pre-allocate a ServiceUnit to this ResourceUnit.
-
removeLoadedServiceUnit
public void removeLoadedServiceUnit(java.lang.String suName, org.apache.pulsar.common.policies.data.ResourceQuota quota)Remove a service unit from the loaded bundle list.
-
getPreAllocatedBundles
public java.util.Set<java.lang.String> getPreAllocatedBundles()
Get the pre-allocated bundles.
-
getLoadedBundles
public java.util.Set<java.lang.String> getLoadedBundles()
Get the loaded bundles.
-
getEstimatedLoadPercentage
public double getEstimatedLoadPercentage()
Get the estimated load percentage.
-
getEstimatedMessageRate
public double getEstimatedMessageRate()
Get the estimated message rate.
-
getAllocatedLoadPercentageCPU
public double getAllocatedLoadPercentageCPU()
Percentage of CPU allocated to bundle's quota.
-
getAllocatedLoadPercentageMemory
public double getAllocatedLoadPercentageMemory()
Percetage of memory allocated to bundle's quota.
-
getAllocatedLoadPercentageBandwidthIn
public double getAllocatedLoadPercentageBandwidthIn()
Percentage of inbound bandwidth allocated to bundle's quota.
-
getAllocatedLoadPercentageBandwidthOut
public double getAllocatedLoadPercentageBandwidthOut()
Percentage of outbound bandwidth allocated to bundle's quota.
-
getEstimatedLoadPercentageString
public java.lang.String getEstimatedLoadPercentageString()
Get the load percentage in String, with detail resource usages.
-
estimateMaxCapacity
public long estimateMaxCapacity(org.apache.pulsar.common.policies.data.ResourceQuota defaultQuota)
Estimate the maximum number of namespace bundles ths ResourceUnit is able to handle with all resource.
-
calculateBrokerMaxCapacity
public static long calculateBrokerMaxCapacity(SystemResourceUsage systemResourceUsage, org.apache.pulsar.common.policies.data.ResourceQuota defaultQuota)
Estimate the maximum number namespace bundles a ResourceUnit is able to handle with all resource.
-
-