You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by sr...@apache.org on 2015/09/21 19:40:50 UTC
[05/24] storm git commit: Debug options support for components
Debug options support for components
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/d1e5ec98
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/d1e5ec98
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/d1e5ec98
Branch: refs/heads/master
Commit: d1e5ec98732e77409e6303b1ec3708a44e6a7bb9
Parents: f8c4c5b
Author: Arun Mahadevan <ai...@hortonworks.com>
Authored: Fri Aug 7 14:28:14 2015 +0530
Committer: Arun Mahadevan <ai...@hortonworks.com>
Committed: Mon Aug 10 14:22:00 2015 +0530
----------------------------------------------------------------------
storm-core/src/clj/backtype/storm/ui/core.clj | 15 ++++++++-
storm-core/src/ui/public/component.html | 7 +++++
storm-core/src/ui/public/js/script.js | 32 ++++++++++++++++++++
.../templates/component-page-template.html | 7 +++++
4 files changed, 60 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/d1e5ec98/storm-core/src/clj/backtype/storm/ui/core.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/ui/core.clj b/storm-core/src/clj/backtype/storm/ui/core.clj
index ea7b048..1b5e5b4 100644
--- a/storm-core/src/clj/backtype/storm/ui/core.clj
+++ b/storm-core/src/clj/backtype/storm/ui/core.clj
@@ -947,6 +947,7 @@
"window" window
"componentType" (name type)
"windowHint" (window-hint window)
+ "debug" (.is_debug summ)
"eventLogLink" (event-log-link topology-id summ topology component secure?)}
spec errors))))
@@ -1040,7 +1041,19 @@
name (.get_name tplg)
enable? (= "enable" action)]
(.debug nimbus name enable?)
- (log-message "Debug topology '" name "' [" action "]")))
+ (log-message "Debug topology [" name "] action [" action "]")))
+ (json-response (topology-op-response id (str "debug/" action)) (m "callback")))
+ (POST "/api/v1/topology/:id/component/:component/debug/:action" [:as {:keys [cookies servlet-request]} id component action & m]
+ (assert-authorized-user servlet-request "debug" (topology-config id))
+ (with-nimbus nimbus
+ (let [tplg (->> (doto
+ (GetInfoOptions.)
+ (.set_num_err_choice NumErrorsChoice/NONE))
+ (.getTopologyInfoWithOpts ^Nimbus$Client nimbus id))
+ name (.get_name tplg)
+ enable? (= "enable" action)]
+ (.debug nimbus name enable?) ;; TODO: include component id in the nimbus api
+ (log-message "Debug topology [" name "] component [" component "] action [" action "]")))
(json-response (topology-op-response id (str "debug/" action)) (m "callback")))
(POST "/api/v1/topology/:id/rebalance/:wait-time" [:as {:keys [cookies servlet-request]} id wait-time & m]
(assert-authorized-user servlet-request "rebalance" (topology-config id))
http://git-wip-us.apache.org/repos/asf/storm/blob/d1e5ec98/storm-core/src/ui/public/component.html
----------------------------------------------------------------------
diff --git a/storm-core/src/ui/public/component.html b/storm-core/src/ui/public/component.html
index a42c1a7..3b4b10d 100644
--- a/storm-core/src/ui/public/component.html
+++ b/storm-core/src/ui/public/component.html
@@ -46,6 +46,9 @@
<div id="component-summary" class="col-md-12"></div>
</div>
<div class="row">
+ <div id="component-actions" class="col-md-12"></div>
+ </div>
+ <div class="row">
<div id="component-stats-detail" class="col-md-12"></div>
</div>
<div class="row">
@@ -112,6 +115,8 @@ $(document).ready(function() {
});
var componentSummary = $("#component-summary");
+ var componentActions = $("#component-actions");
+ var buttonJsonData = componentActionJson(response["encodedTopologyId"], response["encodedId"], response["id"], response["debug"]);
var componentStatsDetail = $("#component-stats-detail")
var inputStats = $("#component-input-stats");
var outputStats = $("#component-output-stats");
@@ -119,6 +124,7 @@ $(document).ready(function() {
var componentErrors = $("#component-errors");
$.get("/templates/component-page-template.html", function(template) {
componentSummary.append(Mustache.render($(template).filter("#component-summary-template").html(),response));
+ componentActions.append(Mustache.render($(template).filter("#component-actions-template").html(),buttonJsonData));
if(response["componentType"] == "spout") {
componentStatsDetail.append(Mustache.render($(template).filter("#spout-stats-detail-template").html(),response));
//window, emitted, transferred, complete latency, acked, failed
@@ -197,6 +203,7 @@ $(document).ready(function() {
}
}
$('#component-summary [data-toggle="tooltip"]').tooltip();
+ $('#component-actions [data-toggle="tooltip"]').tooltip();
$('#component-stats-detail [data-toggle="tooltip"]').tooltip();
$('#component-input-stats [data-toggle="tooltip"]').tooltip();
$('#component-output-stats [data-toggle="tooltip"]').tooltip();
http://git-wip-us.apache.org/repos/asf/storm/blob/d1e5ec98/storm-core/src/ui/public/js/script.js
----------------------------------------------------------------------
diff --git a/storm-core/src/ui/public/js/script.js b/storm-core/src/ui/public/js/script.js
index fda17f2..2173b43 100644
--- a/storm-core/src/ui/public/js/script.js
+++ b/storm-core/src/ui/public/js/script.js
@@ -81,6 +81,28 @@ function ensureInt(n) {
return isInt;
}
+function confirmComponentAction(topologyId, componentId, componentName, action, actionText) {
+ var opts = {
+ type:'POST',
+ url:'/api/v1/topology/' + topologyId + '/component/' + componentId + '/' + action
+ };
+ if (actionText === undefined) {
+ actionText = action;
+ }
+ if (!confirm('Do you really want to ' + actionText + ' component "' + componentName + '"?')) {
+ return false;
+ }
+
+ $("input[type=button]").attr("disabled", "disabled");
+ $.ajax(opts).always(function () {
+ window.location.reload();
+ }).fail(function () {
+ alert("Error while communicating with Nimbus.");
+ });
+
+ return false;
+}
+
function confirmAction(id, name, action, wait, defaultWait, actionText) {
var opts = {
type:'POST',
@@ -164,6 +186,16 @@ function topologyActionJson(id, encodedId, name, status, msgTimeout, debug) {
return jsonData;
}
+function componentActionJson(encodedTopologyId, encodedId, componentName, debug) {
+ var jsonData = {};
+ jsonData["encodedTopologyId"] = encodedTopologyId;
+ jsonData["encodedId"] = encodedId;
+ jsonData["componentName"] = componentName;
+ jsonData["startDebugStatus"] = (!debug) ? "enabled" : "disabled";
+ jsonData["stopDebugStatus"] = debug ? "enabled" : "disabled";
+ return jsonData;
+}
+
function topologyActionButton(id,name,status,actionLabel,command,wait,defaultWait) {
var buttonData = {};
buttonData["buttonStatus"] = status ;
http://git-wip-us.apache.org/repos/asf/storm/blob/d1e5ec98/storm-core/src/ui/public/templates/component-page-template.html
----------------------------------------------------------------------
diff --git a/storm-core/src/ui/public/templates/component-page-template.html b/storm-core/src/ui/public/templates/component-page-template.html
index 7bf9026..01b19ce 100644
--- a/storm-core/src/ui/public/templates/component-page-template.html
+++ b/storm-core/src/ui/public/templates/component-page-template.html
@@ -492,3 +492,10 @@
</tbody>
</table>
</script>
+<script id="component-actions-template" type="text/html">
+ <h2>Component actions</h2>
+ <p id="component-actions">
+ <input {{startDebugStatus}} onclick="confirmComponentAction('{{encodedTopologyId}}', '{{encodedId}}', '{{componentName}}', 'debug/enable', 'debug')" type="button" value="Debug" class="btn btn-default">
+ <input {{stopDebugStatus}} onclick="confirmComponentAction('{{encodedTopologyId}}', '{{encodedId}}', '{{componentName}}', 'debug/disable', 'stop debugging')" type="button" value="Stop Debug" class="btn btn-default">
+ </p>
+</script>