step6_controller.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. App.HighAvailabilityWizardStep6Controller = Em.Controller.extend({
  20. name:"highAvailabilityWizardStep6Controller",
  21. POLL_INTERVAL: 1000,
  22. isNextEnabled: function(){
  23. //only 3 JournalNodes could be installed
  24. return (this.get('initJnCounter') === 3);
  25. }.property('initJnCounter'),
  26. initJnCounter: 0,
  27. pullCheckPointStatus: function () {
  28. this.set('initJnCounter', 0);
  29. var hostNames = this.get('content.masterComponentHosts').filterProperty('component', "JOURNALNODE").mapProperty('hostName');
  30. hostNames.forEach(function (hostName) {
  31. this.pullEachJnStatus(hostName);
  32. }, this);
  33. },
  34. pullEachJnStatus: function(hostName){
  35. App.ajax.send({
  36. name: 'admin.high_availability.getJnCheckPointStatus',
  37. sender: this,
  38. data: {
  39. hostName: hostName
  40. },
  41. success: 'checkJnCheckPointStatus'
  42. });
  43. },
  44. checkJnCheckPointStatus: function (data) {
  45. var self = this;
  46. var journalStatusInfo;
  47. if (data.metrics && data.metrics.dfs) {
  48. journalStatusInfo = $.parseJSON(data.metrics.dfs.journalnode.journalsStatus);
  49. if (journalStatusInfo[this.get('content.nameServiceId')] && journalStatusInfo[this.get('content.nameServiceId')].Formatted === "true") {
  50. this.set("initJnCounter", (this.get('initJnCounter') + 1));
  51. return;
  52. }
  53. }
  54. window.setTimeout(function () {
  55. self.pullEachJnStatus(data.HostRoles.host_name);
  56. }, self.POLL_INTERVAL);
  57. },
  58. done: function () {
  59. if (this.get('isNextEnabled')) {
  60. App.router.send('next');
  61. }
  62. }
  63. })