[
https://issues.apache.org/jira/browse/STORM-2010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15397883#comment-15397883
]
ASF GitHub Bot commented on STORM-2010:
---------------------------------------
Github user harshach commented on a diff in the pull request:
https://github.com/apache/storm/pull/1598#discussion_r72667584
--- Diff: storm-core/src/jvm/org/apache/storm/command/Heartbeats.java ---
@@ -0,0 +1,89 @@
+/**
+ * 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.storm.command;
+
+import com.google.common.base.Joiner;
+import org.apache.storm.cluster.ClusterStateContext;
+import org.apache.storm.cluster.ClusterUtils;
+import org.apache.storm.cluster.IStateStorage;
+import org.apache.storm.generated.ClusterWorkerHeartbeat;
+import org.apache.storm.stats.StatsUtil;
+import org.apache.storm.utils.ConfigUtils;
+import org.apache.storm.utils.Utils;
+import org.json.simple.JSONValue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+public class Heartbeats {
+ private static final Logger LOG =
LoggerFactory.getLogger(Heartbeats.class);
+
+ public static void main(String[] args) throws Exception {
+ if (args.length < 2) {
+ throw new IllegalArgumentException("You should provide both
command and path.");
+ }
+
+ String command = args[0];
+ String path = args[1];
+
+ Map<String, Object> conf = ConfigUtils.readStormConfig();
+ IStateStorage cluster = ClusterUtils.mkStateStorage(conf, conf,
null, new ClusterStateContext());
+
+ System.out.println("Command: [" + command + "]");
+
+ switch (command) {
+ case "list":
+ handleListCommand(cluster, path);
+ break;
+
+ case "get":
+ handleGetCommand(cluster, path);
+ break;
+
+ default:
+ LOG.info("Usage: heartbeats [list|get] path");
+ }
+
+ try {
+ cluster.close();
+ } catch (Exception e) {
+ LOG.info("Caught exception: {} on close.", e);
+ }
+
+ // force process to be terminated
+ System.exit(0);
+ }
+
+ private static void handleListCommand(IStateStorage cluster, String
path) {
+ String message =
Joiner.on("\n").join(cluster.get_worker_hb_children(path, false));
+ LOG.info("list {}:\n{}\n", path, message);
+ }
+
+ private static void handleGetCommand(IStateStorage cluster, String
path) {
+ String message;
+ byte[] hb = cluster.get_worker_hb(path, false);
+ if (hb != null) {
+ Map<String, Object> heartbeatMap =
StatsUtil.convertZkWorkerHb(Utils.deserialize(hb,
ClusterWorkerHeartbeat.class));
+ message = JSONValue.toJSONString(heartbeatMap);
+ } else {
+ message = "Nothing";
--- End diff --
can we changes this to "No Heartbeats found"
> port org.apache.storm.command.heartbeats.clj to Java
> ----------------------------------------------------
>
> Key: STORM-2010
> URL: https://issues.apache.org/jira/browse/STORM-2010
> Project: Apache Storm
> Issue Type: New Feature
> Components: storm-core
> Reporter: Jungtaek Lim
> Assignee: Jungtaek Lim
> Labels: java-migration, jstorm-merger
>
> heartbeats command is missing for storm-core java migration plan. Adding this
> to the plan, and do actual work.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)