[27/50] [abbrv] hadoop git commit: YARN-4849. [YARN-3368] cleanup code base, integrate web UI related build to mvn, and fix licenses. (wangda)
http://git-wip-us.apache.org/repos/asf/hadoop/blob/fb176dae/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/tree-selector.js -- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/tree-selector.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/tree-selector.js new file mode 100644 index 000..f7ec020 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/tree-selector.js @@ -0,0 +1,275 @@ +/** + * 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({ + // Map: + map : undefined, + + // Normalized data for d3 + treeData: undefined, + + // folded queues, folded[] == true means is folded + foldedQueues: { }, + + // maxDepth + maxDepth: 0, + + // num of leaf queue, folded queue is treated as leaf queue + numOfLeafQueue: 0, + + // mainSvg + mainSvg: undefined, + + // Init data + initData: function() { +this.map = { }; +this.treeData = { }; +this.maxDepth = 0; +this.numOfLeafQueue = 0; + +this.get("model") + .forEach(function(o) { +this.map[o.id] = o; + }.bind(this)); + +var selected = this.get("selected"); + +this.initQueue("root", 1, this.treeData); + }, + + // get Children array of given queue + getChildrenNamesArray: function(q) { +var namesArr = []; + +// Folded queue's children is empty +if (this.foldedQueues[q.get("name")]) { + return namesArr; +} + +var names = q.get("children"); +if (names) { + names.forEach(function(name) { +namesArr.push(name); + }); +} + +return namesArr; + }, + + // Init queues + initQueue: function(queueName, depth, node) { +if ((!queueName) || (!this.map[queueName])) { + // Queue is not existed + return; +} + +if (depth > this.maxDepth) { + this.maxDepth = this.maxDepth + 1; +} + +var queue = this.map[queueName]; + +var names = this.getChildrenNamesArray(queue); + +node.name = queueName; +node.parent = queue.get("parent"); +node.queueData = queue; + +if (names.length > 0) { + node.children = []; + + names.forEach(function(name) { +var childQueueData = {}; +node.children.push(childQueueData); +this.initQueue(name, depth + 1, childQueueData); + }.bind(this)); +} else { + this.numOfLeafQueue = this.numOfLeafQueue + 1; +} + }, + + update: function(source, root, tree, diagonal) { +var duration = 300; +var i = 0; + +// Compute the new tree layout. +var nodes = tree.nodes(root).reverse(); +var links = tree.links(nodes); + +// Normalize for fixed-depth. +nodes.forEach(function(d) { d.y = d.depth * 200; }); + +// Update the nodes⦠+var node = this.mainSvg.selectAll("g.node") + .data(nodes, function(d) { return d.id || (d.id = ++i); }); + +// Enter any new nodes at the parent's previous position. +var nodeEnter = node.enter().append("g") + .attr("class", "node") + .attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; }) + .on("click", function(d,i){ +if (d.queueData.get("name") != this.get("selected")) { +document.location.href = "yarnQueue/" + d.queueData.get("name"); +} + }.bind(this)); + // .on("click", click); + +nodeEnter.append("circle") + .attr("r", 1e-6) + .style("fill", function(d) { +var usedCap = d.queueData.get("usedCapacity"); +if (usedCap <= 60.0) { + return "LimeGreen"; +} else if (usedCap <= 100.0) { + return "DarkOrange"; +} else { + return "LightCoral"; +} + }); + +// append percentage +nodeEnter.append("text") + .attr("x", function(d) { return 0; }) + .attr("dy", ".35em") + .attr("text-anchor", function(d) { return "middle"; }) + .text(function(d) { +var usedCap = d.queueData.get("usedCapacity"); +if (usedCap >= 100.0) { + return usedCa
[27/50] [abbrv] hadoop git commit: YARN-4849. [YARN-3368] cleanup code base, integrate web UI related build to mvn, and fix licenses. (wangda)
http://git-wip-us.apache.org/repos/asf/hadoop/blob/6804e642/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-test.js -- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-test.js deleted file mode 100644 index 5877589..000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-node-test.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * 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 { moduleForModel, test } from 'ember-qunit'; - -moduleForModel('yarn-node', 'Unit | Model | Node', { - // Specify the other units that are required for this test. - needs: [] -}); - -test('Basic creation test', function(assert) { - let model = this.subject(); - - assert.ok(model); - assert.ok(model._notifyProperties); - assert.ok(model.didLoad); - assert.ok(model.totalVmemAllocatedContainersMB); - assert.ok(model.vmemCheckEnabled); - assert.ok(model.pmemCheckEnabled); - assert.ok(model.nodeHealthy); - assert.ok(model.lastNodeUpdateTime); - assert.ok(model.healthReport); - assert.ok(model.nmStartupTime); - assert.ok(model.nodeManagerBuildVersion); - assert.ok(model.hadoopBuildVersion); -}); - -test('test fields', function(assert) { - let model = this.subject(); - - assert.expect(4); - Ember.run(function () { -model.set("totalVmemAllocatedContainersMB", 4096); -model.set("totalPmemAllocatedContainersMB", 2048); -model.set("totalVCoresAllocatedContainers", 4); -model.set("hadoopBuildVersion", "3.0.0-SNAPSHOT"); -assert.equal(model.get("totalVmemAllocatedContainersMB"), 4096); -assert.equal(model.get("totalPmemAllocatedContainersMB"), 2048); -assert.equal(model.get("totalVCoresAllocatedContainers"), 4); -assert.equal(model.get("hadoopBuildVersion"), "3.0.0-SNAPSHOT"); - }); -}); - http://git-wip-us.apache.org/repos/asf/hadoop/blob/6804e642/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-rm-node-test.js -- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-rm-node-test.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-rm-node-test.js deleted file mode 100644 index 4fd2517..000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/tests/unit/models/yarn-rm-node-test.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * 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 { moduleForModel, test } from 'ember-qunit'; - -moduleForModel('yarn-rm-node', 'Unit | Model | RMNode', { - // Specify the other units that are required for this test. - needs: [] -}); - -test('Basic creation test', function(assert) { - let model = this.subject(); - - assert.ok(model); - assert.ok(model._notifyProperties); - assert.ok(model.didLoad); - assert.ok(model.rack); - assert.ok(model.state); - assert.ok(model.nodeHostName); - assert.ok(model.nodeHTTPAddress); - assert.ok(model.lastHealthUpdate); - assert.ok(model.healthReport); - assert.ok(model.numContainers); - assert.ok(model.usedMemoryMB); - assert.ok(model.availMemoryMB); - assert.ok(model.usedVirtualCores); - assert.ok(model.availableVirtualCores); - assert.ok(model.version); - assert.ok(model.nodeLabels); - assert.ok(model.nodeLabelsAsStr
[27/50] [abbrv] hadoop git commit: YARN-4849. [YARN-3368] cleanup code base, integrate web UI related build to mvn, and fix licenses. (wangda)
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e8ca198e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/tree-selector.js -- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/tree-selector.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/tree-selector.js new file mode 100644 index 000..f7ec020 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/tree-selector.js @@ -0,0 +1,275 @@ +/** + * 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({ + // Map: + map : undefined, + + // Normalized data for d3 + treeData: undefined, + + // folded queues, folded[] == true means is folded + foldedQueues: { }, + + // maxDepth + maxDepth: 0, + + // num of leaf queue, folded queue is treated as leaf queue + numOfLeafQueue: 0, + + // mainSvg + mainSvg: undefined, + + // Init data + initData: function() { +this.map = { }; +this.treeData = { }; +this.maxDepth = 0; +this.numOfLeafQueue = 0; + +this.get("model") + .forEach(function(o) { +this.map[o.id] = o; + }.bind(this)); + +var selected = this.get("selected"); + +this.initQueue("root", 1, this.treeData); + }, + + // get Children array of given queue + getChildrenNamesArray: function(q) { +var namesArr = []; + +// Folded queue's children is empty +if (this.foldedQueues[q.get("name")]) { + return namesArr; +} + +var names = q.get("children"); +if (names) { + names.forEach(function(name) { +namesArr.push(name); + }); +} + +return namesArr; + }, + + // Init queues + initQueue: function(queueName, depth, node) { +if ((!queueName) || (!this.map[queueName])) { + // Queue is not existed + return; +} + +if (depth > this.maxDepth) { + this.maxDepth = this.maxDepth + 1; +} + +var queue = this.map[queueName]; + +var names = this.getChildrenNamesArray(queue); + +node.name = queueName; +node.parent = queue.get("parent"); +node.queueData = queue; + +if (names.length > 0) { + node.children = []; + + names.forEach(function(name) { +var childQueueData = {}; +node.children.push(childQueueData); +this.initQueue(name, depth + 1, childQueueData); + }.bind(this)); +} else { + this.numOfLeafQueue = this.numOfLeafQueue + 1; +} + }, + + update: function(source, root, tree, diagonal) { +var duration = 300; +var i = 0; + +// Compute the new tree layout. +var nodes = tree.nodes(root).reverse(); +var links = tree.links(nodes); + +// Normalize for fixed-depth. +nodes.forEach(function(d) { d.y = d.depth * 200; }); + +// Update the nodes⦠+var node = this.mainSvg.selectAll("g.node") + .data(nodes, function(d) { return d.id || (d.id = ++i); }); + +// Enter any new nodes at the parent's previous position. +var nodeEnter = node.enter().append("g") + .attr("class", "node") + .attr("transform", function(d) { return "translate(" + source.y0 + "," + source.x0 + ")"; }) + .on("click", function(d,i){ +if (d.queueData.get("name") != this.get("selected")) { +document.location.href = "yarnQueue/" + d.queueData.get("name"); +} + }.bind(this)); + // .on("click", click); + +nodeEnter.append("circle") + .attr("r", 1e-6) + .style("fill", function(d) { +var usedCap = d.queueData.get("usedCapacity"); +if (usedCap <= 60.0) { + return "LimeGreen"; +} else if (usedCap <= 100.0) { + return "DarkOrange"; +} else { + return "LightCoral"; +} + }); + +// append percentage +nodeEnter.append("text") + .attr("x", function(d) { return 0; }) + .attr("dy", ".35em") + .attr("text-anchor", function(d) { return "middle"; }) + .text(function(d) { +var usedCap = d.queueData.get("usedCapacity"); +if (usedCap >= 100.0) { + return usedCa