YARN-8115. [UI2] URL data like nodeHTTPAddress must be encoded in UI before using to access NM. Contributed by Sreenath Somarajapuram.

(cherry picked from commit 42cd367c93)
This commit is contained in:
Sunil G 2018-04-04 22:13:14 +05:30
parent 2f326159f1
commit 4db13cb944
13 changed files with 57 additions and 20 deletions

View File

@ -0,0 +1,25 @@
/**
* 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';
export default Ember.Component.extend({
encodedAddr : Ember.computed("nodeAddr", function(){
return encodeURIComponent(this.get('nodeAddr'));
})
});

View File

@ -22,6 +22,7 @@ export default Ember.Controller.extend({
breadcrumbs: Ember.computed('model.nodeInfo', function () {
var nodeInfo = this.get('model.nodeInfo');
var addr = encodeURIComponent(nodeInfo.addr);
return [{
text: "Home",
routeName: 'application'
@ -30,7 +31,7 @@ export default Ember.Controller.extend({
routeName: 'yarn-nodes.table'
}, {
text: `Node [ ${nodeInfo.id} ]`,
href: `#/yarn-node/${nodeInfo.id}/${nodeInfo.addr}`,
href: `#/yarn-node/${nodeInfo.id}/${addr}/info`,
}, {
text: `Application [ ${nodeInfo.appId} ]`,
}];

View File

@ -22,6 +22,7 @@ export default Ember.Controller.extend({
breadcrumbs: Ember.computed("model.attempt.appId", function () {
var nodeInfo = this.get("model.nodeInfo");
var addr = encodeURIComponent(nodeInfo.addr);
return [{
text: "Home",
routeName: 'application'
@ -30,7 +31,7 @@ export default Ember.Controller.extend({
routeName: 'yarn-nodes.table'
}, {
text: `Node [ ${nodeInfo.id} ]`,
href: `#/yarn-node/${nodeInfo.id}/${nodeInfo.addr}`
href: `#/yarn-node/${nodeInfo.id}/${addr}/info`
}, {
text: "Applications",
}];

View File

@ -22,6 +22,7 @@ export default Ember.Controller.extend({
breadcrumbs: Ember.computed("model.nodeInfo", function () {
var nodeInfo = this.get("model.nodeInfo");
var addr = encodeURIComponent(nodeInfo.addr);
return [{
text: "Home",
routeName: 'application'
@ -30,7 +31,7 @@ export default Ember.Controller.extend({
routeName: 'yarn-nodes.table'
}, {
text: `Node [ ${nodeInfo.id} ]`,
href: `#/yarn-node/${nodeInfo.id}/${nodeInfo.addr}`
href: `#/yarn-node/${nodeInfo.id}/${addr}/info`
}, {
text: `Container [ ${nodeInfo.containerId} ]`
}];

View File

@ -22,6 +22,7 @@ export default Ember.Controller.extend({
breadcrumbs: Ember.computed("model.nodeInfo", function () {
var nodeInfo = this.get("model.nodeInfo");
var addr = encodeURIComponent(nodeInfo.addr);
return [{
text: "Home",
routeName: 'application'
@ -30,7 +31,7 @@ export default Ember.Controller.extend({
routeName: 'yarn-nodes.table'
}, {
text: `Node [ ${nodeInfo.id} ]`,
href: `#/yarn-node/${nodeInfo.id}/${nodeInfo.addr}`
href: `#/yarn-node/${nodeInfo.id}/${addr}/info`
}, {
text: "Containers",
}];

View File

@ -22,6 +22,7 @@ export default Ember.Controller.extend({
breadcrumbs: Ember.computed("model.nodeInfo", function () {
var nodeInfo = this.get("model.nodeInfo");
var addr = encodeURIComponent(nodeInfo.addr);
return [{
text: "Home",
@ -31,7 +32,7 @@ export default Ember.Controller.extend({
routeName: 'yarn-nodes.table'
}, {
text: `Node [ ${nodeInfo.id} ]`,
href: `#/yarn-node/${nodeInfo.id}/${nodeInfo.addr}`,
href: `#/yarn-node/${nodeInfo.id}/${addr}/info`,
}];
})

View File

@ -69,7 +69,7 @@ export default Ember.Controller.extend({
facetType: null,
getCellContent: function(row) {
var node_id = row.get("id"),
node_addr = row.get("nodeHTTPAddress"),
node_addr = encodeURIComponent(row.get("nodeHTTPAddress")),
href = `#/yarn-node/${node_id}/${node_addr}/info`;
switch(row.get("nodeState")) {
case "SHUTDOWN":

View File

@ -29,7 +29,7 @@ export default Ember.Helper.helper(function(params,hash) {
if (nodeState === "SHUTDOWN" || nodeState === "LOST") {
html = html + nodeHTTPAddress;
} else {
html = html + '<a href="#/yarn-node/' + nodeId + "/" + nodeHTTPAddress + '">' +
html = html + '<a href="#/yarn-node/' + nodeId + "/" + encodeURIComponent(nodeHTTPAddress) + '">' +
nodeHTTPAddress + '</a>';
}
html = html + '</td>';

View File

@ -44,6 +44,7 @@ function updateConfigs(application) {
if(!ENV.hosts.rmWebAddress) {
ENV.hosts.rmWebAddress = rmhost;
ENV.hosts.protocolScheme = window.location.protocol;
} else {
rmhost = ENV.hosts.rmWebAddress;
}

View File

@ -23,10 +23,12 @@ import AbstractRoute from './abstract';
export default AbstractRoute.extend({
model(param) {
// Get all apps running on a specific node. Node is contacted by using node_addr.
var address = decodeURIComponent(param.node_addr);
address = address.replace(/(^\w+:|^)\/\//, '');
return Ember.RSVP.hash({
apps: this.store.query('yarn-node-app', { nodeAddr: param.node_addr }),
nmGpuInfo: this.store.findRecord('yarn-nm-gpu', param.node_addr, {reload:true}),
nodeInfo: { id: param.node_id, addr: param.node_addr }
apps: this.store.query('yarn-node-app', { nodeAddr: address }),
nmGpuInfo: this.store.findRecord('yarn-nm-gpu', address, {reload:true}),
nodeInfo: { id: param.node_id, addr: address }
});
},

View File

@ -22,10 +22,12 @@ import AbstractRoute from './abstract';
export default AbstractRoute.extend({
model(param) {
// Get all containers running on specific node.
var address = decodeURIComponent(param.node_addr);
address = address.replace(/(^\w+:|^)\/\//, '');
return Ember.RSVP.hash({
containers: this.store.query('yarn-node-container', { nodeHttpAddr: param.node_addr }),
nmGpuInfo: this.store.findRecord('yarn-nm-gpu', param.node_addr, {reload:true}),
nodeInfo: { id: param.node_id, addr: param.node_addr }
containers: this.store.query('yarn-node-container', { nodeHttpAddr: address }),
nmGpuInfo: this.store.findRecord('yarn-nm-gpu', address, {reload:true}),
nodeInfo: { id: param.node_id, addr: address }
});
},

View File

@ -23,10 +23,12 @@ import AbstractRoute from './abstract';
export default AbstractRoute.extend({
model(param) {
// Fetches data from both NM and RM. RM is queried to get node usage info.
var address = decodeURIComponent(param.node_addr);
address = address.replace(/(^\w+:|^)\/\//, '');
return Ember.RSVP.hash({
nodeInfo: { id: param.node_id, addr: param.node_addr },
nmGpuInfo: this.store.findRecord('yarn-nm-gpu', param.node_addr, {reload:true}),
node: this.store.findRecord('yarn-node', param.node_addr, {reload: true}),
nodeInfo: { id: param.node_id, addr: address },
nmGpuInfo: this.store.findRecord('yarn-nm-gpu', address, {reload:true}),
node: this.store.findRecord('yarn-node', address, {reload: true}),
rmNode: this.store.findRecord('yarn-rm-node', param.node_id, {reload: true})
});
},

View File

@ -25,20 +25,20 @@
<ul class="nav nav-pills nav-stacked" id="stacked-menu">
<ul class="nav nav-pills nav-stacked collapse in">
{{#link-to 'yarn-node.info' tagName="li"}}
{{#link-to 'yarn-node.info' nodeId nodeAddr}}Node Information
{{#link-to 'yarn-node.info' nodeId encodedAddr}}Node Information
{{/link-to}}
{{/link-to}}
{{#link-to 'yarn-node-apps' tagName="li"}}
{{#link-to 'yarn-node-apps' nodeId nodeAddr}}List of Applications
{{#link-to 'yarn-node-apps' nodeId encodedAddr}}List of Applications
{{/link-to}}
{{/link-to}}
{{#link-to 'yarn-node-containers' tagName="li"}}
{{#link-to 'yarn-node-containers' nodeId nodeAddr}}List of Containers
{{#link-to 'yarn-node-containers' nodeId encodedAddr}}List of Containers
{{/link-to}}
{{/link-to}}
{{#if (and nmGpuInfo nmGpuInfo.info.totalGpuDevices)}}
{{#link-to 'yarn-node.yarn-nm-gpu' tagName="li"}}
{{#link-to 'yarn-node.yarn-nm-gpu' nodeId nodeAddr }}GPU Information
{{#link-to 'yarn-node.yarn-nm-gpu' nodeId encodedAddr }}GPU Information
{{/link-to}}
{{/link-to}}
{{/if}}