step4_controller.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. var App = require('app');
  19. require('controllers/main/admin/serviceAccounts_controller');
  20. App.HighAvailabilityWizardStep4Controller = Em.Controller.extend({
  21. name:"highAvailabilityWizardStep4Controller",
  22. POLL_INTERVAL: 1000,
  23. isNextEnabled: false,
  24. isNameNodeStarted: true,
  25. pullCheckPointStatus: function () {
  26. var hostName = this.get('content.masterComponentHosts').findProperty('isCurNameNode', true).hostName;
  27. App.ajax.send({
  28. name: 'admin.high_availability.getNnCheckPointStatus',
  29. sender: this,
  30. data: {
  31. hostName: hostName
  32. },
  33. success: 'checkNnCheckPointStatus'
  34. });
  35. },
  36. checkNnCheckPointStatus: function (data) {
  37. if (data.HostRoles.desired_state === 'STARTED') {
  38. this.set('isNameNodeStarted', true);
  39. var self = this;
  40. var journalTransactionInfo = $.parseJSON(data.metrics.dfs.namenode.JournalTransactionInfo);
  41. var isInSafeMode = (data.metrics.dfs.namenode.Safemode != "");
  42. journalTransactionInfo = parseInt(journalTransactionInfo.LastAppliedOrWrittenTxId) - parseInt(journalTransactionInfo.MostRecentCheckpointTxId);
  43. if (journalTransactionInfo <= 1 && isInSafeMode) {
  44. this.set("isNextEnabled", true);
  45. return;
  46. }
  47. window.setTimeout(function () {
  48. self.pullCheckPointStatus()
  49. }, self.POLL_INTERVAL);
  50. } else {
  51. this.set('isNameNodeStarted', false);
  52. }
  53. },
  54. done: function () {
  55. if (this.get('isNextEnabled')) {
  56. App.router.send('next');
  57. }
  58. }
  59. });