public class ResourceGroupService extends Object
ResourceGroupService contains APIs to manipulate resource groups. It is assumed that there is a
single instance of the ResourceGroupService on each broker.
The control plane operations are somewhat stringent, and throw exceptions if (for instance) the op refers to a
resource group which does not exist.
The data plane operations (e.g., increment stats) throw exceptions as a last resort; if (e.g.) increment stats
refers to a non-existent resource group, the stats are quietly not incremented.PulsarService| Modifier and Type | Class and Description |
|---|---|
protected static class |
ResourceGroupService.ResourceGroupOpStatus |
protected static class |
ResourceGroupService.ResourceGroupUsageStatsType |
| Modifier and Type | Field and Description |
|---|---|
protected static long |
maxIntervalForSuppressingReportsMSecs |
protected static int |
MaxUsageReportSuppressRounds |
protected ResourceQuotaCalculator |
quotaCalculator |
protected static float |
UsageReportSuppressionTolerancePercentage |
| Constructor and Description |
|---|
ResourceGroupService(PulsarService pulsar)
Default constructor.
|
ResourceGroupService(PulsarService pulsar,
TimeUnit timescale,
ResourceUsageTopicTransportManager transportMgr,
ResourceQuotaCalculator quotaCalc) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
aggregateResourceGroupLocalUsages() |
protected void |
calculateQuotaForAllResourceGroups() |
ResourceGroup |
getNamespaceResourceGroup(org.apache.pulsar.common.naming.NamespaceName namespaceName)
Return the resource group associated with a namespace.
|
protected long |
getNumResourceGroups()
Get the current number of RGs.
|
protected ResourceGroup.BytesAndMessagesCount |
getPublishRateLimiters(String rgName) |
protected static double |
getRgLocalUsageByteCount(String rgName,
String monClassName) |
protected static double |
getRgLocalUsageMessageCount(String rgName,
String monClassName) |
protected static double |
getRgNamespaceRegistersCount(String rgName) |
protected static double |
getRgNamespaceUnRegistersCount(String rgName) |
protected static double |
getRgQuotaByteCount(String rgName,
String monClassName) |
protected static io.prometheus.client.Summary.Child.Value |
getRgQuotaCalculationTime() |
protected static double |
getRgQuotaMessageCount(String rgName,
String monClassName) |
protected static double |
getRgTenantRegistersCount(String rgName) |
protected static double |
getRgTenantUnRegistersCount(String rgName) |
protected static double |
getRgUpdatesCount(String rgName) |
protected ResourceGroup.BytesAndMessagesCount |
getRGUsage(String rgName,
ResourceGroup.ResourceGroupMonitoringClass monClass,
ResourceGroupService.ResourceGroupUsageStatsType statsType) |
protected static io.prometheus.client.Summary.Child.Value |
getRgUsageAggregationLatency() |
protected boolean |
incrementUsage(String tenantName,
String nsName,
ResourceGroup.ResourceGroupMonitoringClass monClass,
ResourceGroup.BytesAndMessagesCount incStats)
Increments usage stats for the resource groups associated with the given namespace and tenant.
|
void |
registerNameSpace(String resourceGroupName,
org.apache.pulsar.common.naming.NamespaceName fqNamespaceName)
Registers a namespace as a user of a resource group.
|
void |
registerTenant(String resourceGroupName,
String tenantName)
Registers a tenant as a user of a resource group.
|
void |
resourceGroupCreate(String rgName,
org.apache.pulsar.common.policies.data.ResourceGroup rgConfig)
Create RG.
|
void |
resourceGroupCreate(String rgName,
org.apache.pulsar.common.policies.data.ResourceGroup rgConfig,
ResourceUsagePublisher rgPublisher,
ResourceUsageConsumer rgConsumer)
Create RG, with non-default functions for resource-usage transport-manager.
|
void |
resourceGroupDelete(String name)
Delete RG.
|
ResourceGroup |
resourceGroupGet(String resourceGroupName)
Get a copy of the RG with the given name.
|
Set<String> |
resourceGroupGetAll() |
void |
resourceGroupUpdate(String rgName,
org.apache.pulsar.common.policies.data.ResourceGroup rgConfig)
Update RG.
|
void |
unRegisterNameSpace(String resourceGroupName,
org.apache.pulsar.common.naming.NamespaceName fqNamespaceName)
UnRegisters a namespace from a resource group.
|
void |
unRegisterTenant(String resourceGroupName,
String tenantName)
UnRegisters a tenant from a resource group.
|
protected final ResourceQuotaCalculator quotaCalculator
protected static final int MaxUsageReportSuppressRounds
protected static long maxIntervalForSuppressingReportsMSecs
protected static final float UsageReportSuppressionTolerancePercentage
public ResourceGroupService(PulsarService pulsar)
public ResourceGroupService(PulsarService pulsar, TimeUnit timescale, ResourceUsageTopicTransportManager transportMgr, ResourceQuotaCalculator quotaCalc)
public void resourceGroupCreate(String rgName, org.apache.pulsar.common.policies.data.ResourceGroup rgConfig) throws PulsarAdminException
if - RG with that name already exists.PulsarAdminExceptionpublic void resourceGroupCreate(String rgName, org.apache.pulsar.common.policies.data.ResourceGroup rgConfig, ResourceUsagePublisher rgPublisher, ResourceUsageConsumer rgConsumer) throws PulsarAdminException
if - RG with that name already exists (even if the resource usage handlers are different).PulsarAdminExceptionpublic ResourceGroup resourceGroupGet(String resourceGroupName)
public void resourceGroupUpdate(String rgName, org.apache.pulsar.common.policies.data.ResourceGroup rgConfig) throws PulsarAdminException
if - RG with that name does not exist.PulsarAdminExceptionpublic void resourceGroupDelete(String name) throws PulsarAdminException
if - RG with that name does not exist, or if the RG exists but is still in use.PulsarAdminExceptionprotected long getNumResourceGroups()
public void registerTenant(String resourceGroupName, String tenantName) throws PulsarAdminException
resourceGroupName - tenantName - if - the RG does not exist, or if the NS already references the RG.PulsarAdminExceptionpublic void unRegisterTenant(String resourceGroupName, String tenantName) throws PulsarAdminException
resourceGroupName - tenantName - if - the RG does not exist, or if the tenant does not references the RG yet.PulsarAdminExceptionpublic void registerNameSpace(String resourceGroupName, org.apache.pulsar.common.naming.NamespaceName fqNamespaceName) throws PulsarAdminException
resourceGroupName - fqNamespaceName - (i.e., in "tenant/Namespace" format)if - the RG does not exist, or if the NS already references the RG.PulsarAdminExceptionpublic void unRegisterNameSpace(String resourceGroupName, org.apache.pulsar.common.naming.NamespaceName fqNamespaceName) throws PulsarAdminException
resourceGroupName - fqNamespaceName - i.e., in "tenant/Namespace" format)if - the RG does not exist, or if the NS does not references the RG yet.PulsarAdminExceptionpublic ResourceGroup getNamespaceResourceGroup(org.apache.pulsar.common.naming.NamespaceName namespaceName)
namespaceName - if - the RG does not exist, or if the NS already references the RG.protected boolean incrementUsage(String tenantName, String nsName, ResourceGroup.ResourceGroupMonitoringClass monClass, ResourceGroup.BytesAndMessagesCount incStats) throws PulsarAdminException
tenantName - nsName - monClass - incStats - PulsarAdminExceptionprotected ResourceGroup.BytesAndMessagesCount getRGUsage(String rgName, ResourceGroup.ResourceGroupMonitoringClass monClass, ResourceGroupService.ResourceGroupUsageStatsType statsType) throws PulsarAdminException
PulsarAdminExceptionprotected ResourceGroup.BytesAndMessagesCount getPublishRateLimiters(String rgName) throws PulsarAdminException
PulsarAdminExceptionprotected static double getRgQuotaMessageCount(String rgName, String monClassName)
protected static double getRgLocalUsageByteCount(String rgName, String monClassName)
protected static double getRgLocalUsageMessageCount(String rgName, String monClassName)
protected static double getRgUpdatesCount(String rgName)
protected static double getRgTenantRegistersCount(String rgName)
protected static double getRgTenantUnRegistersCount(String rgName)
protected static double getRgNamespaceRegistersCount(String rgName)
protected static double getRgNamespaceUnRegistersCount(String rgName)
protected static io.prometheus.client.Summary.Child.Value getRgUsageAggregationLatency()
protected static io.prometheus.client.Summary.Child.Value getRgQuotaCalculationTime()
protected void aggregateResourceGroupLocalUsages()
protected void calculateQuotaForAllResourceGroups()
Copyright © 2017–2022 Apache Software Foundation. All rights reserved.