pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] sijie commented on a change in pull request #2883: Add healthcheck for broker
Date Mon, 29 Oct 2018 19:47:07 GMT
sijie commented on a change in pull request #2883: Add healthcheck for broker
URL: https://github.com/apache/pulsar/pull/2883#discussion_r229072513
 
 

 ##########
 File path: pulsar-broker/src/main/java/org/apache/pulsar/PulsarHealthcheck.java
 ##########
 @@ -0,0 +1,204 @@
+/**
+ * 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 com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.nio.file.Paths;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import java.util.Properties;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.lang3.StringUtils;
+
+import org.apache.pulsar.client.admin.PulsarAdmin;
+import org.apache.pulsar.client.admin.PulsarAdminBuilder;
+import org.apache.pulsar.client.api.ClientBuilder;
+import org.apache.pulsar.client.api.Consumer;
+import org.apache.pulsar.client.api.Message;
+import org.apache.pulsar.client.api.Producer;
+import org.apache.pulsar.client.api.PulsarClient;
+import org.apache.pulsar.client.api.Schema;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class PulsarHealthcheck {
+    private static final Logger log = LoggerFactory.getLogger(PulsarHealthcheck.class);
+
+    private static class HealthcheckArguments {
+        @Parameter(names = {"-c", "--clientConf"}, description = "Configuration file for
healthcheck")
+        private String healthcheckConf = Paths.get("").toAbsolutePath().normalize().toString()
+ "/conf/client.conf";
+
+        @Parameter(names = {"-t", "--timeout"}, description = "Max number of seconds to wait
for the healthcheck")
+        private int timeoutSeconds = 10;
+
+        @Parameter(names = {"-h", "--help"}, description = "Show this help message")
+        private boolean help = false;
+    }
+
+    private static class Healthcheck implements Callable<Void> {
+        private final Properties properties;
+
+        Healthcheck(Properties properties) {
+            this.properties = properties;
+        }
+
+        @Override
+        public Void call() throws Exception {
+            log.info("Running healthcheck");
+            try (PulsarAdmin admin = propsToAdminBuilder(properties).build()) {
+                String topic = String.format("persistent://%s/healthcheck",
+                                             admin.brokers().getInternalConfigurationData().getHeartbeatNamespace());
 
 Review comment:
   but we need to handle the case if people rollback broker without tearing down the health
check, no? from writing code perspective, we have to keep these things in mind, because you
can assume people who running this code will follow exactly the same scenario you are thinking
of. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

Mime
View raw message