yarn-container.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. allocatedMB: DS.attr('number'),
  22. allocatedVCores: DS.attr('number'),
  23. assignedNodeId: DS.attr('string'),
  24. priority: DS.attr('number'),
  25. startedTime: DS.attr('number'),
  26. finishedTime: DS.attr('number'),
  27. logUrl: DS.attr('string'),
  28. containerExitStatus: DS.attr('number'),
  29. containerState: DS.attr('string'),
  30. nodeHttpAddress: DS.attr('string'),
  31. startTs: function() {
  32. return Converter.dateToTimeStamp(this.get("startedTime"));
  33. }.property("startedTime"),
  34. finishedTs: function() {
  35. var ts = Converter.dateToTimeStamp(this.get("finishedTime"));
  36. return ts;
  37. }.property("finishedTime"),
  38. validatedFinishedTs: function() {
  39. if (this.get("finishedTs") < this.get("startTs")) {
  40. return "";
  41. }
  42. return this.get("finishedTime");
  43. }.property("finishedTime"),
  44. elapsedTime: function() {
  45. var elapsedMs = this.get("finishedTs") - this.get("startTs");
  46. if (elapsedMs <= 0) {
  47. elapsedMs = Date.now() - this.get("startTs");
  48. }
  49. return Converter.msToElapsedTime(elapsedMs);
  50. }.property(),
  51. tooltipLabel: function() {
  52. return "<p>Id:" + this.get("id") +
  53. "</p><p>ElapsedTime:" +
  54. String(this.get("elapsedTime")) + "</p>";
  55. }.property(),
  56. });