You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2014/11/07 18:29:54 UTC

[3/3] ambari git commit: AMBARI-8207. Configs: JavaScript error on save configs for any client-only service (alexantonenko)

AMBARI-8207. Configs: JavaScript error on save configs for any client-only service (alexantonenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4aae5e4c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4aae5e4c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4aae5e4c

Branch: refs/heads/trunk
Commit: 4aae5e4c8e4b1f632065b6fbadafc47ef2d30638
Parents: b1c4853
Author: Alex Antonenko <hi...@gmail.com>
Authored: Fri Nov 7 17:59:21 2014 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Fri Nov 7 19:29:44 2014 +0200

----------------------------------------------------------------------
 .../app/views/common/quick_view_link_view.js    |   8 +-
 .../test/views/common/quick_link_view_test.js   | 395 +++++++++++++++++++
 2 files changed, 400 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4aae5e4c/ambari-web/app/views/common/quick_view_link_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/quick_view_link_view.js b/ambari-web/app/views/common/quick_view_link_view.js
index 1bb5cb0..4123c8f 100644
--- a/ambari-web/app/views/common/quick_view_link_view.js
+++ b/ambari-web/app/views/common/quick_view_link_view.js
@@ -190,8 +190,8 @@ App.QuickViewLinks = Em.View.extend({
    * @method setHost
    */
   setHost: function(response, serviceName) {
-    if (App.singleNodeInstall) {
-      return [App.singleNodeAlias];
+    if (App.get('singleNodeInstall')) {
+      return [App.get('singleNodeAlias')];
     }
     var hosts = [];
     switch (serviceName) {
@@ -281,7 +281,9 @@ App.QuickViewLinks = Em.View.extend({
         hosts[0] = this.findComponentHost(response.items, "STORM_UI_SERVER");
         break;
       default:
-        hosts[0] = this.findComponentHost(response.items, this.get('content.hostComponents') && this.get('content.hostComponents').findProperty('isMaster', true).get('componentName'));
+        if (App.StackService.find().findProperty('serviceName', serviceName).get('hasMaster')) {
+          hosts[0] = this.findComponentHost(response.items, this.get('content.hostComponents') && this.get('content.hostComponents').findProperty('isMaster', true).get('componentName'));
+        }
         break;
     }
     return hosts;

http://git-wip-us.apache.org/repos/asf/ambari/blob/4aae5e4c/ambari-web/test/views/common/quick_link_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/quick_link_view_test.js b/ambari-web/test/views/common/quick_link_view_test.js
index f6b621a..fedbd9f 100644
--- a/ambari-web/test/views/common/quick_link_view_test.js
+++ b/ambari-web/test/views/common/quick_link_view_test.js
@@ -115,4 +115,399 @@ describe('App.QuickViewLinks', function () {
       })
     },this);
   });
+
+  describe('#setHost', function () {
+
+    var quickViewLinks = App.QuickViewLinks.create({
+        content: Em.Object.create()
+      }),
+      cases = [
+        {
+          singleNodeInstall: true,
+          hosts: ['host0'],
+          title: 'single node install'
+        },
+        {
+          response: {
+            items: [
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'JOBTRACKER'
+                    }
+                  }
+                ],
+                Hosts: {
+                  public_host_name: 'host1'
+                }
+              },
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'HISTORYSERVER'
+                    }
+                  }
+                ],
+                Hosts: {
+                  public_host_name: 'host2'
+                }
+              }
+            ]
+          },
+          serviceName: 'MAPREDUCE',
+          hosts: ['host1', 'host2']
+        },
+        {
+          response: {
+            items: [
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'STORM_UI_SERVER'
+                    }
+                  }
+                ],
+                Hosts: {
+                  public_host_name: 'host3'
+                }
+              }
+            ]
+          },
+          serviceName: 'STORM',
+          hosts: ['host3']
+        },
+        {
+          serviceName: 'PIG',
+          hosts: [],
+          title: 'client only service'
+        },
+        {
+          response: {
+            items: [
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'ZOOKEEPER_SERVER'
+                    }
+                  }
+                ],
+                Hosts: {
+                  public_host_name: 'host4'
+                }
+              }
+            ]
+          },
+          serviceName: 'ZOOKEEPER',
+          hosts: ['host4'],
+          setup: function () {
+            quickViewLinks.set('content', {
+              hostComponents: [
+                Em.Object.create({
+                  componentName: 'ZOOKEEPER_SERVER',
+                  isMaster: true
+                })
+              ]
+            });
+          },
+          title: 'service with master component, except HDFS, HBase, MapReduce, YARN and Storm'
+        },
+        {
+          response: {
+            items: [
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'NAMENODE'
+                    }
+                  }
+                ],
+                Hosts: {
+                  public_host_name: 'host5'
+                }
+              }
+            ]
+          },
+          serviceName: 'HDFS',
+          hosts: ['host5'],
+          setup: function () {
+            quickViewLinks.set('content', {
+              snameNode: true
+            });
+          },
+          title: 'HDFS, HA disabled'
+        },
+        {
+          response: {
+            items: [
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'NAMENODE'
+                    }
+                  }
+                ],
+                Hosts: {
+                  host_name: 'host6',
+                  public_host_name: 'host6'
+                }
+              },
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'NAMENODE'
+                    }
+                  }
+                ],
+                Hosts: {
+                  host_name: 'host7',
+                  public_host_name: 'host7'
+                }
+              },
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'NAMENODE'
+                    }
+                  }
+                ],
+                Hosts: {
+                  host_name: 'host8',
+                  public_host_name: 'host8'
+                }
+              }
+            ]
+          },
+          serviceName: 'HDFS',
+          multipleMasters: true,
+          hosts: ['host6', 'host7', 'host8'],
+          setup: function () {
+            quickViewLinks.set('content', {
+              hostComponents: [
+                Em.Object.create({
+                  componentName: 'NAMENODE',
+                  hostName: 'host6'
+                }),
+                Em.Object.create({
+                  componentName: 'NAMENODE',
+                  hostName: 'host7'
+                }),
+                Em.Object.create({
+                  componentName: 'NAMENODE',
+                  hostName: 'host8'
+                })
+              ],
+              activeNameNode: {
+                hostName: 'host6'
+              },
+              standbyNameNode: {
+                hostName: 'host7'
+              },
+              standbyNameNode2: {
+                hostName: 'host8'
+              }
+            });
+          },
+          title: 'HDFS, HA enabled'
+        },
+        {
+          response: {
+            items: [
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'RESOURCEMANAGER'
+                    }
+                  }
+                ],
+                Hosts: {
+                  public_host_name: 'host9'
+                }
+              }
+            ]
+          },
+          serviceName: 'YARN',
+          hosts: ['host9'],
+          title: 'YARN, HA disabled'
+        },
+        {
+          response: {
+            items: [
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'RESOURCEMANAGER'
+                    }
+                  }
+                ],
+                Hosts: {
+                  host_name: 'host10',
+                  public_host_name: 'host10'
+                }
+              },
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'RESOURCEMANAGER'
+                    }
+                  }
+                ],
+                Hosts: {
+                  host_name: 'host11',
+                  public_host_name: 'host11'
+                }
+              },
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'RESOURCEMANAGER'
+                    }
+                  }
+                ],
+                Hosts: {
+                  host_name: 'host12',
+                  public_host_name: 'host12'
+                }
+              }
+            ]
+          },
+          serviceName: 'YARN',
+          multipleMasters: true,
+          hosts: ['host10', 'host11', 'host12'],
+          setup: function () {
+            quickViewLinks.set('content', {
+              hostComponents: [
+                Em.Object.create({
+                  componentName: 'RESOURCEMANAGER',
+                  hostName: 'host10'
+                }),
+                Em.Object.create({
+                  componentName: 'RESOURCEMANAGER',
+                  hostName: 'host11'
+                }),
+                Em.Object.create({
+                  componentName: 'RESOURCEMANAGER',
+                  hostName: 'host12'
+                })
+              ]
+            });
+          },
+          title: 'YARN, HA enabled'
+        },
+        {
+          response: {
+            items: [
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'HBASE_MASTER'
+                    },
+                    metrics: {
+                      hbase: {
+                        master: {
+                          IsActiveMaster: true
+                        }
+                      }
+                    }
+                  }
+                ],
+                Hosts: {
+                  host_name: 'host13',
+                  public_host_name: 'host13'
+                }
+              },
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'HBASE_MASTER'
+                    },
+                    metrics: {
+                      hbase: {
+                        master: {
+                          IsActiveMaster: false
+                        }
+                      }
+                    }
+                  }
+                ],
+                Hosts: {
+                  host_name: 'host14',
+                  public_host_name: 'host14'
+                }
+              },
+              {
+                host_components: [
+                  {
+                    HostRoles: {
+                      component_name: 'HBASE_MASTER'
+                    }
+                  }
+                ],
+                Hosts: {
+                  host_name: 'host15',
+                  public_host_name: 'host15'
+                }
+              }
+            ]
+          },
+          serviceName: 'HBASE',
+          multipleMasters: true,
+          hosts: ['host13', 'host14', 'host15']
+        }
+      ];
+
+    before(function () {
+      sinon.stub(App.StackService, 'find', function () {
+        return [
+          Em.Object.create({
+            serviceName: 'ZOOKEEPER',
+            hasMaster: true
+          }),
+          Em.Object.create({
+            serviceName: 'PIG',
+            hasMaster: false
+          })
+        ];
+      })
+    });
+
+    after(function () {
+      App.StackService.find.restore();
+    });
+
+    afterEach(function () {
+      App.get.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(item.title || item.serviceName, function () {
+        if (item.setup) {
+          item.setup();
+        }
+        sinon.stub(App, 'get').withArgs('singleNodeInstall').returns(item.singleNodeInstall).
+          withArgs('singleNodeAlias').returns('host0').
+          withArgs('isRMHaEnabled').returns(item.multipleMasters);
+        if (item.multipleMasters) {
+          expect(quickViewLinks.setHost(item.response, item.serviceName).mapProperty('publicHostName')).to.eql(item.hosts);
+        } else {
+          expect(quickViewLinks.setHost(item.response, item.serviceName)).to.eql(item.hosts);
+        }
+      });
+    });
+
+  });
+
 });