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 |
| 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,
ResourceUsageTransportManager transportMgr,
ResourceQuotaCalculator quotaCalc) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
aggregateResourceGroupLocalUsages() |
protected long |
getNumResourceGroups()
Get the current number of RGs.
|
protected ResourceGroup.BytesAndMessagesCount |
getRGUsage(String rgName,
ResourceGroup.ResourceGroupMonitoringClass monClass) |
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,
String namespaceName)
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(ResourceGroupConfigInfo rgConfig)
Create RG.
|
void |
resourceGroupCreate(ResourceGroupConfigInfo 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.
|
void |
resourceGroupUpdate(ResourceGroupConfigInfo rgConfig)
Update RG.
|
void |
unRegisterNameSpace(String resourceGroupName,
String namespaceName)
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, ResourceUsageTransportManager transportMgr, ResourceQuotaCalculator quotaCalc)
public void resourceGroupCreate(ResourceGroupConfigInfo rgConfig) throws PulsarAdminException
if - RG with that name already exists.PulsarAdminExceptionpublic void resourceGroupCreate(ResourceGroupConfigInfo 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(ResourceGroupConfigInfo 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, String namespaceName) throws PulsarAdminException
resourceGroupName - namespaceName - if - the RG does not exist, or if the NS already references the RG.PulsarAdminExceptionpublic void unRegisterNameSpace(String resourceGroupName, String namespaceName) throws PulsarAdminException
resourceGroupName - namespaceName - if - the RG does not exist, or if the NS does not references the RG yet.PulsarAdminExceptionpublic 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) throws PulsarAdminException
PulsarAdminExceptionprotected void aggregateResourceGroupLocalUsages()
Copyright © 2017–2021 Apache Software Foundation. All rights reserved.