yarn-rm-node.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. import DS from 'ember-data';
  19. export default DS.Model.extend({
  20. rack: DS.attr('string'),
  21. state: DS.attr('string'),
  22. nodeHostName: DS.attr('string'),
  23. nodeHTTPAddress: DS.attr('string'),
  24. lastHealthUpdate: DS.attr('string'),
  25. healthReport: DS.attr('string'),
  26. numContainers: DS.attr('number'),
  27. usedMemoryMB: DS.attr('number'),
  28. availMemoryMB: DS.attr('number'),
  29. usedVirtualCores: DS.attr('number'),
  30. availableVirtualCores: DS.attr('number'),
  31. version: DS.attr('string'),
  32. nodeLabels: DS.attr('array'),
  33. nodeLabelsAsString: function() {
  34. var labels = this.get("nodeLabels");
  35. var labelToReturn = "";
  36. // Only one label per node supported.
  37. if (labels && labels.length > 0) {
  38. labelToReturn = labels[0];
  39. }
  40. return labelToReturn;
  41. }.property("nodeLabels"),
  42. /**
  43. * Indicates no rows were retrieved from backend
  44. */
  45. isDummyNode: function() {
  46. return this.get('id') == "dummy";
  47. }.property("id"),
  48. nodeStateStyle: function() {
  49. var style = "default";
  50. var nodeState = this.get("state");
  51. if (nodeState == "REBOOTED") {
  52. style = "warning";
  53. } else if (nodeState == "UNHEALTHY" || nodeState == "DECOMMISSIONED" ||
  54. nodeState == "LOST" || nodeState == "SHUTDOWN") {
  55. style = "danger";
  56. } else if (nodeState == "RUNNING") {
  57. style = "success";
  58. }
  59. return "label label-" + style;
  60. }.property("state"),
  61. getMemoryDataForDonutChart: function() {
  62. var arr = [];
  63. arr.push({
  64. label: "Used",
  65. value: this.get("usedMemoryMB")
  66. });
  67. arr.push({
  68. label: "Available",
  69. value: this.get("availMemoryMB")
  70. });
  71. return arr;
  72. }.property("availMemoryMB", "usedMemoryMB"),
  73. getVCoreDataForDonutChart: function() {
  74. var arr = [];
  75. arr.push({
  76. label: "Used",
  77. value: this.get("usedVirtualCores")
  78. });
  79. arr.push({
  80. label: "Available",
  81. value: this.get("availableVirtualCores")
  82. });
  83. return arr;
  84. }.property("availableVirtualCores", "usedVirtualCores"),
  85. });