step1_controller.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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.ReassignMasterWizardStep1Controller = Em.Controller.extend({
  20. name: 'reassignMasterWizardStep1Controller',
  21. databaseType: null,
  22. dbProperty: function() {
  23. var componentName = this.get('content.reassign.component_name');
  24. var property = null;
  25. switch(componentName) {
  26. case 'HIVE_SERVER':
  27. case 'HIVE_METASTORE':
  28. property = 'javax.jdo.option.ConnectionDriverName';
  29. break;
  30. case 'OOZIE_SERVER':
  31. property = 'oozie.service.JPAService.jdbc.driver';
  32. break;
  33. }
  34. return property;
  35. },
  36. loadConfigsTags: function () {
  37. if(!this.get('databaseType')) {
  38. App.ajax.send({
  39. name: 'config.tags',
  40. sender: this,
  41. success: 'onLoadConfigsTags',
  42. error: ''
  43. });
  44. }
  45. },
  46. /**
  47. * construct URL parameters for config call
  48. * @param componentName
  49. * @param data
  50. * @return {Array}
  51. */
  52. getConfigUrlParams: function (componentName, data) {
  53. var urlParams = [];
  54. switch (componentName) {
  55. case 'OOZIE_SERVER':
  56. urlParams.push('(type=oozie-site&tag=' + data.Clusters.desired_configs['oozie-site'].tag + ')');
  57. break;
  58. case 'HIVE_SERVER':
  59. case 'HIVE_METASTORE':
  60. urlParams.push('(type=hive-site&tag=' + data.Clusters.desired_configs['hive-site'].tag + ')');
  61. break;
  62. }
  63. return urlParams;
  64. },
  65. onLoadConfigsTags: function (data) {
  66. var urlParams = this.getConfigUrlParams(this.get('content.reassign.component_name'), data);
  67. App.ajax.send({
  68. name: 'reassign.load_configs',
  69. sender: this,
  70. data: {
  71. urlParams: urlParams.join('|')
  72. },
  73. success: 'onLoadConfigs',
  74. error: ''
  75. });
  76. },
  77. onLoadConfigs: function (data) {
  78. var databaseProperty = data.items[0].properties[this.dbProperty()];
  79. var databaseType = databaseProperty.match(/MySQL|PostgreS|Oracle|Derby|MSSQL/gi)[0];
  80. if (databaseType !== 'derby') {
  81. App.router.reassignMasterController.set('content.hasManualSteps', false);
  82. }
  83. this.saveDatabaseType(databaseType)
  84. },
  85. saveDatabaseType: function(type) {
  86. if(type) {
  87. this.set('databaseType', type);
  88. App.router.get(this.get('content.controllerName')).saveDatabaseType(type);
  89. }
  90. }
  91. });