yarn-app-timeline.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. import Converter from 'yarn-ui/utils/converter';
  20. export default DS.Model.extend({
  21. appName: DS.attr('string'),
  22. user: DS.attr('string'),
  23. queue: DS.attr('string'),
  24. state: DS.attr('string'),
  25. startTime: DS.attr('string'),
  26. elapsedTime: DS.attr('string'),
  27. finalStatus: DS.attr('string'),
  28. finishedTime: DS.attr('finishedTime'),
  29. progress: DS.attr('number'),
  30. diagnostics: DS.attr('string'),
  31. amHostHttpAddress: DS.attr('string'),
  32. logAggregationStatus: DS.attr('string'),
  33. unmanagedApplication: DS.attr('string'),
  34. amNodeLabelExpression: DS.attr('string'),
  35. applicationTags: DS.attr('string'),
  36. applicationType: DS.attr('string'),
  37. priority: DS.attr('number'),
  38. allocatedMB: DS.attr('number'),
  39. allocatedVCores: DS.attr('number'),
  40. runningContainers: DS.attr('number'),
  41. memorySeconds: DS.attr('number'),
  42. vcoreSeconds: DS.attr('number'),
  43. preemptedResourceMB: DS.attr('number'),
  44. preemptedResourceVCores: DS.attr('number'),
  45. numNonAMContainerPreempted: DS.attr('number'),
  46. numAMContainerPreempted: DS.attr('number'),
  47. clusterUsagePercentage: DS.attr('number'),
  48. queueUsagePercentage: DS.attr('number'),
  49. currentAppAttemptId: DS.attr('string'),
  50. isFailed: function() {
  51. return this.get('finalStatus') === "FAILED";
  52. }.property("finalStatus"),
  53. validatedFinishedTs: function() {
  54. if (this.get("finishedTime") < this.get("startTime")) {
  55. return "";
  56. }
  57. return this.get("finishedTime");
  58. }.property("finishedTime"),
  59. formattedElapsedTime: function() {
  60. return Converter.msToElapsedTimeUnit(this.get('elapsedTime'));
  61. }.property('elapsedTime'),
  62. allocatedResource: function() {
  63. return Converter.resourceToString(this.get("allocatedMB"), this.get("allocatedVCores"));
  64. }.property("allocatedMB", "allocatedVCores"),
  65. preemptedResource: function() {
  66. return Converter.resourceToString(this.get("preemptedResourceMB"), this.get("preemptedResourceVCores"));
  67. }.property("preemptedResourceMB", "preemptedResourceVCores"),
  68. aggregatedResourceUsage: function() {
  69. return Converter.resourceToString(this.get("memorySeconds"), this.get("vcoreSeconds")) + " (× Secs)";
  70. }.property("memorySeconds", "vcoreSeconds"),
  71. progressStyle: function() {
  72. return "width: " + this.get("progress") + "%";
  73. }.property("progress"),
  74. runningContainersNumber: function() {
  75. if(this.get("runningContainers") < 0) {
  76. return 0;
  77. }
  78. return this.get("runningContainers");
  79. }.property("progress"),
  80. finalStatusStyle: function() {
  81. var style = "default";
  82. var finalStatus = this.get("finalStatus");
  83. if (finalStatus === "KILLED") {
  84. style = "warning";
  85. } else if (finalStatus === "FAILED") {
  86. style = "danger";
  87. } else {
  88. style = "success";
  89. }
  90. return "label label-" + style;
  91. }.property("finalStatus")
  92. });