step4_controller.js 2.1 KB

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