app-attempt.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 Ember from 'ember';
  19. export default Ember.Mixin.create({
  20. fetchAppInfoFromRMorATS(appId, store) {
  21. return new Ember.RSVP.Promise(function(resolve, reject) {
  22. store.find('yarn-app', appId).then(function(rmApp) {
  23. resolve(rmApp);
  24. }, function() {
  25. store.find('yarn-app-timeline', appId).then(function(atsApp) {
  26. resolve(atsApp);
  27. }, function() {
  28. console.error('Error:', 'Application not found in RM or ATS for appId: ' + appId);
  29. reject(null);
  30. });
  31. });
  32. });
  33. },
  34. fetchAttemptInfoFromRMorATS(attemptId, store) {
  35. return new Ember.RSVP.Promise(function(resolve, reject) {
  36. store.findRecord('yarn-app-attempt', attemptId, {reload: true}).then(function(rmAttempt) {
  37. resolve(rmAttempt);
  38. }, function() {
  39. store.findRecord('yarn-timeline-appattempt', attemptId, {reload: true}).then(function(atsAttempt) {
  40. resolve(atsAttempt);
  41. }, function() {
  42. console.error('Error:', 'Application attempt not found in RM or ATS for attemptId: ' + attemptId);
  43. reject(null);
  44. });
  45. });
  46. });
  47. },
  48. fetchAttemptListFromRMorATS(appId, store) {
  49. return new Ember.RSVP.Promise(function(resolve, reject) {
  50. store.query('yarn-app-attempt', {appId: appId}).then(function(rmAttempts) {
  51. resolve(rmAttempts);
  52. }, function() {
  53. store.query('yarn-timeline-appattempt', {appId: appId}).then(function(atsAttempts) {
  54. resolve(atsAttempts);
  55. }, function() {
  56. console.error('Error:', 'Application attempts not found in RM or ATS for appId: ' + appId);
  57. reject(null);
  58. });
  59. });
  60. });
  61. }
  62. });