You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2016/02/24 18:33:35 UTC
[3/6] storm git commit: STORM-1265: port
backtype.storm.command.monitor to java
STORM-1265: port backtype.storm.command.monitor to java
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/93b314cf
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/93b314cf
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/93b314cf
Branch: refs/heads/master
Commit: 93b314cf6e092e42c6cd6116618bfce94797c5cf
Parents: 8aaa838
Author: Abhishek Agarwal <ab...@inmobi.com>
Authored: Mon Feb 22 16:39:10 2016 +0530
Committer: Abhishek Agarwal <ab...@inmobi.com>
Committed: Mon Feb 22 16:39:10 2016 +0530
----------------------------------------------------------------------
.../clj/org/apache/storm/command/monitor.clj | 37 -----------
.../jvm/org/apache/storm/command/Monitor.java | 65 ++++++++++++++++++++
2 files changed, 65 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/93b314cf/storm-core/src/clj/org/apache/storm/command/monitor.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/org/apache/storm/command/monitor.clj b/storm-core/src/clj/org/apache/storm/command/monitor.clj
deleted file mode 100644
index 4ec49af..0000000
--- a/storm-core/src/clj/org/apache/storm/command/monitor.clj
+++ /dev/null
@@ -1,37 +0,0 @@
-;; 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.
-(ns org.apache.storm.command.monitor
- (:use [clojure.tools.cli :only [cli]])
- (:use [org.apache.storm.internal.thrift :only [with-configured-nimbus-connection]])
- (:import [org.apache.storm.utils Monitor])
- (:gen-class)
- )
-
-(defn -main [& args]
- (let [[{interval :interval component :component stream :stream watch :watch} [name] _]
- (cli args ["-i" "--interval" :default 4 :parse-fn #(Integer/parseInt %)]
- ["-m" "--component" :default nil]
- ["-s" "--stream" :default "default"]
- ["-w" "--watch" :default "emitted"])
- mon (Monitor.)]
- (if interval (.set_interval mon interval))
- (if name (.set_topology mon name))
- (if component (.set_component mon component))
- (if stream (.set_stream mon stream))
- (if watch (.set_watch mon watch))
- (with-configured-nimbus-connection nimbus
- (.metrics mon nimbus)
- )))
http://git-wip-us.apache.org/repos/asf/storm/blob/93b314cf/storm-core/src/jvm/org/apache/storm/command/Monitor.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/org/apache/storm/command/Monitor.java b/storm-core/src/jvm/org/apache/storm/command/Monitor.java
new file mode 100644
index 0000000..68a65ea
--- /dev/null
+++ b/storm-core/src/jvm/org/apache/storm/command/Monitor.java
@@ -0,0 +1,65 @@
+/**
+ * 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 org.apache.storm.generated.Nimbus;
+import org.apache.storm.utils.NimbusClient;
+
+import java.util.Map;
+
+public class Monitor {
+
+ public static void main(String[] args) throws Exception {
+ Map<String, Object> cl = CLI.opt("i", "interval", 4, CLI.AS_INT)
+ .opt("m", "component", null)
+ .opt("s", "stream", "default")
+ .opt("w", "watch", "emitted")
+ .arg("topologyName", CLI.FIRST_WINS)
+ .parse(args);
+ final org.apache.storm.utils.Monitor monitor = new org.apache.storm.utils.Monitor();
+ Integer interval = (Integer) cl.get("i");
+ String component = (String) cl.get("m");
+ String stream = (String) cl.get("s");
+ String watch = (String) cl.get("w");
+ String topologyName = (String) cl.get("topologyName");
+
+ if (null != interval) {
+ monitor.set_interval(interval);
+ }
+ if (null != component) {
+ monitor.set_component(component);
+ }
+ if (null != stream) {
+ monitor.set_stream(stream);
+ }
+ if (null != watch) {
+ monitor.set_watch(watch);
+ }
+ if (null != topologyName) {
+ monitor.set_topology(topologyName);
+ }
+
+ NimbusClient.withConfiguredClient(new NimbusClient.WithNimbus() {
+ @Override
+ public void run(Nimbus.Client nimbus) throws Exception {
+ monitor.metrics(nimbus);
+ }
+ });
+ }
+}