You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2018/03/28 20:43:32 UTC
[incubator-pulsar] branch master updated: Fix broker stats to work
with v2 namespace format. (#1464)
This is an automated email from the ASF dual-hosted git repository.
mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new ba76b71 Fix broker stats to work with v2 namespace format. (#1464)
ba76b71 is described below
commit ba76b71593ed3b41fded5c1050460a5d6614aa79
Author: cckellogg <cc...@gmail.com>
AuthorDate: Wed Mar 28 13:43:29 2018 -0700
Fix broker stats to work with v2 namespace format. (#1464)
---
.../pulsar/broker/admin/impl/BrokerStatsBase.java | 13 ++----------
.../apache/pulsar/broker/admin/v1/BrokerStats.java | 24 ++++++++++++++++++++++
.../apache/pulsar/broker/admin/v2/BrokerStats.java | 23 +++++++++++++++++++++
3 files changed, 49 insertions(+), 11 deletions(-)
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokerStatsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokerStatsBase.java
index 9da3fc6..03fc9a2 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokerStatsBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokerStatsBase.java
@@ -158,20 +158,11 @@ public class BrokerStatsBase extends AdminResource {
}
}
- @GET
- @Path("/broker-resource-availability/{property}/{cluster}/{namespace}")
- @ApiOperation(value = "Broker availability report", notes = "This API gives the current broker availability in percent, each resource percentage usage is calculated and then"
- + "sum of all of the resource usage percent is called broker-resource-availability"
- + "<br/><br/>THIS API IS ONLY FOR USE BY TESTING FOR CONFIRMING NAMESPACE ALLOCATION ALGORITHM", response = ResourceUnit.class, responseContainer = "Map")
- @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
- @ApiResponse(code = 409, message = "Load-manager doesn't support operation") })
- public Map<Long, Collection<ResourceUnit>> getBrokerResourceAvailability(@PathParam("property") String property,
- @PathParam("cluster") String cluster, @PathParam("namespace") String namespace) throws Exception {
+ protected Map<Long, Collection<ResourceUnit>> internalBrokerResourceAvailability(NamespaceName namespace) {
try {
- NamespaceName ns = NamespaceName.get(property, cluster, namespace);
LoadManager lm = pulsar().getLoadManager().get();
if (lm instanceof SimpleLoadManagerImpl) {
- return ((SimpleLoadManagerImpl) lm).getResourceAvailabilityFor(ns).asMap();
+ return ((SimpleLoadManagerImpl) lm).getResourceAvailabilityFor(namespace).asMap();
} else {
throw new RestException(Status.CONFLICT, lm.getClass().getName() + " does not support this operation");
}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/BrokerStats.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/BrokerStats.java
index 97ebbd9..76aea67 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/BrokerStats.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/BrokerStats.java
@@ -19,14 +19,38 @@
package org.apache.pulsar.broker.admin.v1;
import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
import org.apache.pulsar.broker.admin.impl.BrokerStatsBase;
+import org.apache.pulsar.broker.loadbalance.ResourceUnit;
+import org.apache.pulsar.common.naming.NamespaceName;
+import javax.ws.rs.GET;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
+import java.util.Collection;
+import java.util.Map;
@Path("/broker-stats")
@Api(value = "/broker-stats", description = "Stats for broker", tags = "broker-stats")
@Produces(MediaType.APPLICATION_JSON)
public class BrokerStats extends BrokerStatsBase {
+
+ @GET
+ @Path("/broker-resource-availability/{property}/{cluster}/{namespace}")
+ @ApiOperation(value = "Broker availability report", notes = "This API gives the current broker availability in "
+ + "percent, each resource percentage usage is calculated and then"
+ + "sum of all of the resource usage percent is called broker-resource-availability"
+ + "<br/><br/>THIS API IS ONLY FOR USE BY TESTING FOR CONFIRMING NAMESPACE ALLOCATION ALGORITHM",
+ response = ResourceUnit.class, responseContainer = "Map")
+ @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponse(code = 409, message = "Load-manager doesn't support operation") })
+ public Map<Long, Collection<ResourceUnit>> getBrokerResourceAvailability(@PathParam("property") String property,
+ @PathParam("cluster") String cluster, @PathParam("namespace") String namespace) {
+ validateNamespaceName(property, cluster, namespace);
+ return internalBrokerResourceAvailability(namespaceName);
+ }
}
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/BrokerStats.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/BrokerStats.java
index f0318d7..fd0d839 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/BrokerStats.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/BrokerStats.java
@@ -19,14 +19,37 @@
package org.apache.pulsar.broker.admin.v2;
import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
import org.apache.pulsar.broker.admin.impl.BrokerStatsBase;
+import org.apache.pulsar.broker.loadbalance.ResourceUnit;
+import javax.ws.rs.GET;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
+import java.util.Collection;
+import java.util.Map;
@Path("/broker-stats")
@Api(value = "/broker-stats", description = "Stats for broker", tags = "broker-stats")
@Produces(MediaType.APPLICATION_JSON)
public class BrokerStats extends BrokerStatsBase {
+
+ @GET
+ @Path("/broker-resource-availability/{property}/{namespace}")
+ @ApiOperation(value = "Broker availability report", notes = "This API gives the current broker availability in "
+ + "percent, each resource percentage usage is calculated and then"
+ + "sum of all of the resource usage percent is called broker-resource-availability"
+ + "<br/><br/>THIS API IS ONLY FOR USE BY TESTING FOR CONFIRMING NAMESPACE ALLOCATION ALGORITHM",
+ response = ResourceUnit.class, responseContainer = "Map")
+ @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"),
+ @ApiResponse(code = 409, message = "Load-manager doesn't support operation") })
+ public Map<Long, Collection<ResourceUnit>> getBrokerResourceAvailability(@PathParam("property") String property,
+ @PathParam("namespace") String namespace) {
+ validateNamespaceName(property, namespace);
+ return internalBrokerResourceAvailability(namespaceName);
+ }
}
--
To stop receiving notification emails like this one, please contact
mmerli@apache.org.