step4_controller.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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').filterProperty('component', 'NAMENODE').findProperty('isInstalled', 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. this.set('isNameNodeStarted', data.HostRoles.desired_state === 'STARTED');
  38. var self = this;
  39. var journalTransactionInfo = $.parseJSON(Em.get(data, 'metrics.dfs.namenode.JournalTransactionInfo'));
  40. var isInSafeMode = !Em.isEmpty(Em.get(data, 'metrics.dfs.namenode.Safemode'));
  41. // in case when transaction info absent or invalid return 2 which will return false in next `if` statement
  42. journalTransactionInfo = !!journalTransactionInfo ? (parseInt(journalTransactionInfo.LastAppliedOrWrittenTxId) - parseInt(journalTransactionInfo.MostRecentCheckpointTxId)) : 2;
  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. },
  51. done: function () {
  52. if (this.get('isNextEnabled')) {
  53. App.get('router.mainAdminKerberosController').getKDCSessionState(function() {
  54. App.router.send("next");
  55. });
  56. }
  57. }
  58. });