ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [34/40] ambari git commit: AMBARI-14927. Log Search: Add Host Components Logs tab to Host Details page (alexantonenko)
Date Fri, 05 Feb 2016 21:56:49 GMT
AMBARI-14927. Log Search: Add Host Components Logs tab to Host Details page
 (alexantonenko)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: b567ca441c213c816019dc5a45884f69a286f54c
Parents: 3a2add5
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Fri Feb 5 18:30:24 2016 +0200
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Fri Feb 5 18:30:24 2016 +0200

----------------------------------------------------------------------
 .../app/controllers/global/update_controller.js |   4 +-
 ambari-web/app/messages.js                      |   3 +
 ambari-web/app/routes/main.js                   |  11 ++
 ambari-web/app/styles/application.less          |   3 +-
 ambari-web/app/templates/main/host/logs.hbs     |  62 ++++++++
 ambari-web/app/views.js                         |   1 +
 ambari-web/app/views/main/host/logs_view.js     | 147 +++++++++++++++++++
 ambari-web/app/views/main/host/menu.js          |  11 +-
 ambari-web/test/views/main/host/menu_test.js    |  20 ++-
 9 files changed, 257 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b567ca44/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index 0a5d913..0168398 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -223,7 +223,7 @@ App.UpdateController = Em.Controller.extend({
     }
     else {
       if (App.router.get('currentState.parentState.name') == 'hostDetails') {
-        hostDetailsFilter = App.router.get('location.lastSetURL').match(/\/hosts\/(.*)\/(summary|configs|alerts|stackVersions)/)[1];
+        hostDetailsFilter = App.router.get('location.lastSetURL').match(/\/hosts\/(.*)\/(summary|configs|alerts|stackVersions|logs)/)[1];
         App.updater.updateInterval('updateHost', App.get('componentsUpdateInterval'));
         //if host details page opened then request info only of one displayed host
         this.get('queryParams').set('Hosts', [
@@ -579,7 +579,7 @@ App.UpdateController = Em.Controller.extend({
       complete: callback
     });
   },
-  
+
   updateUpgradeState: function (callback) {
     var currentStateName = App.get('router.currentState.name'),
       parentStateName = App.get('router.currentState.parentState.name'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/b567ca44/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 8d1f6f1..a8b5db6 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -312,6 +312,7 @@ Em.I18n.translations = {
   'common.filters': 'Filters',
   'common.keywords': 'Keywods',
   'common.levels': 'Levels',
+  'common.extension': 'Extension',
 
   'models.alert_instance.tiggered.verbose': "Occurred on {0} <br> Checked on {1}",
   'models.alert_definition.triggered.verbose': "Occurred on {0}",
@@ -2280,6 +2281,8 @@ Em.I18n.translations = {
 
   'hosts.host.serviceNotAvailable': 'Service not available on this host',
 
+  'hosts.host.menu.logs': 'Logs',
+
   'hosts.host.menu.stackVersions': 'Versions',
   'hosts.host.stackVersions.table.allVersions': 'All Versions',
   'hosts.host.stackVersions.table.allNames': 'All Names',

http://git-wip-us.apache.org/repos/asf/ambari/blob/b567ca44/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index bd66945..cbaf34d 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -264,6 +264,17 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
         }
       }),
 
+      logs: Em.Route.extend({
+        route: '/logs',
+        connectOutlets: function (router, context) {
+          if (App.get('supports.logSearch')) {
+            router.get('mainHostDetailsController').connectOutlet('mainHostLogs')
+          } else {
+            router.transitionTo('summary');
+          }
+        }
+      }),
+
       hostNavigate: function (router, event) {
         var parent = event.view._parentView;
         parent.deactivateChildViews();

http://git-wip-us.apache.org/repos/asf/ambari/blob/b567ca44/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index ce10a98..a1969db 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -3700,7 +3700,8 @@ table.graphs {
       }
     }
   }
-  .host-tab-content {
+  .host-tab-content,
+  .logs-tab-content {
     margin-top: 20px;
     .table thead {
       background: none repeat scroll 0 0 #F8F8F8;

http://git-wip-us.apache.org/repos/asf/ambari/blob/b567ca44/ambari-web/app/templates/main/host/logs.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/logs.hbs b/ambari-web/app/templates/main/host/logs.hbs
new file mode 100644
index 0000000..000b4aa
--- /dev/null
+++ b/ambari-web/app/templates/main/host/logs.hbs
@@ -0,0 +1,62 @@
+{{!
+* 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.
+}}
+
+<table class="table advanced-header-table table-bordered table-striped">
+  <thead>
+    {{#view view.sortView classNames="label-row" contentBinding="view.filteredContent"}}
+      {{view view.parentView.serviceNameSort classNames="first"}}
+      {{view view.parentView.componentNameSort}}
+      {{view view.parentView.fileExtensionsSort}}
+    {{/view}}
+    <tr class="filter-row">
+      <th class="first service-name-filter">{{view view.serviceNameFilterView}}</th>
+      <th class="component-name-filter">{{view view.componentNameFilterView}}</th>
+      <th class="file-extension-filter">{{view view.fileExtensionsFilter}}</th>
+    </tr>
+  </thead>
+  <tbody>
+    {{#if view.pageContent}}
+      {{#each row in view.pageContent}}
+      <tr>
+        <td>{{row.serviceName}}</td>
+        <td>{{row.componentName}}</td>
+        <td>
+          <a {{action openLogFile row target="view"}} href="#">{{row.fileName}}</a>
+        </td>
+      </tr>
+      {{/each}}
+    {{/if}}
+  </tbody>
+</table>
+
+<div class="page-bar">
+  <div class="filtered-info span4">
+    {{#if view.showFilteredContent}}
+      <label>{{view.filteredContentInfo}} - <a {{action clearFilters target="view"}}
+        href="#">{{t tableView.filters.clearAllFilters}}</a></label>
+    {{/if}}
+  </div>
+  <div class="items-on-page">
+    <label>{{t common.show}}: {{view view.rowsPerPageSelectView selectionBinding="view.parentView.displayLength"}}</label>
+  </div>
+  <div class="info">{{view.paginationInfo}}</div>
+  <div class="paging_two_button">
+    {{view view.paginationLeft}}
+    {{view view.paginationRight}}
+  </div>
+</div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b567ca44/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index 4404a2a..2224393 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -122,6 +122,7 @@ require('views/main/host/details/host_component_views/datanode_view');
 require('views/main/host/details/host_component_views/nodemanager_view');
 require('views/main/host/details/host_component_views/regionserver_view');
 require('views/main/host/details/host_component_views/tasktracker_view');
+require('views/main/host/logs_view');
 require('views/main/host/menu');
 require('views/main/host/summary');
 require('views/main/host/configs');

http://git-wip-us.apache.org/repos/asf/ambari/blob/b567ca44/ambari-web/app/views/main/host/logs_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/logs_view.js b/ambari-web/app/views/main/host/logs_view.js
new file mode 100644
index 0000000..dfe00e4
--- /dev/null
+++ b/ambari-web/app/views/main/host/logs_view.js
@@ -0,0 +1,147 @@
+/**
+ * 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.
+ */
+
+
+var App = require('app');
+var filters = require('views/common/filter_view');
+var sort = require('views/common/sort_view');
+
+App.MainHostLogsView = App.TableView.extend({
+  templateName: require('templates/main/host/logs'),
+
+  classNames: ['logs-tab-content'],
+
+  /**
+   * @type {Ember.Object}
+   */
+  host: Em.computed.alias('App.router.mainHostDetailsController.content'),
+
+  content: function() {
+    return [
+      Em.Object.create({
+        serviceName: 'HDFS',
+        componentName: 'DATANODE',
+        fileExtension: '.log',
+        fileName: 'HDFS_DATANODE.log'
+      })
+    ];
+  }.property(),
+  /**
+   * @type {Ember.View}
+   */
+  sortView: sort.wrapperView,
+
+  serviceNameSort: sort.fieldView.extend({
+    column: 1,
+    name: 'serviceName',
+    displayName: Em.I18n.t('common.service')
+  }),
+
+  componentNameSort: sort.fieldView.extend({
+    column: 2,
+    name: 'componentName',
+    displayName: Em.I18n.t('common.component')
+  }),
+
+  fileExtensionsSort: sort.fieldView.extend({
+    column: 3,
+    name: 'extension',
+    displayName: Em.I18n.t('common.extension')
+  }),
+
+  serviceNameFilterView: filters.createSelectView({
+    column: 1,
+    fieldType: 'filter-input-width',
+    content: function() {
+      return [{
+        value: '',
+        label: Em.I18n.t('common.all')
+      }].concat(App.Service.find().mapProperty('serviceName').uniq().map(function(item) {
+        return {
+          value: item,
+          label: item
+        }
+      }));
+    }.property('App.router.clusterController.isLoaded'),
+    onChangeValue: function() {
+      this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'select');
+    }
+  }),
+
+  componentNameFilterView: filters.createSelectView({
+    column: 2,
+    fieldType: 'filter-input-width',
+    content: function() {
+      var hostName = this.get('parentView').get('host.hostName'),
+        hostComponents = App.HostComponent.find().filterProperty('hostName', hostName),
+        componentsMap = hostComponents.map(function(item) {
+          return {
+            value: item.get('componentName'),
+            label: item.get('displayName')
+          }
+        });
+      return [{
+        value: '',
+        label: Em.I18n.t('common.all')
+      }].concat(componentsMap);
+    }.property('App.router.clusterController.isLoaded'),
+    onChangeValue: function() {
+      this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'select');
+    }
+  }),
+
+  fileExtensionsFilter: filters.createSelectView({
+    column: 3,
+    fieldType: 'filter-input-width',
+    content: function() {
+      return [{
+        value: '',
+        label: Em.I18n.t('common.all')
+      }].concat([
+        '.out',
+         '.log'
+       ].map(function(item) {
+        return {
+          value: item,
+          label: item
+        }
+      }))
+    }.property('App.router.clusterController.isLoaded'),
+    onChangeValue: function() {
+      this.get('parentView').updateFilter(this.get('column'), this.get('value'), 'select');
+    }
+  }),
+
+  /**
+   * @type {string[]}
+   */
+  colPropAssoc: function () {
+    var ret = [];
+    ret[1] = 'serviceName';
+    ret[2] = 'componentName';
+    ret[3] = 'fileExtension';
+    return ret;
+  }.property(),
+
+  openLogFile: function(e) {
+    var fileData = e.context;
+    if (e.context) {
+      App.LogFileSearchPopup(fileData.fileName);
+    }
+  }
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/b567ca44/ambari-web/app/views/main/host/menu.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/menu.js b/ambari-web/app/views/main/host/menu.js
index 15608d1..a53c21a 100644
--- a/ambari-web/app/views/main/host/menu.js
+++ b/ambari-web/app/views/main/host/menu.js
@@ -53,6 +53,15 @@ App.MainHostMenuView = Em.CollectionView.extend({
           return !App.get('supports.stackUpgrade') || !App.get('stackVersionsAvailable')
         }.property('App.supports.stackUpgrade'),
         id: 'host-details-summary-version'
+      }),
+      Em.Object.create({
+        name: 'logs',
+        label: Em.I18n.t('hosts.host.menu.logs'),
+        routing: 'logs',
+        hidden: function () {
+          return !App.get('supports.logSearch');
+        }.property('App.supports.logSearch'),
+        id: 'host-details-summary-logs'
       })
     ];
   }.property('App.stackVersionsAvailable'),
@@ -104,4 +113,4 @@ App.MainHostMenuView = Em.CollectionView.extend({
     '{{view.content.badgeText}}' +
     '</span>  {{/if}}</a>{{/unless}}')
   })
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/b567ca44/ambari-web/test/views/main/host/menu_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host/menu_test.js b/ambari-web/test/views/main/host/menu_test.js
index 4540486..59facf1 100644
--- a/ambari-web/test/views/main/host/menu_test.js
+++ b/ambari-web/test/views/main/host/menu_test.js
@@ -69,6 +69,24 @@ describe('App.MainHostMenuView', function () {
         });
       });
 
+    Em.A([
+      {
+        logSearch: false,
+        m: '`logs` tab is invisible',
+        e: true
+      },
+      {
+        logSearch: true,
+        m: '`logs` tab is visible',
+        e: false
+      }
+    ]).forEach(function(test) {
+      it(test.m, function() {
+          this.mock.withArgs('supports.logSearch').returns(test.logSearch);
+          view.propertyDidChange('content');
+          expect(view.get('content').findProperty('name', 'logs').get('hidden')).to.equal(test.e);
+      });
+    });
   });
 
-});
\ No newline at end of file
+});


Mime
View raw message