You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/08/12 17:13:45 UTC
[GitHub] [pulsar] kaushik-develop commented on a change in pull request #11643: [PIP-82] [pulsar-broker] Use the qualified NS-name in RG-register/unr…
kaushik-develop commented on a change in pull request #11643:
URL: https://github.com/apache/pulsar/pull/11643#discussion_r687935424
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java
##########
@@ -233,66 +235,80 @@ public void unRegisterTenant(String resourceGroupName, String tenantName) throws
* Registers a namespace as a user of a resource group.
*
* @param resourceGroupName
- * @param namespaceName
+ * @param fqNamespaceName (i.e., in "tenant/Namespace" format)
* @throws if the RG does not exist, or if the NS already references the RG.
*/
- public void registerNameSpace(String resourceGroupName, String namespaceName) throws PulsarAdminException {
+ public void registerNameSpace(String resourceGroupName, String fqNamespaceName) throws PulsarAdminException {
+ // Since it is a fully qualified NS, we expect a '/' in it.
+ String[] parts = fqNamespaceName.split("/");
Review comment:
Thanks; updated in the next iteration.
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceGroupService.java
##########
@@ -233,66 +235,80 @@ public void unRegisterTenant(String resourceGroupName, String tenantName) throws
* Registers a namespace as a user of a resource group.
*
* @param resourceGroupName
- * @param namespaceName
+ * @param fqNamespaceName (i.e., in "tenant/Namespace" format)
* @throws if the RG does not exist, or if the NS already references the RG.
*/
- public void registerNameSpace(String resourceGroupName, String namespaceName) throws PulsarAdminException {
+ public void registerNameSpace(String resourceGroupName, String fqNamespaceName) throws PulsarAdminException {
+ // Since it is a fully qualified NS, we expect a '/' in it.
+ String[] parts = fqNamespaceName.split("/");
+ if (parts.length < 2) {
+ String errMesg = "Fully-qualified namespace " + fqNamespaceName + " does not have a topic in it";
+ throw new PulsarAdminException(errMesg);
+ }
+
ResourceGroup rg = checkResourceGroupExists(resourceGroupName);
// Check that the NS-name doesn't already have a RG association.
// [If it does, that should be unregistered before putting a different association.]
- ResourceGroup oldRG = this.namespaceToRGsMap.get(namespaceName);
+ ResourceGroup oldRG = this.namespaceToRGsMap.get(fqNamespaceName);
if (oldRG != null) {
- String errMesg = "Namespace " + namespaceName + " already references a resource group: " + oldRG.getID();
+ String errMesg = "Namespace " + fqNamespaceName + " already references a resource group: " + oldRG.getID();
throw new PulsarAdminException(errMesg);
}
- ResourceGroupOpStatus status = rg.registerUsage(namespaceName, ResourceGroupRefTypes.Namespaces, true,
+ ResourceGroupOpStatus status = rg.registerUsage(fqNamespaceName, ResourceGroupRefTypes.Namespaces, true,
this.resourceUsageTransportManagerMgr);
if (status == ResourceGroupOpStatus.Exists) {
String errMesg = String.format("Namespace {} already references the target resource group {}",
- namespaceName, resourceGroupName);
+ fqNamespaceName, resourceGroupName);
throw new PulsarAdminException(errMesg);
}
// Associate this NS-name with the RG.
- this.namespaceToRGsMap.put(namespaceName, rg);
+ this.namespaceToRGsMap.put(fqNamespaceName, rg);
rgNamespaceRegisters.labels(resourceGroupName).inc();
}
- /**
- * Return the resource group associated with a namespace.
- *
- * @param namespaceName
- * @throws if the RG does not exist, or if the NS already references the RG.
- */
- public ResourceGroup getNamespaceResourceGroup(String namespaceName) {
- return this.namespaceToRGsMap.get(namespaceName);
- }
-
/**
* UnRegisters a namespace from a resource group.
*
* @param resourceGroupName
- * @param namespaceName
+ * @param fqNamespaceName i.e., in "tenant/Namespace" format)
* @throws if the RG does not exist, or if the NS does not references the RG yet.
*/
- public void unRegisterNameSpace(String resourceGroupName, String namespaceName) throws PulsarAdminException {
+ public void unRegisterNameSpace(String resourceGroupName, String fqNamespaceName) throws PulsarAdminException {
+ // Since it is a fully qualified NS, we expect a '/' in it.
+ String[] parts = fqNamespaceName.split("/");
Review comment:
Thanks; updated in the next iteration.
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/resourcegroup/ResourceQuotaCalculatorImpl.java
##########
@@ -60,7 +68,11 @@ public long computeLocalQuota(long confUsage, long myUsage, long[] allUsages) th
float myUsageFraction = (float) myUsage / totalUsage;
float calculatedQuota = max(myUsage + residual * myUsageFraction, 0);
- return (long) calculatedQuota;
+ val longCalculatedQuota = (long) calculatedQuota;
Review comment:
No explicit need. I am just more used to the deciphering of types (through my C++11 and later background) by compiler support, instead of by the programmer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org