@Test public void testAmsLog4jUpdateConfigs() throws Exception { reset(clusters, cluster); expect(clusters.getClusters()).andReturn(ImmutableMap.of("normal", cluster)).once(); EasyMockSupport easyMockSupport = new EasyMockSupport(); Injector injector2 = easyMockSupport.createNiceMock(Injector.class); AmbariManagementControllerImpl controller = createMockBuilder(AmbariManagementControllerImpl.class) .addMockedMethod("createConfiguration") .addMockedMethod("getClusters", new Class[]{}) .addMockedMethod("createConfig") .withConstructor(actionManager, clusters, injector) .createNiceMock(); expect(injector2.getInstance(AmbariManagementController.class)).andReturn(controller).anyTimes(); expect(controller.getClusters()).andReturn(clusters).anyTimes(); Map<String, String> oldAmsLog4j = ImmutableMap.of( "content", "#\n" + "# Licensed to the Apache Software Foundation (ASF) under one\n" + "# or more contributor license agreements. See the NOTICE file\n" + "# distributed with this work for additional information\n" + "# regarding copyright ownership. The ASF licenses this file\n" + "# to you under the Apache License, Version 2.0 (the\n" + "# \"License\"); you may not use this file except in compliance\n" + "# with the License. You may obtain a copy of the License at\n" + "#\n" + "# http: "#\n" + "# Unless required by applicable law or agreed to in writing, software\n" + "# distributed under the License is distributed on an \"AS IS\" BASIS,\n" + "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + "# See the License for the specific language governing permissions and\n" + "# limitations under the License.\n" + "#\n" + "\n" + "# Define some default values that can be overridden by system properties\n" + "ams.log.dir=.\n" + "ams.log.file=ambari-metrics-collector.log\n" + "\n" + "# Root logger option\n" + "log4j.rootLogger=INFO,file\n" + "\n" + "# Direct log messages to a log file\n" + "log4j.appender.file=org.apache.log4j.RollingFileAppender\n" + "log4j.appender.file.File=${ams.log.dir}/${ams.log.file}\n" + "log4j.appender.file.MaxFileSize=10MB\n" + "log4j.appender.file.MaxBackupIndex=12\n" + "log4j.appender.file.layout=org.apache.log4j.PatternLayout\n" + "log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n"); Map<String, String> expectedAmsLog4j = new HashMap<>(); expectedAmsLog4j.put("content", "#\n" + "# Licensed to the Apache Software Foundation (ASF) under one\n" + "# or more contributor license agreements. See the NOTICE file\n" + "# distributed with this work for additional information\n" + "# regarding copyright ownership. The ASF licenses this file\n" + "# to you under the Apache License, Version 2.0 (the\n" + "# \"License\"); you may not use this file except in compliance\n" + "# with the License. You may obtain a copy of the License at\n" + "#\n" + "# http: "#\n" + "# Unless required by applicable law or agreed to in writing, software\n" + "# distributed under the License is distributed on an \"AS IS\" BASIS,\n" + "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + "# See the License for the specific language governing permissions and\n" + "# limitations under the License.\n" + "#\n" + "\n" + "# Define some default values that can be overridden by system properties\n" + "ams.log.dir=.\n" + "ams.log.file=ambari-metrics-collector.log\n" + "\n" + "# Root logger option\n" + "log4j.rootLogger=INFO,file\n" + "\n" + "# Direct log messages to a log file\n" + "log4j.appender.file=org.apache.log4j.RollingFileAppender\n" + "log4j.appender.file.File=${ams.log.dir}/${ams.log.file}\n" + "log4j.appender.file.MaxFileSize={{ams_log_max_backup_size}}MB\n" + "log4j.appender.file.MaxBackupIndex={{ams_log_number_of_backup_files}}\n" + "log4j.appender.file.layout=org.apache.log4j.PatternLayout\n" + "log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n"); expectedAmsLog4j.put("ams_log_max_backup_size", "10"); expectedAmsLog4j.put("ams_log_number_of_backup_files", "12"); Config mockAmsLog4j = easyMockSupport.createNiceMock(Config.class); expect(cluster.getDesiredConfigByType("ams-log4j")).andReturn(mockAmsLog4j).atLeastOnce(); expect(mockAmsLog4j.getProperties()).andReturn(oldAmsLog4j).anyTimes(); Capture<Map<String, String>> AmsLog4jCapture = EasyMock.newCapture(); expect(controller.createConfig(anyObject(Cluster.class), anyString(), capture(AmsLog4jCapture), anyString(), anyObject(Map.class))).andReturn(config).once(); Map<String, String> oldAmsHbaseLog4j = ImmutableMap.of( "content", "# Licensed to the Apache Software Foundation (ASF) under one\n" + "# or more contributor license agreements. See the NOTICE file\n" + "# distributed with this work for additional information\n" + "# regarding copyright ownership. The ASF licenses this file\n" + "# to you under the Apache License, Version 2.0 (the\n" + "# \"License\"); you may not use this file except in compliance\n" + "# with the License. You may obtain a copy of the License at\n" + "#\n" + "# http: "#\n" + "# Unless required by applicable law or agreed to in writing, software\n" + "# distributed under the License is distributed on an \"AS IS\" BASIS,\n" + "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + "# See the License for the specific language governing permissions and\n" + "# limitations under the License.\n" + "\n" + "\n" + "# Define some default values that can be overridden by system properties\n" + "hbase.root.logger=INFO,console\n" + "hbase.security.logger=INFO,console\n" + "hbase.log.dir=.\n" + "hbase.log.file=hbase.log\n" + "\n" + "# Define the root logger to the system property \"hbase.root.logger\".\n" + "log4j.rootLogger=${hbase.root.logger}\n" + "\n" + "# Logging Threshold\n" + "log4j.threshold=ALL\n" + "\n" + "#\n" + "# Daily Rolling File Appender\n" + "#\n" + "log4j.appender.DRFA=org.apache.log4j.DailyRollingFileAppender\n" + "log4j.appender.DRFA.File=${hbase.log.dir}/${hbase.log.file}\n" + "\n" + "# Rollver at midnight\n" + "log4j.appender.DRFA.DatePattern=.yyyy-MM-dd\n" + "\n" + "# 30-day backup\n" + "#log4j.appender.DRFA.MaxBackupIndex=30\n" + "log4j.appender.DRFA.layout=org.apache.log4j.PatternLayout\n" + "\n" + "# Pattern format: Date LogLevel LoggerName LogMessage\n" + "log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}: %m%n\n" + "\n" + "# Rolling File Appender properties\n" + "hbase.log.maxfilesize=256MB\n" + "hbase.log.maxbackupindex=20\n" + "\n" + "# Rolling File Appender\n" + "log4j.appender.RFA=org.apache.log4j.RollingFileAppender\n" + "log4j.appender.RFA.File=${hbase.log.dir}/${hbase.log.file}\n" + "\n" + "log4j.appender.RFA.MaxFileSize=${hbase.log.maxfilesize}\n" + "log4j.appender.RFA.MaxBackupIndex=${hbase.log.maxbackupindex}\n" + "\n" + "log4j.appender.RFA.layout=org.apache.log4j.PatternLayout\n" + "log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}: %m%n\n" + "\n" + "#\n" + "# Security audit appender\n" + "#\n" + "hbase.security.log.file=SecurityAuth.audit\n" + "hbase.security.log.maxfilesize=256MB\n" + "hbase.security.log.maxbackupindex=20\n" + "log4j.appender.RFAS=org.apache.log4j.RollingFileAppender\n" + "log4j.appender.RFAS.File=${hbase.log.dir}/${hbase.security.log.file}\n" + "log4j.appender.RFAS.MaxFileSize=${hbase.security.log.maxfilesize}\n" + "log4j.appender.RFAS.MaxBackupIndex=${hbase.security.log.maxbackupindex}\n" + "log4j.appender.RFAS.layout=org.apache.log4j.PatternLayout\n" + "log4j.appender.RFAS.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n\n" + "log4j.category.SecurityLogger=${hbase.security.logger}\n" + "log4j.additivity.SecurityLogger=false\n" + "#log4j.logger.SecurityLogger.org.apache.hadoop.hbase.security.access.AccessController=TRACE\n" + "\n" + "#\n" + "# Null Appender\n" + "#\n" + "log4j.appender.NullAppender=org.apache.log4j.varia.NullAppender\n" + "\n" + "#\n" + "# console\n" + "# Add \"console\" to rootlogger above if you want to use this\n" + "#\n" + "log4j.appender.console=org.apache.log4j.ConsoleAppender\n" + "log4j.appender.console.target=System.err\n" + "log4j.appender.console.layout=org.apache.log4j.PatternLayout\n" + "log4j.appender.console.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}: %m%n\n" + "\n" + "# Custom Logging levels\n" + "\n" + "log4j.logger.org.apache.zookeeper=INFO\n" + "#log4j.logger.org.apache.hadoop.fs.FSNamesystem=DEBUG\n" + "log4j.logger.org.apache.hadoop.hbase=INFO\n" + "# Make these two classes INFO-level. Make them DEBUG to see more zk debug.\n" + "log4j.logger.org.apache.hadoop.hbase.zookeeper.ZKUtil=INFO\n" + "log4j.logger.org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher=INFO\n" + "#log4j.logger.org.apache.hadoop.dfs=DEBUG\n" + "# Set this class to log INFO only otherwise its OTT\n" + "# Enable this to get detailed connection error/retry logging.\n" + "# log4j.logger.org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation=TRACE\n" + "\n" + "\n" + "# Uncomment this line to enable tracing on _every_ RPC call (this can be a lot of output)\n" + "#log4j.logger.org.apache.hadoop.ipc.HBaseServer.trace=DEBUG\n" + "\n" + "# Uncomment the below if you want to remove logging of client region caching'\n" + "# and scan of .META. messages\n" + "# log4j.logger.org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation=INFO\n" + "# log4j.logger.org.apache.hadoop.hbase.client.MetaScanner=INFO\n"); Map<String, String> expectedAmsHbaseLog4j = new HashMap<String, String>(); expectedAmsHbaseLog4j.put("content", "# Licensed to the Apache Software Foundation (ASF) under one\n" + "# or more contributor license agreements. See the NOTICE file\n" + "# distributed with this work for additional information\n" + "# regarding copyright ownership. The ASF licenses this file\n" + "# to you under the Apache License, Version 2.0 (the\n" + "# \"License\"); you may not use this file except in compliance\n" + "# with the License. You may obtain a copy of the License at\n" + "#\n" + "# http: "#\n" + "# Unless required by applicable law or agreed to in writing, software\n" + "# distributed under the License is distributed on an \"AS IS\" BASIS,\n" + "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + "# See the License for the specific language governing permissions and\n" + "# limitations under the License.\n" + "\n" + "\n" + "# Define some default values that can be overridden by system properties\n" + "hbase.root.logger=INFO,console\n" + "hbase.security.logger=INFO,console\n" + "hbase.log.dir=.\n" + "hbase.log.file=hbase.log\n" + "\n" + "# Define the root logger to the system property \"hbase.root.logger\".\n" + "log4j.rootLogger=${hbase.root.logger}\n" + "\n" + "# Logging Threshold\n" + "log4j.threshold=ALL\n" + "\n" + "#\n" + "# Daily Rolling File Appender\n" + "#\n" + "log4j.appender.DRFA=org.apache.log4j.DailyRollingFileAppender\n" + "log4j.appender.DRFA.File=${hbase.log.dir}/${hbase.log.file}\n" + "\n" + "# Rollver at midnight\n" + "log4j.appender.DRFA.DatePattern=.yyyy-MM-dd\n" + "\n" + "# 30-day backup\n" + "#log4j.appender.DRFA.MaxBackupIndex=30\n" + "log4j.appender.DRFA.layout=org.apache.log4j.PatternLayout\n" + "\n" + "# Pattern format: Date LogLevel LoggerName LogMessage\n" + "log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}: %m%n\n" + "\n" + "# Rolling File Appender properties\n" + "hbase.log.maxfilesize={{ams_hbase_log_maxfilesize}}MB\n" + "hbase.log.maxbackupindex={{ams_hbase_log_maxbackupindex}}\n" + "\n" + "# Rolling File Appender\n" + "log4j.appender.RFA=org.apache.log4j.RollingFileAppender\n" + "log4j.appender.RFA.File=${hbase.log.dir}/${hbase.log.file}\n" + "\n" + "log4j.appender.RFA.MaxFileSize=${hbase.log.maxfilesize}\n" + "log4j.appender.RFA.MaxBackupIndex=${hbase.log.maxbackupindex}\n" + "\n" + "log4j.appender.RFA.layout=org.apache.log4j.PatternLayout\n" + "log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}: %m%n\n" + "\n" + "#\n" + "# Security audit appender\n" + "#\n" + "hbase.security.log.file=SecurityAuth.audit\n" + "hbase.security.log.maxfilesize={{ams_hbase_security_log_maxfilesize}}MB\n" + "hbase.security.log.maxbackupindex={{ams_hbase_security_log_maxbackupindex}}\n" + "log4j.appender.RFAS=org.apache.log4j.RollingFileAppender\n" + "log4j.appender.RFAS.File=${hbase.log.dir}/${hbase.security.log.file}\n" + "log4j.appender.RFAS.MaxFileSize=${hbase.security.log.maxfilesize}\n" + "log4j.appender.RFAS.MaxBackupIndex=${hbase.security.log.maxbackupindex}\n" + "log4j.appender.RFAS.layout=org.apache.log4j.PatternLayout\n" + "log4j.appender.RFAS.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n\n" + "log4j.category.SecurityLogger=${hbase.security.logger}\n" + "log4j.additivity.SecurityLogger=false\n" + "#log4j.logger.SecurityLogger.org.apache.hadoop.hbase.security.access.AccessController=TRACE\n" + "\n" + "#\n" + "# Null Appender\n" + "#\n" + "log4j.appender.NullAppender=org.apache.log4j.varia.NullAppender\n" + "\n" + "#\n" + "# console\n" + "# Add \"console\" to rootlogger above if you want to use this\n" + "#\n" + "log4j.appender.console=org.apache.log4j.ConsoleAppender\n" + "log4j.appender.console.target=System.err\n" + "log4j.appender.console.layout=org.apache.log4j.PatternLayout\n" + "log4j.appender.console.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{2}: %m%n\n" + "\n" + "# Custom Logging levels\n" + "\n" + "log4j.logger.org.apache.zookeeper=INFO\n" + "#log4j.logger.org.apache.hadoop.fs.FSNamesystem=DEBUG\n" + "log4j.logger.org.apache.hadoop.hbase=INFO\n" + "# Make these two classes INFO-level. Make them DEBUG to see more zk debug.\n" + "log4j.logger.org.apache.hadoop.hbase.zookeeper.ZKUtil=INFO\n" + "log4j.logger.org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher=INFO\n" + "#log4j.logger.org.apache.hadoop.dfs=DEBUG\n" + "# Set this class to log INFO only otherwise its OTT\n" + "# Enable this to get detailed connection error/retry logging.\n" + "# log4j.logger.org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation=TRACE\n" + "\n" + "\n" + "# Uncomment this line to enable tracing on _every_ RPC call (this can be a lot of output)\n" + "#log4j.logger.org.apache.hadoop.ipc.HBaseServer.trace=DEBUG\n" + "\n" + "# Uncomment the below if you want to remove logging of client region caching'\n" + "# and scan of .META. messages\n" + "# log4j.logger.org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation=INFO\n" + "# log4j.logger.org.apache.hadoop.hbase.client.MetaScanner=INFO\n"); expectedAmsHbaseLog4j.put("ams_hbase_log_maxfilesize", "256"); expectedAmsHbaseLog4j.put("ams_hbase_log_maxbackupindex", "20"); expectedAmsHbaseLog4j.put("ams_hbase_security_log_maxfilesize", "256"); expectedAmsHbaseLog4j.put("ams_hbase_security_log_maxbackupindex", "20"); Config mockAmsHbaseLog4j = easyMockSupport.createNiceMock(Config.class); expect(cluster.getDesiredConfigByType("ams-hbase-log4j")).andReturn(mockAmsHbaseLog4j).atLeastOnce(); expect(mockAmsHbaseLog4j.getProperties()).andReturn(oldAmsHbaseLog4j).anyTimes(); Capture<Map<String, String>> AmsHbaseLog4jCapture = EasyMock.newCapture(); expect(controller.createConfig(anyObject(Cluster.class), anyString(), capture(AmsHbaseLog4jCapture), anyString(), anyObject(Map.class))).andReturn(config).once(); replay(clusters, cluster); replay(controller, injector2); replay(mockAmsLog4j, mockAmsHbaseLog4j); new UpgradeCatalog250(injector2).updateAMSConfigs(); easyMockSupport.verifyAll(); Map<String, String> updatedAmsLog4jProperties = AmsLog4jCapture.getValue(); assertTrue(Maps.difference(expectedAmsLog4j, updatedAmsLog4jProperties).areEqual()); Map<String, String> updatedAmsHbaseLog4jProperties = AmsHbaseLog4jCapture.getValue(); assertTrue(Maps.difference(expectedAmsHbaseLog4j, updatedAmsHbaseLog4jProperties).areEqual()); }
protected void updateAMSConfigs() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); if (clusters != null) { Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (final Cluster cluster : clusterMap.values()) { Config amsEnv = cluster.getDesiredConfigByType(AMS_ENV); if (amsEnv != null) { Map<String, String> amsEnvProperties = amsEnv.getProperties(); String content = amsEnvProperties.get("content"); Map<String, String> newProperties = new HashMap<>(); newProperties.put("content", updateAmsEnvContent(content)); updateConfigurationPropertiesForCluster(cluster, AMS_ENV, newProperties, true, true); } boolean isDistributed = false; Config amsSite = cluster.getDesiredConfigByType(AMS_SITE); if (amsSite != null) { if ("distributed".equals(amsSite.getProperties().get(AMS_MODE))) { isDistributed = true; } Map<String, String> amsSiteProperties = amsSite.getProperties(); if (amsSiteProperties != null && amsSiteProperties.containsKey("timeline.metrics.hbase.fifo.compaction.enabled")) { LOG.info("Removing timeline.metrics.hbase.fifo.compaction.enabled from ams-site"); removeConfigurationPropertiesFromCluster(cluster, AMS_SITE, Collections.singleton("timeline.metrics.hbase.fifo.compaction.enabled")); } } if (isDistributed) { Config amsHbaseSite = cluster.getDesiredConfigByType(AMS_HBASE_SITE); if (amsHbaseSite != null) { Map<String, String> amsHbaseSiteProperties = amsHbaseSite.getProperties(); String rootDir = amsHbaseSiteProperties.get(HBASE_ROOTDIR); if (StringUtils.isNotEmpty(rootDir) && rootDir.startsWith("hdfs: int indexOfSlash = rootDir.indexOf("/", 7); Map<String, String> newProperties = new HashMap<>(); String newRootdir = rootDir.substring(indexOfSlash); newProperties.put(HBASE_ROOTDIR, newRootdir); LOG.info("Changing ams-hbase-site rootdir to " + newRootdir); updateConfigurationPropertiesForCluster(cluster, AMS_HBASE_SITE, newProperties, true, true); } } } Config amsLog4jProperties = cluster.getDesiredConfigByType(AMS_LOG4J); if(amsLog4jProperties != null){ Map<String, String> newProperties = new HashMap<>(); String content = amsLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content,"ams_log_max_backup_size","ams_log_max_backup_size","log4j.appender.file.MaxFileSize=(\\w+)MB","80",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_log_number_of_backup_files","ams_log_number_of_backup_files","log4j.appender.file.MaxBackupIndex=(\\w+)","60",newProperties); newProperties.put("content",content); updateConfigurationPropertiesForCluster(cluster,AMS_LOG4J,newProperties,true,true); } Config amsHbaseLog4jProperties = cluster.getDesiredConfigByType(AMS_HBASE_LOG4J); if(amsHbaseLog4jProperties != null){ Map<String, String> newProperties = new HashMap<>(); String content = amsHbaseLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_log_maxfilesize","ams_hbase_log_maxfilesize","hbase.log.maxfilesize=(\\w+)MB","256",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_log_maxbackupindex","ams_hbase_log_maxbackupindex","hbase.log.maxbackupindex=(\\w+)","20",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_security_log_maxfilesize","ams_hbase_security_log_maxfilesize","hbase.security.log.maxfilesize=(\\w+)MB","256",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_security_log_maxbackupindex","ams_hbase_security_log_maxbackupindex","hbase.security.log.maxbackupindex=(\\w+)","20",newProperties); newProperties.put("content",content); updateConfigurationPropertiesForCluster(cluster,AMS_HBASE_LOG4J,newProperties,true,true); } Config amsGrafanaIni = cluster.getDesiredConfigByType(AMS_GRAFANA_INI); if (amsGrafanaIni != null) { Map<String, String> amsGrafanaIniProperties = amsGrafanaIni.getProperties(); String content = amsGrafanaIniProperties.get("content"); Map<String, String> newProperties = new HashMap<>(); newProperties.put("content", updateAmsGrafanaIniContent(content)); updateConfigurationPropertiesForCluster(cluster, AMS_GRAFANA_INI, newProperties, true, true); } } } } }
UpgradeCatalog250 extends AbstractUpgradeCatalog { protected void updateAMSConfigs() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); if (clusters != null) { Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (final Cluster cluster : clusterMap.values()) { Config amsEnv = cluster.getDesiredConfigByType(AMS_ENV); if (amsEnv != null) { Map<String, String> amsEnvProperties = amsEnv.getProperties(); String content = amsEnvProperties.get("content"); Map<String, String> newProperties = new HashMap<>(); newProperties.put("content", updateAmsEnvContent(content)); updateConfigurationPropertiesForCluster(cluster, AMS_ENV, newProperties, true, true); } boolean isDistributed = false; Config amsSite = cluster.getDesiredConfigByType(AMS_SITE); if (amsSite != null) { if ("distributed".equals(amsSite.getProperties().get(AMS_MODE))) { isDistributed = true; } Map<String, String> amsSiteProperties = amsSite.getProperties(); if (amsSiteProperties != null && amsSiteProperties.containsKey("timeline.metrics.hbase.fifo.compaction.enabled")) { LOG.info("Removing timeline.metrics.hbase.fifo.compaction.enabled from ams-site"); removeConfigurationPropertiesFromCluster(cluster, AMS_SITE, Collections.singleton("timeline.metrics.hbase.fifo.compaction.enabled")); } } if (isDistributed) { Config amsHbaseSite = cluster.getDesiredConfigByType(AMS_HBASE_SITE); if (amsHbaseSite != null) { Map<String, String> amsHbaseSiteProperties = amsHbaseSite.getProperties(); String rootDir = amsHbaseSiteProperties.get(HBASE_ROOTDIR); if (StringUtils.isNotEmpty(rootDir) && rootDir.startsWith("hdfs: int indexOfSlash = rootDir.indexOf("/", 7); Map<String, String> newProperties = new HashMap<>(); String newRootdir = rootDir.substring(indexOfSlash); newProperties.put(HBASE_ROOTDIR, newRootdir); LOG.info("Changing ams-hbase-site rootdir to " + newRootdir); updateConfigurationPropertiesForCluster(cluster, AMS_HBASE_SITE, newProperties, true, true); } } } Config amsLog4jProperties = cluster.getDesiredConfigByType(AMS_LOG4J); if(amsLog4jProperties != null){ Map<String, String> newProperties = new HashMap<>(); String content = amsLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content,"ams_log_max_backup_size","ams_log_max_backup_size","log4j.appender.file.MaxFileSize=(\\w+)MB","80",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_log_number_of_backup_files","ams_log_number_of_backup_files","log4j.appender.file.MaxBackupIndex=(\\w+)","60",newProperties); newProperties.put("content",content); updateConfigurationPropertiesForCluster(cluster,AMS_LOG4J,newProperties,true,true); } Config amsHbaseLog4jProperties = cluster.getDesiredConfigByType(AMS_HBASE_LOG4J); if(amsHbaseLog4jProperties != null){ Map<String, String> newProperties = new HashMap<>(); String content = amsHbaseLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_log_maxfilesize","ams_hbase_log_maxfilesize","hbase.log.maxfilesize=(\\w+)MB","256",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_log_maxbackupindex","ams_hbase_log_maxbackupindex","hbase.log.maxbackupindex=(\\w+)","20",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_security_log_maxfilesize","ams_hbase_security_log_maxfilesize","hbase.security.log.maxfilesize=(\\w+)MB","256",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_security_log_maxbackupindex","ams_hbase_security_log_maxbackupindex","hbase.security.log.maxbackupindex=(\\w+)","20",newProperties); newProperties.put("content",content); updateConfigurationPropertiesForCluster(cluster,AMS_HBASE_LOG4J,newProperties,true,true); } Config amsGrafanaIni = cluster.getDesiredConfigByType(AMS_GRAFANA_INI); if (amsGrafanaIni != null) { Map<String, String> amsGrafanaIniProperties = amsGrafanaIni.getProperties(); String content = amsGrafanaIniProperties.get("content"); Map<String, String> newProperties = new HashMap<>(); newProperties.put("content", updateAmsGrafanaIniContent(content)); updateConfigurationPropertiesForCluster(cluster, AMS_GRAFANA_INI, newProperties, true, true); } } } } } }
UpgradeCatalog250 extends AbstractUpgradeCatalog { protected void updateAMSConfigs() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); if (clusters != null) { Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (final Cluster cluster : clusterMap.values()) { Config amsEnv = cluster.getDesiredConfigByType(AMS_ENV); if (amsEnv != null) { Map<String, String> amsEnvProperties = amsEnv.getProperties(); String content = amsEnvProperties.get("content"); Map<String, String> newProperties = new HashMap<>(); newProperties.put("content", updateAmsEnvContent(content)); updateConfigurationPropertiesForCluster(cluster, AMS_ENV, newProperties, true, true); } boolean isDistributed = false; Config amsSite = cluster.getDesiredConfigByType(AMS_SITE); if (amsSite != null) { if ("distributed".equals(amsSite.getProperties().get(AMS_MODE))) { isDistributed = true; } Map<String, String> amsSiteProperties = amsSite.getProperties(); if (amsSiteProperties != null && amsSiteProperties.containsKey("timeline.metrics.hbase.fifo.compaction.enabled")) { LOG.info("Removing timeline.metrics.hbase.fifo.compaction.enabled from ams-site"); removeConfigurationPropertiesFromCluster(cluster, AMS_SITE, Collections.singleton("timeline.metrics.hbase.fifo.compaction.enabled")); } } if (isDistributed) { Config amsHbaseSite = cluster.getDesiredConfigByType(AMS_HBASE_SITE); if (amsHbaseSite != null) { Map<String, String> amsHbaseSiteProperties = amsHbaseSite.getProperties(); String rootDir = amsHbaseSiteProperties.get(HBASE_ROOTDIR); if (StringUtils.isNotEmpty(rootDir) && rootDir.startsWith("hdfs: int indexOfSlash = rootDir.indexOf("/", 7); Map<String, String> newProperties = new HashMap<>(); String newRootdir = rootDir.substring(indexOfSlash); newProperties.put(HBASE_ROOTDIR, newRootdir); LOG.info("Changing ams-hbase-site rootdir to " + newRootdir); updateConfigurationPropertiesForCluster(cluster, AMS_HBASE_SITE, newProperties, true, true); } } } Config amsLog4jProperties = cluster.getDesiredConfigByType(AMS_LOG4J); if(amsLog4jProperties != null){ Map<String, String> newProperties = new HashMap<>(); String content = amsLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content,"ams_log_max_backup_size","ams_log_max_backup_size","log4j.appender.file.MaxFileSize=(\\w+)MB","80",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_log_number_of_backup_files","ams_log_number_of_backup_files","log4j.appender.file.MaxBackupIndex=(\\w+)","60",newProperties); newProperties.put("content",content); updateConfigurationPropertiesForCluster(cluster,AMS_LOG4J,newProperties,true,true); } Config amsHbaseLog4jProperties = cluster.getDesiredConfigByType(AMS_HBASE_LOG4J); if(amsHbaseLog4jProperties != null){ Map<String, String> newProperties = new HashMap<>(); String content = amsHbaseLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_log_maxfilesize","ams_hbase_log_maxfilesize","hbase.log.maxfilesize=(\\w+)MB","256",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_log_maxbackupindex","ams_hbase_log_maxbackupindex","hbase.log.maxbackupindex=(\\w+)","20",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_security_log_maxfilesize","ams_hbase_security_log_maxfilesize","hbase.security.log.maxfilesize=(\\w+)MB","256",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_security_log_maxbackupindex","ams_hbase_security_log_maxbackupindex","hbase.security.log.maxbackupindex=(\\w+)","20",newProperties); newProperties.put("content",content); updateConfigurationPropertiesForCluster(cluster,AMS_HBASE_LOG4J,newProperties,true,true); } Config amsGrafanaIni = cluster.getDesiredConfigByType(AMS_GRAFANA_INI); if (amsGrafanaIni != null) { Map<String, String> amsGrafanaIniProperties = amsGrafanaIni.getProperties(); String content = amsGrafanaIniProperties.get("content"); Map<String, String> newProperties = new HashMap<>(); newProperties.put("content", updateAmsGrafanaIniContent(content)); updateConfigurationPropertiesForCluster(cluster, AMS_GRAFANA_INI, newProperties, true, true); } } } } } @Inject  UpgradeCatalog250(Injector injector); }
UpgradeCatalog250 extends AbstractUpgradeCatalog { protected void updateAMSConfigs() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); if (clusters != null) { Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (final Cluster cluster : clusterMap.values()) { Config amsEnv = cluster.getDesiredConfigByType(AMS_ENV); if (amsEnv != null) { Map<String, String> amsEnvProperties = amsEnv.getProperties(); String content = amsEnvProperties.get("content"); Map<String, String> newProperties = new HashMap<>(); newProperties.put("content", updateAmsEnvContent(content)); updateConfigurationPropertiesForCluster(cluster, AMS_ENV, newProperties, true, true); } boolean isDistributed = false; Config amsSite = cluster.getDesiredConfigByType(AMS_SITE); if (amsSite != null) { if ("distributed".equals(amsSite.getProperties().get(AMS_MODE))) { isDistributed = true; } Map<String, String> amsSiteProperties = amsSite.getProperties(); if (amsSiteProperties != null && amsSiteProperties.containsKey("timeline.metrics.hbase.fifo.compaction.enabled")) { LOG.info("Removing timeline.metrics.hbase.fifo.compaction.enabled from ams-site"); removeConfigurationPropertiesFromCluster(cluster, AMS_SITE, Collections.singleton("timeline.metrics.hbase.fifo.compaction.enabled")); } } if (isDistributed) { Config amsHbaseSite = cluster.getDesiredConfigByType(AMS_HBASE_SITE); if (amsHbaseSite != null) { Map<String, String> amsHbaseSiteProperties = amsHbaseSite.getProperties(); String rootDir = amsHbaseSiteProperties.get(HBASE_ROOTDIR); if (StringUtils.isNotEmpty(rootDir) && rootDir.startsWith("hdfs: int indexOfSlash = rootDir.indexOf("/", 7); Map<String, String> newProperties = new HashMap<>(); String newRootdir = rootDir.substring(indexOfSlash); newProperties.put(HBASE_ROOTDIR, newRootdir); LOG.info("Changing ams-hbase-site rootdir to " + newRootdir); updateConfigurationPropertiesForCluster(cluster, AMS_HBASE_SITE, newProperties, true, true); } } } Config amsLog4jProperties = cluster.getDesiredConfigByType(AMS_LOG4J); if(amsLog4jProperties != null){ Map<String, String> newProperties = new HashMap<>(); String content = amsLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content,"ams_log_max_backup_size","ams_log_max_backup_size","log4j.appender.file.MaxFileSize=(\\w+)MB","80",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_log_number_of_backup_files","ams_log_number_of_backup_files","log4j.appender.file.MaxBackupIndex=(\\w+)","60",newProperties); newProperties.put("content",content); updateConfigurationPropertiesForCluster(cluster,AMS_LOG4J,newProperties,true,true); } Config amsHbaseLog4jProperties = cluster.getDesiredConfigByType(AMS_HBASE_LOG4J); if(amsHbaseLog4jProperties != null){ Map<String, String> newProperties = new HashMap<>(); String content = amsHbaseLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_log_maxfilesize","ams_hbase_log_maxfilesize","hbase.log.maxfilesize=(\\w+)MB","256",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_log_maxbackupindex","ams_hbase_log_maxbackupindex","hbase.log.maxbackupindex=(\\w+)","20",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_security_log_maxfilesize","ams_hbase_security_log_maxfilesize","hbase.security.log.maxfilesize=(\\w+)MB","256",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_security_log_maxbackupindex","ams_hbase_security_log_maxbackupindex","hbase.security.log.maxbackupindex=(\\w+)","20",newProperties); newProperties.put("content",content); updateConfigurationPropertiesForCluster(cluster,AMS_HBASE_LOG4J,newProperties,true,true); } Config amsGrafanaIni = cluster.getDesiredConfigByType(AMS_GRAFANA_INI); if (amsGrafanaIni != null) { Map<String, String> amsGrafanaIniProperties = amsGrafanaIni.getProperties(); String content = amsGrafanaIniProperties.get("content"); Map<String, String> newProperties = new HashMap<>(); newProperties.put("content", updateAmsGrafanaIniContent(content)); updateConfigurationPropertiesForCluster(cluster, AMS_GRAFANA_INI, newProperties, true, true); } } } } } @Inject  UpgradeCatalog250(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); }
UpgradeCatalog250 extends AbstractUpgradeCatalog { protected void updateAMSConfigs() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); if (clusters != null) { Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (final Cluster cluster : clusterMap.values()) { Config amsEnv = cluster.getDesiredConfigByType(AMS_ENV); if (amsEnv != null) { Map<String, String> amsEnvProperties = amsEnv.getProperties(); String content = amsEnvProperties.get("content"); Map<String, String> newProperties = new HashMap<>(); newProperties.put("content", updateAmsEnvContent(content)); updateConfigurationPropertiesForCluster(cluster, AMS_ENV, newProperties, true, true); } boolean isDistributed = false; Config amsSite = cluster.getDesiredConfigByType(AMS_SITE); if (amsSite != null) { if ("distributed".equals(amsSite.getProperties().get(AMS_MODE))) { isDistributed = true; } Map<String, String> amsSiteProperties = amsSite.getProperties(); if (amsSiteProperties != null && amsSiteProperties.containsKey("timeline.metrics.hbase.fifo.compaction.enabled")) { LOG.info("Removing timeline.metrics.hbase.fifo.compaction.enabled from ams-site"); removeConfigurationPropertiesFromCluster(cluster, AMS_SITE, Collections.singleton("timeline.metrics.hbase.fifo.compaction.enabled")); } } if (isDistributed) { Config amsHbaseSite = cluster.getDesiredConfigByType(AMS_HBASE_SITE); if (amsHbaseSite != null) { Map<String, String> amsHbaseSiteProperties = amsHbaseSite.getProperties(); String rootDir = amsHbaseSiteProperties.get(HBASE_ROOTDIR); if (StringUtils.isNotEmpty(rootDir) && rootDir.startsWith("hdfs: int indexOfSlash = rootDir.indexOf("/", 7); Map<String, String> newProperties = new HashMap<>(); String newRootdir = rootDir.substring(indexOfSlash); newProperties.put(HBASE_ROOTDIR, newRootdir); LOG.info("Changing ams-hbase-site rootdir to " + newRootdir); updateConfigurationPropertiesForCluster(cluster, AMS_HBASE_SITE, newProperties, true, true); } } } Config amsLog4jProperties = cluster.getDesiredConfigByType(AMS_LOG4J); if(amsLog4jProperties != null){ Map<String, String> newProperties = new HashMap<>(); String content = amsLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content,"ams_log_max_backup_size","ams_log_max_backup_size","log4j.appender.file.MaxFileSize=(\\w+)MB","80",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_log_number_of_backup_files","ams_log_number_of_backup_files","log4j.appender.file.MaxBackupIndex=(\\w+)","60",newProperties); newProperties.put("content",content); updateConfigurationPropertiesForCluster(cluster,AMS_LOG4J,newProperties,true,true); } Config amsHbaseLog4jProperties = cluster.getDesiredConfigByType(AMS_HBASE_LOG4J); if(amsHbaseLog4jProperties != null){ Map<String, String> newProperties = new HashMap<>(); String content = amsHbaseLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_log_maxfilesize","ams_hbase_log_maxfilesize","hbase.log.maxfilesize=(\\w+)MB","256",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_log_maxbackupindex","ams_hbase_log_maxbackupindex","hbase.log.maxbackupindex=(\\w+)","20",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_security_log_maxfilesize","ams_hbase_security_log_maxfilesize","hbase.security.log.maxfilesize=(\\w+)MB","256",newProperties); content = SchemaUpgradeUtil.extractProperty(content,"ams_hbase_security_log_maxbackupindex","ams_hbase_security_log_maxbackupindex","hbase.security.log.maxbackupindex=(\\w+)","20",newProperties); newProperties.put("content",content); updateConfigurationPropertiesForCluster(cluster,AMS_HBASE_LOG4J,newProperties,true,true); } Config amsGrafanaIni = cluster.getDesiredConfigByType(AMS_GRAFANA_INI); if (amsGrafanaIni != null) { Map<String, String> amsGrafanaIniProperties = amsGrafanaIni.getProperties(); String content = amsGrafanaIniProperties.get("content"); Map<String, String> newProperties = new HashMap<>(); newProperties.put("content", updateAmsGrafanaIniContent(content)); updateConfigurationPropertiesForCluster(cluster, AMS_GRAFANA_INI, newProperties, true, true); } } } } } @Inject  UpgradeCatalog250(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); static final String COMPONENT_TABLE; static final String COMPONENT_VERSION_TABLE; static final String COMPONENT_VERSION_PK; static final String COMPONENT_VERSION_FK_COMPONENT; static final String COMPONENT_VERSION_FK_REPO_VERSION; }