From db7e195df28e17fcdbdd3d6c536095c0f83fd02e Mon Sep 17 00:00:00 2001 From: Sunil G Date: Mon, 27 Mar 2017 15:50:50 +0530 Subject: [PATCH] YARN-6402. Move 'Long Running Services' to an independent tab at top level for new Yarn UI Change-Id: I0113a7c3267981e59450cbc3dff3107629aaf8d9 --- .../webapp/app/controllers/app-table-columns.js | 3 +- .../src/main/webapp/app/controllers/yarn-apps.js | 1 - .../main/webapp/app/controllers/yarn-services.js | 74 ++++++++++++++++++- .../hadoop-yarn-ui/src/main/webapp/app/router.js | 1 + .../src/main/webapp/app/routes/yarn-services.js | 34 +++++++++ .../src/main/webapp/app/templates/application.hbs | 5 ++ .../src/main/webapp/app/templates/yarn-apps.hbs | 4 - .../main/webapp/app/templates/yarn-services.hbs | 86 ++++++++++++++++++++++ .../webapp/tests/unit/routes/yarn-services-test.js | 29 ++++++++ 9 files changed, 229 insertions(+), 8 deletions(-) create mode 100644 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/routes/yarn-services.js create mode 100644 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-services.hbs create mode 100644 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/tests/unit/routes/yarn-services-test.js diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/app-table-columns.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/app-table-columns.js index 35db636..b01fba9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/app-table-columns.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/app-table-columns.js @@ -23,9 +23,10 @@ import TableDef from 'em-table/utils/table-definition'; export default Ember.Controller.extend({ tableDefinition: TableDef.create({ -      sortColumnId: 'startTime', +      sortColumnId: 'stTime',       sortOrder: 'desc'    }), + columns: function() { var colums = []; colums.push({ diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-apps.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-apps.js index 18bf682..999fd44 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-apps.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-apps.js @@ -27,5 +27,4 @@ export default Ember.Controller.extend({ text: "Applications", routeName: 'yarn-apps.apps', }] - }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-services.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-services.js index 75bebf6..2958fd1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-services.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-services.js @@ -17,8 +17,10 @@ */ import Ember from 'ember'; +import AppTableController from './app-table-columns'; -export default Ember.Controller.extend({ + +export default AppTableController.extend({ breadcrumbs: [{ text: "Home", @@ -29,6 +31,74 @@ export default Ember.Controller.extend({ }, { text: "Long Running Services", routeName: 'yarn-services', - }] + }], + + getFinishedServicesDataForDonutChart: Ember.computed('model.apps', function() { + + var finishdApps = 0; + var failedApps = 0; + var killedApps = 0; + + this.get('model.apps').forEach(function(service){ + if (service.get('state') === "FINISHED") { + finishdApps++; + } + + if (service.get('state') === "FAILED") { + failedApps++; + } + + if (service.get('state') === "KILLED") { + killedApps++; + } + }); + + var arr = []; + arr.push({ + label: "Completed", + value: finishdApps + }); + arr.push({ + label: "Killed", + value: killedApps + }); + arr.push({ + label: "Failed", + value: failedApps + }); + + return arr; + }), + + + getRunningServicesDataForDonutChart: Ember.computed('model.apps', function() { + var pendingApps = 0; + var runningApps = 0; + + this.get('model.apps').forEach(function(service){ + if (service.get('state') === "RUNNING") { + runningApps++; + } + + if (service.get('state') === "ACCEPTED" || + service.get('state') === "SUBMITTED" || + service.get('state') === "NEW" || + service.get('state') === "NEW_SAVING") { + pendingApps++; + } + }); + + var arr = []; + arr.push({ + label: "Pending", + value: pendingApps + }); + arr.push({ + label: "Running", + value: runningApps + }); + + return arr; + }), }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/router.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/router.js index a52107a..6340574 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/router.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/router.js @@ -56,6 +56,7 @@ Router.map(function() { this.route('yarn-app-attempts', { path: '/yarn-app-attempts/:app_id' }); this.route('yarn-queues', { path: '/yarn-queues/:queue_name' }); this.route('yarn-appattempt-containers', {path: '/yarn-appattempt-containers/:app_attempt_id'}); + this.route('yarn-services'); this.route('yarn-flow-activity'); this.route('yarn-flow', { path: '/yarn-flow/:flow_uid'}, function() { this.route('info'); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/routes/yarn-services.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/routes/yarn-services.js new file mode 100644 index 0000000..fb01138 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/routes/yarn-services.js @@ -0,0 +1,34 @@ +/** + * 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. + */ + +import Ember from 'ember'; +import AbstractRoute from './abstract'; + +export default AbstractRoute.extend({ + model() { + return Ember.RSVP.hash({ + apps: this.store.query('yarn-app', { + applicationTypes: "org-apache-slider" + }), + }); + }, + + unloadAll() { + this.store.unloadAll('yarn-app'); + } +}); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/application.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/application.hbs index d61622b..cffba72 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/application.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/application.hbs @@ -51,6 +51,11 @@ (current) {{/link-to}} {{/link-to}} + {{#link-to 'yarn-services' tagName="li"}} + {{#link-to 'yarn-services' class="navigation-link"}}Services + (current) + {{/link-to}} + {{/link-to}} {{#link-to 'yarn-flow-activity' tagName="li"}} {{#link-to 'yarn-flow-activity' class="navigation-link"}}Flow Activity (current) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-apps.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-apps.hbs index 801f9aa..264e6b6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-apps.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-apps.hbs @@ -33,10 +33,6 @@ {{#link-to 'yarn-apps.apps'}}All Applications {{/link-to}} {{/link-to}} - {{#link-to 'yarn-apps.services' tagName="li"}} - {{#link-to 'yarn-apps.services'}}Long Running Services - {{/link-to}} - {{/link-to}} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-services.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-services.hbs new file mode 100644 index 0000000..646e60b --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-services.hbs @@ -0,0 +1,86 @@ +{{!-- + 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. +--}} + +{{breadcrumb-bar breadcrumbs=breadcrumbs}} + + +
+
+ +
+
+
+

Services

+
+
+ +
+
+
+ +
+
+
+
+
+ Finished Services +
+
+ {{donut-chart data=getFinishedServicesDataForDonutChart + showLabels=true + parentId="finishedapps-donut-chart" + ratio=0.6 + maxHeight=350 + colorTargets="good warn error" + }} +
+
+
+ +
+
+
+ Running Services +
+
+ {{donut-chart data=getRunningServicesDataForDonutChart + showLabels=true + parentId="runningapps-donut-chart" + ratio=0.6 + maxHeight=350 + colorTargets="warn good" + }} +
+
+
+
+ {{#if model.apps}} + {{em-table columns=columns rows=model.apps definition=tableDefinition}} + {{else}} +

Could not find any services from this cluster

+ {{/if}} +
+
+
\ No newline at end of file diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/tests/unit/routes/yarn-services-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/tests/unit/routes/yarn-services-test.js new file mode 100644 index 0000000..6348f86 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/tests/unit/routes/yarn-services-test.js @@ -0,0 +1,29 @@ +/** + * 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. + */ + +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:yarn-services', 'Unit | Route | yarn services', { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] +}); + +test('it exists', function(assert) { + let route = this.subject(); + assert.ok(route); +}); -- 2.10.1 (Apple Git-78)