Skip to content

Commit

Permalink
[CheckStyle]Make codestyle of module pulsar-broker gradually confor…
Browse files Browse the repository at this point in the history
…m CheckStyle (apache#8848)

* add provided jclouds

Signed-off-by: Renkai <[email protected]>

* make broker-style gradually conform checkstyle

Signed-off-by: Renkai <[email protected]>

* make broker-style gradually conform checkstyle

Signed-off-by: Renkai <[email protected]>

* make broker-style gradually conform checkstyle

Signed-off-by: Renkai <[email protected]>

* make broker-style gradually conform checkstyle

Signed-off-by: Renkai <[email protected]>
  • Loading branch information
Renkai authored Dec 8, 2020
1 parent 5054642 commit 0e89f96
Show file tree
Hide file tree
Showing 10 changed files with 1,160 additions and 840 deletions.
1 change: 0 additions & 1 deletion buildtools/src/main/resources/pulsar/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
<suppress checks="ConstantName" files="MessageId.java"/>
<suppress checks="MethodName" files="TopicsImpl.java"/>
<suppress checks="MemberName" files="TopicsImpl.java"/>
<suppress checks=".*" files="src/main/java/org/apache/pulsar/broker/admin/impl/.*.java"/>
<suppress checks=".*" files="src/main/java/org/apache/pulsar/broker/cache/.*.java"/>
<suppress checks=".*" files="src/main/java/org/apache/pulsar/broker/delayed/.*.java"/>
<suppress checks=".*" files="src/main/java/org/apache/pulsar/broker/intercept/.*.java"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public class BrokerStatsBase extends AdminResource {

@GET
@Path("/metrics")
@ApiOperation(value = "Gets the metrics for Monitoring", notes = "Requested should be executed by Monitoring agent on each broker to fetch the metrics", response = Metrics.class, responseContainer = "List")
@ApiOperation(value = "Gets the metrics for Monitoring",
notes = "Requested should be executed by Monitoring agent on each broker to fetch the metrics",
response = Metrics.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission") })
public Collection<Metrics> getMetrics() throws Exception {
// Ensure super user access only
Expand All @@ -68,7 +70,8 @@ public Collection<Metrics> getMetrics() throws Exception {

@GET
@Path("/mbeans")
@ApiOperation(value = "Get all the mbean details of this broker JVM", response = Metrics.class, responseContainer = "List")
@ApiOperation(value = "Get all the mbean details of this broker JVM",
response = Metrics.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission") })
public Collection<Metrics> getMBeans() throws Exception {
// Ensure super user access only
Expand All @@ -84,10 +87,9 @@ public Collection<Metrics> getMBeans() throws Exception {

@GET
@Path("/destinations")
@ApiOperation(value = "Get all the topic stats by namespace", response = OutputStream.class, responseContainer = "OutputStream") // https://github.com/swagger-api/swagger-ui/issues/558
// map
// support
// missing
@ApiOperation(value = "Get all the topic stats by namespace", response = OutputStream.class,
responseContainer = "OutputStream") // https://github.com/swagger-api/swagger-ui/issues/558
// map support missing
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission") })
public StreamingOutput getTopics2() throws Exception {
// Ensure super user access only
Expand All @@ -103,7 +105,8 @@ public StreamingOutput getTopics2() throws Exception {

@GET
@Path("/allocator-stats/{allocator}")
@ApiOperation(value = "Get the stats for the Netty allocator. Available allocators are 'default' and 'ml-cache'", response = AllocatorStats.class)
@ApiOperation(value = "Get the stats for the Netty allocator. Available allocators are 'default' and 'ml-cache'",
response = AllocatorStats.class)
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission") })
public AllocatorStats getAllocatorStats(@PathParam("allocator") String allocatorName) throws Exception {
// Ensure super user access only
Expand All @@ -121,15 +124,13 @@ public AllocatorStats getAllocatorStats(@PathParam("allocator") String allocator

@GET
@Path("/bookieops")
@ApiOperation(value = "Get pending bookie client op stats by namesapce", response = PendingBookieOpsStats.class, // https://github.com/swagger-api/swagger-core/issues/449
// nested
// containers
// are
// not
// supported
@ApiOperation(value = "Get pending bookie client op stats by namesapce",
response = PendingBookieOpsStats.class,
// https://github.com/swagger-api/swagger-core/issues/449
// nested containers are not supported
responseContainer = "Map")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission") })
public Map<String, Map<String, PendingBookieOpsStats>> getPendingBookieOpsStats() throws Exception {
public Map<String, Map<String, PendingBookieOpsStats>> getPendingBookieOpsStats() {
// Ensure super user access only
validateSuperUserAccess();
try {
Expand All @@ -142,7 +143,8 @@ public Map<String, Map<String, PendingBookieOpsStats>> getPendingBookieOpsStats(

@GET
@Path("/load-report")
@ApiOperation(value = "Get Load for this broker", notes = "consists of topics stats & systemResourceUsage", response = LoadReport.class)
@ApiOperation(value = "Get Load for this broker", notes = "consists of topics stats & systemResourceUsage",
response = LoadReport.class)
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission") })
public LoadManagerReport getLoadReport() throws Exception {
// Ensure super user access only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ public Set<String> getActiveBrokers(@PathParam("cluster") String cluster) throws

@GET
@Path("/{clusterName}/{broker-webserviceurl}/ownedNamespaces")
@ApiOperation(value = "Get the list of namespaces served by the specific broker", response = NamespaceOwnershipStatus.class, responseContainer = "Map")
@ApiOperation(value = "Get the list of namespaces served by the specific broker",
response = NamespaceOwnershipStatus.class, responseContainer = "Map")
@ApiResponses(value = {
@ApiResponse(code = 307, message = "Current broker doesn't serve the cluster"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Cluster doesn't exist") })
@ApiResponse(code = 307, message = "Current broker doesn't serve the cluster"),
@ApiResponse(code = 403, message = "Don't have admin permission"),
@ApiResponse(code = 404, message = "Cluster doesn't exist") })
public Map<String, NamespaceOwnershipStatus> getOwnedNamespaces(@PathParam("clusterName") String cluster,
@PathParam("broker-webserviceurl") String broker) throws Exception {
validateSuperUserAccess();
Expand All @@ -122,21 +123,24 @@ public Map<String, NamespaceOwnershipStatus> getOwnedNamespaces(@PathParam("clus

@POST
@Path("/configuration/{configName}/{configValue}")
@ApiOperation(value = "Update dynamic serviceconfiguration into zk only. This operation requires Pulsar super-user privileges.")
@ApiOperation(value =
"Update dynamic serviceconfiguration into zk only. This operation requires Pulsar super-user privileges.")
@ApiResponses(value = {
@ApiResponse(code = 204, message = "Service configuration updated successfully"),
@ApiResponse(code = 403, message = "You don't have admin permission to update service-configuration"),
@ApiResponse(code = 404, message = "Configuration not found"),
@ApiResponse(code = 412, message = "Invalid dynamic-config value"),
@ApiResponse(code = 500, message = "Internal server error")})
public void updateDynamicConfiguration(@PathParam("configName") String configName, @PathParam("configValue") String configValue) throws Exception {
@ApiResponse(code = 204, message = "Service configuration updated successfully"),
@ApiResponse(code = 403, message = "You don't have admin permission to update service-configuration"),
@ApiResponse(code = 404, message = "Configuration not found"),
@ApiResponse(code = 412, message = "Invalid dynamic-config value"),
@ApiResponse(code = 500, message = "Internal server error") })
public void updateDynamicConfiguration(@PathParam("configName") String configName,
@PathParam("configValue") String configValue) throws Exception {
validateSuperUserAccess();
updateDynamicConfigurationOnZk(configName, configValue);
}

@DELETE
@Path("/configuration/{configName}")
@ApiOperation(value = "Delete dynamic serviceconfiguration into zk only. This operation requires Pulsar super-user privileges.")
@ApiOperation(value =
"Delete dynamic serviceconfiguration into zk only. This operation requires Pulsar super-user privileges.")
@ApiResponses(value = { @ApiResponse(code = 204, message = "Service configuration updated successfully"),
@ApiResponse(code = 403, message = "You don't have admin permission to update service-configuration"),
@ApiResponse(code = 412, message = "Invalid dynamic-config value"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,8 @@ public NamespaceIsolationData getNamespaceIsolationPolicy(
"NamespaceIsolationPolicies for cluster " + cluster + " does not exist"));
// construct the response to Namespace isolation data map
if (!nsIsolationPolicies.getPolicies().containsKey(policyName)) {
log.info("[{}] Cannot find NamespaceIsolationPolicy {} for cluster {}", clientAppId(), policyName, cluster);
log.info("[{}] Cannot find NamespaceIsolationPolicy {} for cluster {}",
clientAppId(), policyName, cluster);
throw new RestException(Status.NOT_FOUND,
"Cannot find NamespaceIsolationPolicy " + policyName + " for cluster " + cluster);
}
Expand Down Expand Up @@ -732,7 +733,8 @@ public void setNamespaceIsolationPolicy(
}
}

private boolean createZnodeIfNotExist(String path, Optional<Object> value) throws KeeperException, InterruptedException {
private boolean createZnodeIfNotExist(String path, Optional<Object> value)
throws KeeperException, InterruptedException {
// create persistent node on ZooKeeper
if (globalZk().exists(path, false) == null) {
// create all the intermediate nodes
Expand All @@ -742,7 +744,7 @@ private boolean createZnodeIfNotExist(String path, Optional<Object> value) throw
CreateMode.PERSISTENT);
return true;
} catch (KeeperException.NodeExistsException nee) {
if(log.isDebugEnabled()) {
if (log.isDebugEnabled()) {
log.debug("Other broker preempted the full path [{}] already. Continue...", path);
}
} catch (JsonGenerationException e) {
Expand Down Expand Up @@ -979,7 +981,8 @@ public void deleteFailureDomain(
validateClusterExists(cluster);

try {
final String domainPath = joinPath(pulsar().getConfigurationCache().CLUSTER_FAILURE_DOMAIN_ROOT, domainName);
final String domainPath = joinPath(pulsar().getConfigurationCache().CLUSTER_FAILURE_DOMAIN_ROOT,
domainName);
globalZk().delete(domainPath, -1);
// clear domain cache
failureDomainCache().invalidate(domainPath);
Expand All @@ -1004,7 +1007,9 @@ private void validateBrokerExistsInOtherDomain(final String cluster, final Strin
continue;
}
try {
Optional<FailureDomain> domain = failureDomainCache().get(joinPath(failureDomainRootPath, domainName));
Optional<FailureDomain> domain =
failureDomainCache()
.get(joinPath(failureDomainRootPath, domainName));
if (domain.isPresent() && domain.get().brokers != null) {
List<String> duplicateBrokers = domain.get().brokers.stream().parallel()
.filter(inputDomain.brokers::contains).collect(Collectors.toList());
Expand Down
Loading

0 comments on commit 0e89f96

Please sign in to comment.