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 2020/09/30 15:48:51 UTC

[GitHub] [pulsar] BewareMyPower commented on a change in pull request #8169: [broker] Add command to delete a cluster's metadata from ZK

BewareMyPower commented on a change in pull request #8169:
URL: https://github.com/apache/pulsar/pull/8169#discussion_r497616934



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataTeardown.java
##########
@@ -0,0 +1,111 @@
+/**
+ * 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;
+
+import com.beust.jcommander.JCommander;
+import com.beust.jcommander.Parameter;
+import org.apache.pulsar.zookeeper.ZooKeeperClientFactory;
+import org.apache.pulsar.zookeeper.ZookeeperClientFactoryImpl;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZKUtil;
+import org.apache.zookeeper.ZooKeeper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.ExecutionException;
+
+/**
+ * Teardown the metadata for a existed Pulsar cluster
+ */
+public class PulsarClusterMetadataTeardown {
+
+    private static class Arguments {
+        @Parameter(names = { "-zk",
+                "--zookeeper"}, description = "Local ZooKeeper quorum connection string", required = true)
+        private String zookeeper;
+
+        @Parameter(names = {
+                "--zookeeper-session-timeout-ms"
+        }, description = "Local zookeeper session timeout ms")
+        private int zkSessionTimeoutMillis = 30000;
+
+        @Parameter(names = { "-c", "-cluster" }, description = "Cluster name")
+        private String cluster;
+
+        @Parameter(names = { "-cs", "--configuration-store" }, description = "Configuration Store connection string")
+        private String configurationStore;
+
+        @Parameter(names = { "-h", "--help" }, description = "Show this help message")
+        private boolean help = false;
+    }
+
+    public static void main(String[] args) throws InterruptedException {
+        Arguments arguments = new Arguments();
+        JCommander jcommander = new JCommander();
+        try {
+            jcommander.addObject(arguments);
+            jcommander.parse(args);
+            if (arguments.help) {
+                jcommander.usage();
+                return;
+            }
+        } catch (Exception e) {
+            jcommander.usage();
+            throw e;
+        }
+
+        ZooKeeper localZk = initZk(arguments.zookeeper, arguments.zkSessionTimeoutMillis);
+
+        deleteZkNodeRecursively(localZk, "/bookies");

Review comment:
       `/managed-ledgers` and `/namespaces` are hard coded in `PulsarClusterMetadataSetup`, `/schemas` is hard coded in `BookkeeperSchemaStorage`,  `/loadbalance` is hard coded in `broker.loadbalance` package. The left ZK nodes I can't find the definition, but I don't find it configurable. If they're all hard coded, IMO, reading them from conf file is unnecessary.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org