hdfs.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with this
  4. * work for additional information regarding copyright ownership. The ASF
  5. * licenses this file to you under the Apache License, Version 2.0 (the
  6. * "License"); you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. * License for the specific language governing permissions and limitations under
  15. * the License.
  16. */
  17. var App = require('app');
  18. require('utils/configs/modification_handlers/modification_handler');
  19. module.exports = App.ServiceConfigModificationHandler.create({
  20. serviceId : 'HDFS',
  21. getConfig : function(allConfigs, configName, configFilename, configServiceName) {
  22. return allConfigs.findProperty("serviceName", configServiceName).get("configs").find(function(config) {
  23. return configName == config.get('name') && (configFilename == null || configFilename == config.get('filename'));
  24. });
  25. },
  26. getDependentConfigChanges : function(changedConfig, selectedServices, allConfigs, securityEnabled) {
  27. var affectedProperties = [];
  28. var newValue = changedConfig.get("value");
  29. var rangerPluginEnabledName = "ranger-hdfs-plugin-enabled";
  30. var affectedPropertyName = changedConfig.get("name");
  31. if (affectedPropertyName == rangerPluginEnabledName) {
  32. var configDfsPermissionsEnabled = this.getConfig(allConfigs, 'dfs.permissions.enabled', 'hdfs-site.xml', 'HDFS');
  33. var rangerPluginEnabled = newValue == "Yes";
  34. var newDfsPermissionsEnabled = rangerPluginEnabled ? "true" : "true";
  35. // Add Hive-Ranger configs
  36. if (configDfsPermissionsEnabled != null && newDfsPermissionsEnabled !== configDfsPermissionsEnabled.get('value')) {
  37. affectedProperties.push({
  38. serviceName : "HDFS",
  39. sourceServiceName : "HDFS",
  40. propertyName : 'dfs.permissions.enabled',
  41. propertyDisplayName : 'dfs.permissions.enabled',
  42. newValue : newDfsPermissionsEnabled,
  43. curValue : configDfsPermissionsEnabled.get('value'),
  44. changedPropertyName : rangerPluginEnabledName,
  45. removed : false,
  46. filename : 'hdfs-site.xml'
  47. });
  48. }
  49. }
  50. return affectedProperties;
  51. }
  52. });