You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by GitBox <gi...@apache.org> on 2018/06/27 00:07:45 UTC

[GitHub] kramasamy closed pull request #2860: Add component config in heron UI and Tracker

kramasamy closed pull request #2860: Add component config in heron UI and Tracker
URL: https://github.com/apache/incubator-heron/pull/2860
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/heron/tools/tracker/src/python/tracker.py b/heron/tools/tracker/src/python/tracker.py
index c03621aa28..4fb6e87cf8 100644
--- a/heron/tools/tracker/src/python/tracker.py
+++ b/heron/tools/tracker/src/python/tracker.py
@@ -430,6 +430,7 @@ def extract_physical_plan(self, topology):
         "spouts": {},
         "bolts": {},
         "config": {},
+        "components": {}
     }
 
     if not topology.physical_plan:
@@ -447,12 +448,21 @@ def extract_physical_plan(self, topology):
     # Configs
     if topology.physical_plan.topology.topology_config:
       physicalPlan["config"] = convert_pb_kvs(topology.physical_plan.topology.topology_config.kvs)
+
     for spout in spouts:
       spout_name = spout.comp.name
       physicalPlan["spouts"][spout_name] = []
+      if spout_name not in physicalPlan["components"]:
+        physicalPlan["components"][spout_name] = {
+            "config": convert_pb_kvs(spout.comp.config.kvs)
+        }
     for bolt in bolts:
       bolt_name = bolt.comp.name
       physicalPlan["bolts"][bolt_name] = []
+      if bolt_name not in physicalPlan["components"]:
+        physicalPlan["components"][bolt_name] = {
+            "config": convert_pb_kvs(bolt.comp.config.kvs)
+        }
 
     for stmgr in stmgrs:
       host = stmgr.host_name
diff --git a/heron/tools/tracker/tests/python/BUILD b/heron/tools/tracker/tests/python/BUILD
index 2c752e1c04..26d1bd845f 100644
--- a/heron/tools/tracker/tests/python/BUILD
+++ b/heron/tools/tracker/tests/python/BUILD
@@ -58,7 +58,7 @@ pex_pytest(
 
 pex_pytest(
     name = "tracker_unittest",
-    srcs = ["tracker_unittest.py"],
+    srcs = ["tracker_unittest.py", "mock_proto.py"],
     deps = [
         "//heron/tools/tracker/src/python:tracker-py",
         "//heron/proto:proto-py",
diff --git a/heron/tools/tracker/tests/python/tracker_unittest.py b/heron/tools/tracker/tests/python/tracker_unittest.py
index 4a4ba67eaa..136c6b96cd 100644
--- a/heron/tools/tracker/tests/python/tracker_unittest.py
+++ b/heron/tools/tracker/tests/python/tracker_unittest.py
@@ -8,6 +8,7 @@
 from heron.statemgrs.src.python import statemanagerfactory
 from heron.tools.tracker.src.python.topology import Topology
 from heron.tools.tracker.src.python.tracker import Tracker
+from mock_proto import MockProto
 
 class TrackerTest(unittest.TestCase):
   def setUp(self):
@@ -215,3 +216,21 @@ def test_remove_topology(self):
     self.tracker.removeTopology('top_name4', 'mock_name2')
     self.assertItemsEqual([self.topology3, self.topology5],
                           self.tracker.topologies)
+
+  def test_extract_physical_plan(self):
+    # Create topology
+    pb_pplan = MockProto().create_mock_simple_physical_plan()
+    topology = Topology('topology_name', 'state_manager')
+    topology.set_physical_plan(pb_pplan)
+    # Extract physical plan
+    pplan = self.tracker.extract_physical_plan(topology)
+    # Mock topology doesn't have topology config and instances
+    self.assertEqual(pplan['config'], {})
+    self.assertEqual(pplan['bolts'], {'mock_bolt': []})
+    self.assertEqual(pplan['spouts'], {'mock_spout': []})
+    self.assertEqual(pplan['components']['mock_bolt']['config'],
+                     {'topology.component.parallelism': '1'})
+    self.assertEqual(pplan['components']['mock_spout']['config'],
+                     {'topology.component.parallelism': '1'})
+    self.assertEqual(pplan['instances'], {})
+    self.assertEqual(pplan['stmgrs'], {})
diff --git a/heron/tools/ui/resources/static/js/config.js b/heron/tools/ui/resources/static/js/config.js
index a0b19b5dab..87a0409d4b 100644
--- a/heron/tools/ui/resources/static/js/config.js
+++ b/heron/tools/ui/resources/static/js/config.js
@@ -2,9 +2,12 @@
 
 var ConfigTable = React.createClass({
   getInitialState: function() {
-    return {'config': {}};
+    return {
+      'config': {},
+      'component_config': {}
+    };
   },
-  getTopologyConfig: function() {
+  getConfig: function() {
     urlTokens = [  this.props.baseUrl,
                    'topologies',
                    this.props.cluster,
@@ -17,9 +20,23 @@ var ConfigTable = React.createClass({
       url: fetchUrl,
       dataType:  'json',
       success: function(response) {
-        if (response.hasOwnProperty('result')
-            && response.result.hasOwnProperty('config')) {
-          this.setState({config: response.result.config});
+        if (response.hasOwnProperty('result')) {
+          // Topology config
+          var config = {};
+          if (response.result.hasOwnProperty('config')) {
+            config = response.result.config;
+          }
+          // Component config
+          var componentConfig = {};
+          if (response.result.hasOwnProperty('components')) {
+            for (var component in response.result.components) {
+              componentConfig[component] = response.result.components[component].config;
+            }
+          }
+          this.setState({
+            config: config,
+            component_config: componentConfig
+          });
         }
       }.bind(this),
 
@@ -80,27 +97,43 @@ var ConfigTable = React.createClass({
   },
 
   componentWillMount: function () {
-    this.getTopologyConfig();
+    this.getConfig();
   },
   componentDidUpdate: function(prevProps, prevState) {
     if (prevProps.topology != this.props.topology) {
-      this.getTopologyConfig();
+      this.getConfig();
     }
   },
   render: function() {
     var configData = this.state.config;
+    var componentConfigData = this.state.component_config;
     var headings = ['Property', 'Value'];
     var title = 'Configuration';
     var rows = [];
     var self = this;
+    // Fill topology config data
     for (property in configData) {
       var configValue = configData[property];
-      if (typeof configValue == 'string') {
-        rows.push([property, configValue]);
-      } else {
+      if (typeof configValue == 'object') {
         rows.push([property, JSON.parse(configValue.value)]);
+      } else {
+        rows.push([property, configValue]);
       }
     }
+    // Fill component config data
+    for (component in componentConfigData) {
+      data = componentConfigData[component];
+      for (property in data) {
+        var key = '[' + component + '] ' + property;
+        var configValue = data[property];
+        if (typeof configValue == 'object') {
+          rows.push([key, JSON.parse(configValue.value)]);
+        } else {
+          rows.push([key, configValue]);
+        }
+      }
+    }
+
     var tableContent = ( 
       <tbody>{
         rows.map(function(row) {


 

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