Add CheckStyle Plugin in pulsar-zookeeper-utils (#13499)
diff --git a/pulsar-zookeeper-utils/pom.xml b/pulsar-zookeeper-utils/pom.xml
index b06bd8d..eeffaed 100644
--- a/pulsar-zookeeper-utils/pom.xml
+++ b/pulsar-zookeeper-utils/pom.xml
@@ -156,6 +156,19 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>checkstyle</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
diff --git a/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/stats/CacheMetricsCollector.java b/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/stats/CacheMetricsCollector.java
index 86d4f2f..5df9d3a 100644
--- a/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/stats/CacheMetricsCollector.java
+++ b/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/stats/CacheMetricsCollector.java
@@ -23,6 +23,7 @@
@UtilityClass
public class CacheMetricsCollector {
- public static final io.prometheus.client.cache.caffeine.CacheMetricsCollector CAFFEINE = new io.prometheus.client.cache.caffeine.CacheMetricsCollector()
+ public static final io.prometheus.client.cache.caffeine.CacheMetricsCollector CAFFEINE =
+ new io.prometheus.client.cache.caffeine.CacheMetricsCollector()
.register();
}
diff --git a/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/stats/package-info.java b/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/stats/package-info.java
new file mode 100644
index 0000000..1173684
--- /dev/null
+++ b/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/stats/package-info.java
@@ -0,0 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.stats;
diff --git a/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/LocalBookkeeperEnsemble.java b/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/LocalBookkeeperEnsemble.java
index e1c18b4..37cbb84 100644
--- a/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/LocalBookkeeperEnsemble.java
+++ b/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/LocalBookkeeperEnsemble.java
@@ -26,7 +26,6 @@
import static org.apache.bookkeeper.stream.protocol.ProtocolConstants.DEFAULT_STREAM_CONF;
import static org.apache.commons.io.FileUtils.cleanDirectory;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
-
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
@@ -45,7 +44,6 @@
import java.util.function.Supplier;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
-
import org.apache.bookkeeper.bookie.BookieException.InvalidCookieException;
import org.apache.bookkeeper.bookie.storage.ldb.DbLedgerStorage;
import org.apache.bookkeeper.clients.StorageClientBuilder;
@@ -152,7 +150,7 @@
LOG.info("Running {} bookie(s) and advertised them at {}.", this.numberOfBookies, this.advertisedAddress);
}
- private String HOSTPORT;
+ private String hostPort;
private final String advertisedAddress;
private int zkPort;
@@ -217,9 +215,9 @@
}
this.zkPort = serverFactory.getLocalPort();
- this.HOSTPORT = "127.0.0.1:" + zkPort;
+ this.hostPort = "127.0.0.1:" + zkPort;
- boolean b = waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT);
+ boolean b = waitForServerUp(hostPort, CONNECTION_TIMEOUT);
LOG.info("ZooKeeper server up: {}", b);
LOG.debug("Local ZK started (port: {}, data_directory: {})", zkPort, zkDataDir.getAbsolutePath());
@@ -231,7 +229,8 @@
LOG.info("disconnect ZK server side connection {}", serverCnxn);
Class disconnectReasonClass = Class.forName("org.apache.zookeeper.server.ServerCnxn$DisconnectReason");
Method method = serverCnxn.getClass().getMethod("close", disconnectReasonClass);
- method.invoke(serverCnxn, Stream.of(disconnectReasonClass.getEnumConstants()).filter(s->s.toString().equals("CONNECTION_CLOSE_FORCED")).findFirst().get());
+ method.invoke(serverCnxn, Stream.of(disconnectReasonClass.getEnumConstants()).filter(s ->
+ s.toString().equals("CONNECTION_CLOSE_FORCED")).findFirst().get());
} catch (Exception ex) {
throw new RuntimeException(ex);
}
@@ -249,7 +248,7 @@
// initialize the zk client with values
try {
ZKConnectionWatcher zkConnectionWatcher = new ZKConnectionWatcher();
- zkc = new ZooKeeper(HOSTPORT, zkSessionTimeOut, zkConnectionWatcher);
+ zkc = new ZooKeeper(hostPort, zkSessionTimeOut, zkConnectionWatcher);
zkConnectionWatcher.waitForConnection();
if (zkc.exists("/ledgers", false) == null) {
zkc.create("/ledgers", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
@@ -295,7 +294,8 @@
int bookiePort = portManager.get();
// Ensure registration Z-nodes are cleared when standalone service is restarted ungracefully
- String registrationZnode = String.format("/ledgers/available/%s:%d", baseConf.getAdvertisedAddress(), bookiePort);
+ String registrationZnode = String.format("/ledgers/available/%s:%d",
+ baseConf.getAdvertisedAddress(), bookiePort);
if (zkc.exists(registrationZnode, null) != null) {
try {
zkc.delete(registrationZnode, -1);
diff --git a/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/package-info.java b/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/package-info.java
new file mode 100644
index 0000000..61f96f6
--- /dev/null
+++ b/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/package-info.java
@@ -0,0 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.zookeeper;