yarn-app-timeline.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.JSONAPISerializer.extend({
  21. internalNormalizeSingleResponse(store, primaryModelClass, payload, id) {
  22. var events = payload.events,
  23. appFinishedEvent = events.findBy('id', 'YARN_APPLICATION_FINISHED'),
  24. startedTime = payload.createdtime,
  25. finishedTime = appFinishedEvent? appFinishedEvent.timestamp : Date.now(),
  26. elapsedTime = finishedTime - startedTime,
  27. diagnostics = payload.info.YARN_APPLICATION_DIAGNOSTICS_INFO,
  28. priority = payload.info.YARN_APPLICATION_PRIORITY;
  29. var fixedPayload = {
  30. id: id,
  31. type: primaryModelClass.modelName,
  32. attributes: {
  33. appName: payload.info.YARN_APPLICATION_NAME,
  34. user: payload.info.YARN_APPLICATION_USER,
  35. queue: "N/A",
  36. state: payload.info.YARN_APPLICATION_STATE,
  37. startTime: Converter.timeStampToDate(startedTime),
  38. elapsedTime: elapsedTime,
  39. finishedTime: Converter.timeStampToDate(finishedTime),
  40. finalStatus: payload.info.YARN_APPLICATION_FINAL_STATUS,
  41. progress: 100,
  42. applicationType: payload.info.YARN_APPLICATION_TYPE,
  43. diagnostics: (diagnostics && diagnostics !== 'null')? diagnostics : '',
  44. amHostHttpAddress: '',
  45. logAggregationStatus: '',
  46. unmanagedApplication: payload.info.YARN_APPLICATION_UNMANAGED_APPLICATION || 'N/A',
  47. amNodeLabelExpression: payload.configs.YARN_AM_NODE_LABEL_EXPRESSION,
  48. priority: (priority !== undefined)? priority : 'N/A',
  49. allocatedMB: 0,
  50. allocatedVCores: 0,
  51. runningContainers: 0,
  52. memorySeconds: payload.info.YARN_APPLICATION_MEM_METRIC,
  53. vcoreSeconds: payload.info.YARN_APPLICATION_CPU_METRIC,
  54. preemptedResourceMB: 0,
  55. preemptedResourceVCores: 0,
  56. numNonAMContainerPreempted: 0,
  57. numAMContainerPreempted: 0,
  58. clusterUsagePercentage: 0,
  59. queueUsagePercentage: 0,
  60. currentAppAttemptId: payload.info.YARN_APPLICATION_LATEST_APP_ATTEMPT
  61. }
  62. };
  63. return fixedPayload;
  64. },
  65. normalizeSingleResponse(store, primaryModelClass, payload, id/*, requestType*/) {
  66. var p = this.internalNormalizeSingleResponse(store, primaryModelClass, payload, id);
  67. return {data: p};
  68. }
  69. });