@Test public void testLogSearchUpdateConfigs() 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> oldLogSearchProperties = ImmutableMap.of( "logsearch.external.auth.enabled", "true", "logsearch.external.auth.host_url", "host_url", "logsearch.external.auth.login_url", "login_url"); Map<String, String> expectedLogSearchProperties = ImmutableMap.of( "logsearch.auth.external_auth.enabled", "true", "logsearch.auth.external_auth.host_url", "host_url", "logsearch.auth.external_auth.login_url", "login_url"); Config mockLogSearchProperties = easyMockSupport.createNiceMock(Config.class); expect(cluster.getDesiredConfigByType("logsearch-properties")).andReturn(mockLogSearchProperties).atLeastOnce(); expect(mockLogSearchProperties.getProperties()).andReturn(oldLogSearchProperties).anyTimes(); Capture<Map<String, String>> logSearchPropertiesCapture = EasyMock.newCapture(); expect(controller.createConfig(anyObject(Cluster.class), anyString(), capture(logSearchPropertiesCapture), anyString(), EasyMock.<Map<String, Map<String, String>>>anyObject())).andReturn(config).once(); Map<String, String> oldLogFeederEnv = ImmutableMap.of( "content", "infra_solr_ssl_enabled"); Map<String, String> expectedLogFeederEnv = ImmutableMap.of( "content", "logfeeder_use_ssl"); Config mockLogFeederEnv = easyMockSupport.createNiceMock(Config.class); expect(cluster.getDesiredConfigByType("logfeeder-env")).andReturn(mockLogFeederEnv).atLeastOnce(); expect(mockLogFeederEnv.getProperties()).andReturn(oldLogFeederEnv).anyTimes(); Capture<Map<String, String>> logFeederEnvCapture = EasyMock.newCapture(); expect(controller.createConfig(anyObject(Cluster.class), anyString(), capture(logFeederEnvCapture), anyString(), EasyMock.<Map<String, Map<String, String>>>anyObject())).andReturn(config).once(); Map<String, String> oldLogSearchEnv = new HashMap<>(); oldLogSearchEnv.put("logsearch_solr_audit_logs_use_ranger", "false"); oldLogSearchEnv.put("logsearch_solr_audit_logs_zk_node", "zk_node"); oldLogSearchEnv.put("logsearch_solr_audit_logs_zk_quorum", "zk_quorum"); oldLogSearchEnv.put("logsearch_ui_protocol", "http"); oldLogSearchEnv.put("logsearch_truststore_location", "/etc/security/serverKeys/logsearch.trustStore.jks"); oldLogSearchEnv.put("logsearch_keystore_location", "/etc/security/serverKeys/logsearch.keyStore.jks"); oldLogSearchEnv.put("content", "infra_solr_ssl_enabled or logsearch_ui_protocol == 'https'"); Map<String, String> expectedLogSearchEnv = ImmutableMap.of( "logsearch_ui_protocol", "http", "logsearch_truststore_location", "/etc/ambari-logsearch-portal/conf/keys/logsearch.jks", "logsearch_keystore_location", "/etc/ambari-logsearch-portal/conf/keys/logsearch.jks", "content", "logsearch_use_ssl"); Config mockLogSearchEnv = easyMockSupport.createNiceMock(Config.class); expect(cluster.getDesiredConfigByType("logsearch-env")).andReturn(mockLogSearchEnv).atLeastOnce(); expect(mockLogSearchEnv.getProperties()).andReturn(oldLogSearchEnv).anyTimes(); Capture<Map<String, String>> logSearchEnvCapture = EasyMock.newCapture(); expect(controller.createConfig(anyObject(Cluster.class), anyString(), capture(logSearchEnvCapture), anyString(), EasyMock.<Map<String, Map<String, String>>>anyObject())).andReturn(config).once(); Map<String, String> oldLogFeederLog4j = ImmutableMap.of( "content", " <appender name=\"rolling_file\" class=\"org.apache.log4j.RollingFileAppender\">\n" + " <param name=\"file\" value=\"{{logfeeder_log_dir}}/logfeeder.log\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"11MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"12\"/>\n" + " <layout class=\"org.apache.log4j.PatternLayout\">\n" + " <param name=\"ConversionPattern\" value=\"%d [%t] %-5p %C{6} (%F:%L) - %m%n\"/>\n" + " </layout>\n" + " </appender>\n" + "\n" + " <appender name=\"rolling_file_json\"\n" + " class=\"org.apache.ambari.logsearch.appender.LogsearchRollingFileAppender\">\n" + " <param name=\"file\" value=\"{{logfeeder_log_dir}}/logsearch-logfeeder.json\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"13MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"14\" />\n" + " <layout class=\"org.apache.ambari.logsearch.appender.LogsearchConversion\" />\n" + " </appender>"); Map<String, String> expectedLogFeederLog4j = ImmutableMap.of( "content", " <appender name=\"rolling_file\" class=\"org.apache.log4j.RollingFileAppender\">\n" + " <param name=\"file\" value=\"{{logfeeder_log_dir}}/logfeeder.log\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"{{logfeeder_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"{{logfeeder_log_maxbackupindex}}\"/>\n" + " <layout class=\"org.apache.log4j.PatternLayout\">\n" + " <param name=\"ConversionPattern\" value=\"%d [%t] %-5p %C{6} (%F:%L) - %m%n\"/>\n" + " </layout>\n" + " </appender>\n" + "\n" + " <appender name=\"rolling_file_json\"\n" + " class=\"org.apache.ambari.logsearch.appender.LogsearchRollingFileAppender\">\n" + " <param name=\"file\" value=\"{{logfeeder_log_dir}}/logsearch-logfeeder.json\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"{{logfeeder_json_log_maxfilesize}}MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"{{logfeeder_json_log_maxbackupindex}}\" />\n" + " <layout class=\"org.apache.ambari.logsearch.appender.LogsearchConversion\" />\n" + " </appender>", "logfeeder_log_maxfilesize", "11", "logfeeder_log_maxbackupindex", "12", "logfeeder_json_log_maxfilesize", "13", "logfeeder_json_log_maxbackupindex", "14"); Config mockLogFeederLog4j = easyMockSupport.createNiceMock(Config.class); expect(cluster.getDesiredConfigByType("logfeeder-log4j")).andReturn(mockLogFeederLog4j).atLeastOnce(); expect(mockLogFeederLog4j.getProperties()).andReturn(oldLogFeederLog4j).anyTimes(); Capture<Map<String, String>> logFeederLog4jCapture = EasyMock.newCapture(); expect(controller.createConfig(anyObject(Cluster.class), anyString(), capture(logFeederLog4jCapture), anyString(), EasyMock.<Map<String, Map<String, String>>>anyObject())).andReturn(config).once(); Map<String, String> oldLogSearchLog4j = ImmutableMap.of( "content", " <appender name=\"rolling_file\" class=\"org.apache.log4j.RollingFileAppender\">\n" + " <param name=\"file\" value=\"{{logsearch_log_dir}}/logsearch.err\" />\n" + " <param name=\"Threshold\" value=\"info\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"11MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"12\" />\n" + " <layout class=\"org.apache.log4j.PatternLayout\">\n" + " <param name=\"ConversionPattern\" value=\"%d [%t] %-5p %C{6} (%F:%L) - %m%n\" />\n" + " </layout>\n" + " </appender>\n" + "\n" + " <appender name=\"rolling_file_json\" class=\"org.apache.ambari.logsearch.appender.LogsearchRollingFileAppender\">\n" + " <param name=\"file\" value=\"{{logsearch_log_dir}}/logsearch.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"13MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"14\"/>\n" + " <layout class=\"org.apache.ambari.logsearch.appender.LogsearchConversion\"/>\n" + " </appender>\n" + "\n" + " <appender name=\"audit_rolling_file_json\" class=\"org.apache.ambari.logsearch.appender.LogsearchRollingFileAppender\">\n" + " <param name=\"file\" value=\"{{logsearch_log_dir}}/logsearch-audit.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"15MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"16\"/>\n" + " <layout class=\"org.apache.ambari.logsearch.appender.LogsearchConversion\"/>\n" + " </appender>\n" + "\n" + " <appender name=\"performance_analyzer_json\" class=\"org.apache.ambari.logsearch.appender.LogsearchRollingFileAppender\">\n" + " <param name=\"file\" value=\"{{logsearch_log_dir}}/logsearch-performance.json\"/>\n" + " <param name=\"Threshold\" value=\"info\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"17MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"18\"/>\n" + " <layout class=\"org.apache.ambari.logsearch.appender.LogsearchConversion\"/>\n" + " </appender>\n" + "\n" + " <logger name=\"org.apache.ambari.logsearch.audit\" additivity=\"true\">\n" + " <appender-ref ref=\"audit_rolling_file_json\"/>\n" + " </logger>\n" + "\n" + " <logger name=\"org.apache.ambari.logsearch.performance\" additivity=\"false\">\n" + " <appender-ref ref=\"performance_analyzer_json\"/>\n" + " </logger>\n" + "\n" + " <category name=\"org.apache.ambari.logsearch\" additivity=\"false\">\n" + " <priority value=\"warn\"/>\n" + " <appender-ref ref=\"rolling_file_json\"/>\n" + " </category>"); Map<String, String> expectedLogSearchLog4j = new HashMap<>(); expectedLogSearchLog4j.put("content", " <appender name=\"rolling_file\" class=\"org.apache.log4j.RollingFileAppender\">\n" + " <param name=\"file\" value=\"{{logsearch_log_dir}}/logsearch.log\" />\n" + " <param name=\"Threshold\" value=\"info\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"{{logsearch_log_maxfilesize}}MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"{{logsearch_log_maxbackupindex}}\" />\n" + " <layout class=\"org.apache.log4j.PatternLayout\">\n" + " <param name=\"ConversionPattern\" value=\"%d [%t] %-5p %C{6} (%F:%L) - %m%n\" />\n" + " </layout>\n" + " </appender>\n" + "\n" + " <appender name=\"rolling_file_json\" class=\"org.apache.ambari.logsearch.appender.LogsearchRollingFileAppender\">\n" + " <param name=\"file\" value=\"{{logsearch_log_dir}}/logsearch.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"{{logsearch_json_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"{{logsearch_json_log_maxbackupindex}}\"/>\n" + " <layout class=\"org.apache.ambari.logsearch.appender.LogsearchConversion\"/>\n" + " </appender>\n" + "\n" + " <appender name=\"audit_rolling_file_json\" class=\"org.apache.ambari.logsearch.appender.LogsearchRollingFileAppender\">\n" + " <param name=\"file\" value=\"{{logsearch_log_dir}}/logsearch-audit.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"{{logsearch_audit_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"{{logsearch_audit_log_maxbackupindex}}\"/>\n" + " <layout class=\"org.apache.ambari.logsearch.appender.LogsearchConversion\"/>\n" + " </appender>\n" + "\n" + " <appender name=\"performance_analyzer_json\" class=\"org.apache.ambari.logsearch.appender.LogsearchRollingFileAppender\">\n" + " <param name=\"file\" value=\"{{logsearch_log_dir}}/logsearch-performance.json\"/>\n" + " <param name=\"Threshold\" value=\"info\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"{{logsearch_perf_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"{{logsearch_perf_log_maxbackupindex}}\"/>\n" + " <layout class=\"org.apache.ambari.logsearch.appender.LogsearchConversion\"/>\n" + " </appender>\n" + "\n" + " <logger name=\"org.apache.ambari.logsearch.audit\" additivity=\"true\">\n" + " <appender-ref ref=\"audit_rolling_file_json\"/>\n" + " </logger>\n" + "\n" + " <logger name=\"org.apache.ambari.logsearch.performance\" additivity=\"false\">\n" + " <appender-ref ref=\"performance_analyzer_json\"/>\n" + " </logger>\n" + "\n" + " <category name=\"org.apache.ambari.logsearch\" additivity=\"false\">\n" + " <priority value=\"info\"/>\n" + " <appender-ref ref=\"rolling_file_json\"/>\n" + " </category>"); expectedLogSearchLog4j.put("logsearch_log_maxfilesize", "11"); expectedLogSearchLog4j.put("logsearch_log_maxbackupindex", "12"); expectedLogSearchLog4j.put("logsearch_json_log_maxfilesize", "13"); expectedLogSearchLog4j.put("logsearch_json_log_maxbackupindex", "14"); expectedLogSearchLog4j.put("logsearch_audit_log_maxfilesize", "15"); expectedLogSearchLog4j.put("logsearch_audit_log_maxbackupindex", "16"); expectedLogSearchLog4j.put("logsearch_perf_log_maxfilesize", "17"); expectedLogSearchLog4j.put("logsearch_perf_log_maxbackupindex", "18"); Config mockLogSearchLog4j = easyMockSupport.createNiceMock(Config.class); expect(cluster.getDesiredConfigByType("logsearch-log4j")).andReturn(mockLogSearchLog4j).atLeastOnce(); expect(mockLogSearchLog4j.getProperties()).andReturn(oldLogSearchLog4j).anyTimes(); Capture<Map<String, String>> logSearchLog4jCapture = EasyMock.newCapture(); expect(controller.createConfig(anyObject(Cluster.class), anyString(), capture(logSearchLog4jCapture), anyString(), EasyMock.<Map<String, Map<String, String>>>anyObject())).andReturn(config).once(); replay(clusters, cluster); replay(controller, injector2); replay(mockLogSearchProperties, mockLogFeederEnv, mockLogSearchEnv, mockLogFeederLog4j, mockLogSearchLog4j); new UpgradeCatalog250(injector2).updateLogSearchConfigs(); easyMockSupport.verifyAll(); Map<String, String> updatedLogSearchProperties = logSearchPropertiesCapture.getValue(); assertTrue(Maps.difference(expectedLogSearchProperties, updatedLogSearchProperties).areEqual()); Map<String, String> updatedLogFeederEnv = logFeederEnvCapture.getValue(); assertTrue(Maps.difference(expectedLogFeederEnv, updatedLogFeederEnv).areEqual()); Map<String, String> updatedLogSearchEnv = logSearchEnvCapture.getValue(); assertTrue(Maps.difference(expectedLogSearchEnv, updatedLogSearchEnv).areEqual()); Map<String, String> updatedLogFeederLog4j = logFeederLog4jCapture.getValue(); assertTrue(Maps.difference(expectedLogFeederLog4j, updatedLogFeederLog4j).areEqual()); Map<String, String> updatedLogSearchLog4j = logSearchLog4jCapture.getValue(); assertTrue(Maps.difference(expectedLogSearchLog4j, updatedLogSearchLog4j).areEqual()); }
protected void updateLogSearchConfigs() 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 logSearchProperties = cluster.getDesiredConfigByType("logsearch-properties"); if (logSearchProperties != null) { Map<String, String> newProperties = new HashMap<>(); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.enabled")) newProperties.put("logsearch.auth.external_auth.enabled", logSearchProperties.getProperties().get("logsearch.external.auth.enabled")); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.host_url")) newProperties.put("logsearch.auth.external_auth.host_url", logSearchProperties.getProperties().get("logsearch.external.auth.host_url")); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.login_url")) newProperties.put("logsearch.auth.external_auth.login_url", logSearchProperties.getProperties().get("logsearch.external.auth.login_url")); Set<String> removeProperties = new HashSet<>(); removeProperties.add("logsearch.external.auth.enabled"); removeProperties.add("logsearch.external.auth.host_url"); removeProperties.add("logsearch.external.auth.login_url"); updateConfigurationPropertiesForCluster(cluster, "logsearch-properties", newProperties, removeProperties, true, true); } Config logfeederEnvProperties = cluster.getDesiredConfigByType("logfeeder-env"); if (logfeederEnvProperties != null) { String content = logfeederEnvProperties.getProperties().get("content"); if (content.contains("infra_solr_ssl_enabled")) { content = content.replace("infra_solr_ssl_enabled", "logfeeder_use_ssl"); updateConfigurationPropertiesForCluster(cluster, "logfeeder-env", Collections.singletonMap("content", content), true, true); } } Config logsearchEnvProperties = cluster.getDesiredConfigByType("logsearch-env"); if (logsearchEnvProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logsearchEnvProperties.getProperties().get("content"); if (content.contains("infra_solr_ssl_enabled or logsearch_ui_protocol == 'https'")) { content = content.replace("infra_solr_ssl_enabled or logsearch_ui_protocol == 'https'", "logsearch_use_ssl"); } if (!content.equals(logsearchEnvProperties.getProperties().get("content"))) { newProperties.put("content", content); } if ("http".equals(logsearchEnvProperties.getProperties().get("logsearch_ui_protocol")) && "/etc/security/serverKeys/logsearch.trustStore.jks".equals(logsearchEnvProperties.getProperties().get("logsearch_truststore_location")) && "/etc/security/serverKeys/logsearch.keyStore.jks".equals(logsearchEnvProperties.getProperties().get("logsearch_keystore_location"))) { newProperties.put("logsearch_truststore_location", "/etc/ambari-logsearch-portal/conf/keys/logsearch.jks"); newProperties.put("logsearch_keystore_location", "/etc/ambari-logsearch-portal/conf/keys/logsearch.jks"); } Set<String> removeProperties = new HashSet<>(); removeProperties.add("logsearch_solr_audit_logs_use_ranger"); removeProperties.add("logsearch_solr_audit_logs_zk_node"); removeProperties.add("logsearch_solr_audit_logs_zk_quorum"); updateConfigurationPropertiesForCluster(cluster, "logsearch-env", newProperties, removeProperties, true, true); } Config logfeederLog4jProperties = cluster.getDesiredConfigByType("logfeeder-log4j"); if (logfeederLog4jProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logfeederLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_log_maxfilesize", "logfeeder_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logfeeder.log\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_log_maxbackupindex", "logfeeder_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logfeeder.log\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logfeeder_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_json_log_maxfilesize", "logfeeder_json_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logsearch-logfeeder.json\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\" />", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_json_log_maxbackupindex", "logfeeder_json_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logsearch-logfeeder.json\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logfeeder_json_log_maxfilesize}}MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\" />", "10", newProperties); newProperties.put("content", content); updateConfigurationPropertiesForCluster(cluster, "logfeeder-log4j", newProperties, true, true); } Config logsearchLog4jProperties = cluster.getDesiredConfigByType("logsearch-log4j"); if (logsearchLog4jProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logsearchLog4jProperties.getProperties().get("content"); if (content.contains("{{logsearch_log_dir}}/logsearch.err")) { content = content.replace("{{logsearch_log_dir}}/logsearch.err", "{{logsearch_log_dir}}/logsearch.log"); } if (content.contains("<priority value=\"warn\"/>")) { content = content.replace("<priority value=\"warn\"/>", "<priority value=\"info\"/>"); } content = SchemaUpgradeUtil.extractProperty(content, "logsearch_log_maxfilesize", "logsearch_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.log\" />\n" + " <param name=\"Threshold\" value=\"info\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\" />\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_log_maxbackupindex", "logsearch_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.log\" />\n" + " <param name=\"Threshold\" value=\"info\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_log_maxfilesize}}MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\" />\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_json_log_maxfilesize", "logsearch_json_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_json_log_maxbackupindex", "logsearch_json_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_json_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_audit_log_maxfilesize", "logsearch_audit_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-audit.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_audit_log_maxbackupindex", "logsearch_audit_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-audit.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_audit_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_perf_log_maxfilesize", "logsearch_perf_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-performance.json\"/>\n" + " <param name=\"Threshold\" value=\"info\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_perf_log_maxbackupindex", "logsearch_perf_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-performance.json\"/>\n" + " <param name=\"Threshold\" value=\"info\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_perf_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); newProperties.put("content", content); if (!content.equals(logsearchLog4jProperties.getProperties().get("content"))) { updateConfigurationPropertiesForCluster(cluster, "logsearch-log4j", newProperties, true, true); } } } } } }
UpgradeCatalog250 extends AbstractUpgradeCatalog { protected void updateLogSearchConfigs() 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 logSearchProperties = cluster.getDesiredConfigByType("logsearch-properties"); if (logSearchProperties != null) { Map<String, String> newProperties = new HashMap<>(); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.enabled")) newProperties.put("logsearch.auth.external_auth.enabled", logSearchProperties.getProperties().get("logsearch.external.auth.enabled")); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.host_url")) newProperties.put("logsearch.auth.external_auth.host_url", logSearchProperties.getProperties().get("logsearch.external.auth.host_url")); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.login_url")) newProperties.put("logsearch.auth.external_auth.login_url", logSearchProperties.getProperties().get("logsearch.external.auth.login_url")); Set<String> removeProperties = new HashSet<>(); removeProperties.add("logsearch.external.auth.enabled"); removeProperties.add("logsearch.external.auth.host_url"); removeProperties.add("logsearch.external.auth.login_url"); updateConfigurationPropertiesForCluster(cluster, "logsearch-properties", newProperties, removeProperties, true, true); } Config logfeederEnvProperties = cluster.getDesiredConfigByType("logfeeder-env"); if (logfeederEnvProperties != null) { String content = logfeederEnvProperties.getProperties().get("content"); if (content.contains("infra_solr_ssl_enabled")) { content = content.replace("infra_solr_ssl_enabled", "logfeeder_use_ssl"); updateConfigurationPropertiesForCluster(cluster, "logfeeder-env", Collections.singletonMap("content", content), true, true); } } Config logsearchEnvProperties = cluster.getDesiredConfigByType("logsearch-env"); if (logsearchEnvProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logsearchEnvProperties.getProperties().get("content"); if (content.contains("infra_solr_ssl_enabled or logsearch_ui_protocol == 'https'")) { content = content.replace("infra_solr_ssl_enabled or logsearch_ui_protocol == 'https'", "logsearch_use_ssl"); } if (!content.equals(logsearchEnvProperties.getProperties().get("content"))) { newProperties.put("content", content); } if ("http".equals(logsearchEnvProperties.getProperties().get("logsearch_ui_protocol")) && "/etc/security/serverKeys/logsearch.trustStore.jks".equals(logsearchEnvProperties.getProperties().get("logsearch_truststore_location")) && "/etc/security/serverKeys/logsearch.keyStore.jks".equals(logsearchEnvProperties.getProperties().get("logsearch_keystore_location"))) { newProperties.put("logsearch_truststore_location", "/etc/ambari-logsearch-portal/conf/keys/logsearch.jks"); newProperties.put("logsearch_keystore_location", "/etc/ambari-logsearch-portal/conf/keys/logsearch.jks"); } Set<String> removeProperties = new HashSet<>(); removeProperties.add("logsearch_solr_audit_logs_use_ranger"); removeProperties.add("logsearch_solr_audit_logs_zk_node"); removeProperties.add("logsearch_solr_audit_logs_zk_quorum"); updateConfigurationPropertiesForCluster(cluster, "logsearch-env", newProperties, removeProperties, true, true); } Config logfeederLog4jProperties = cluster.getDesiredConfigByType("logfeeder-log4j"); if (logfeederLog4jProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logfeederLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_log_maxfilesize", "logfeeder_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logfeeder.log\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_log_maxbackupindex", "logfeeder_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logfeeder.log\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logfeeder_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_json_log_maxfilesize", "logfeeder_json_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logsearch-logfeeder.json\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\" />", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_json_log_maxbackupindex", "logfeeder_json_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logsearch-logfeeder.json\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logfeeder_json_log_maxfilesize}}MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\" />", "10", newProperties); newProperties.put("content", content); updateConfigurationPropertiesForCluster(cluster, "logfeeder-log4j", newProperties, true, true); } Config logsearchLog4jProperties = cluster.getDesiredConfigByType("logsearch-log4j"); if (logsearchLog4jProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logsearchLog4jProperties.getProperties().get("content"); if (content.contains("{{logsearch_log_dir}}/logsearch.err")) { content = content.replace("{{logsearch_log_dir}}/logsearch.err", "{{logsearch_log_dir}}/logsearch.log"); } if (content.contains("<priority value=\"warn\"/>")) { content = content.replace("<priority value=\"warn\"/>", "<priority value=\"info\"/>"); } content = SchemaUpgradeUtil.extractProperty(content, "logsearch_log_maxfilesize", "logsearch_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.log\" />\n" + " <param name=\"Threshold\" value=\"info\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\" />\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_log_maxbackupindex", "logsearch_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.log\" />\n" + " <param name=\"Threshold\" value=\"info\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_log_maxfilesize}}MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\" />\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_json_log_maxfilesize", "logsearch_json_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_json_log_maxbackupindex", "logsearch_json_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_json_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_audit_log_maxfilesize", "logsearch_audit_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-audit.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_audit_log_maxbackupindex", "logsearch_audit_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-audit.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_audit_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_perf_log_maxfilesize", "logsearch_perf_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-performance.json\"/>\n" + " <param name=\"Threshold\" value=\"info\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_perf_log_maxbackupindex", "logsearch_perf_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-performance.json\"/>\n" + " <param name=\"Threshold\" value=\"info\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_perf_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); newProperties.put("content", content); if (!content.equals(logsearchLog4jProperties.getProperties().get("content"))) { updateConfigurationPropertiesForCluster(cluster, "logsearch-log4j", newProperties, true, true); } } } } } } }
UpgradeCatalog250 extends AbstractUpgradeCatalog { protected void updateLogSearchConfigs() 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 logSearchProperties = cluster.getDesiredConfigByType("logsearch-properties"); if (logSearchProperties != null) { Map<String, String> newProperties = new HashMap<>(); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.enabled")) newProperties.put("logsearch.auth.external_auth.enabled", logSearchProperties.getProperties().get("logsearch.external.auth.enabled")); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.host_url")) newProperties.put("logsearch.auth.external_auth.host_url", logSearchProperties.getProperties().get("logsearch.external.auth.host_url")); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.login_url")) newProperties.put("logsearch.auth.external_auth.login_url", logSearchProperties.getProperties().get("logsearch.external.auth.login_url")); Set<String> removeProperties = new HashSet<>(); removeProperties.add("logsearch.external.auth.enabled"); removeProperties.add("logsearch.external.auth.host_url"); removeProperties.add("logsearch.external.auth.login_url"); updateConfigurationPropertiesForCluster(cluster, "logsearch-properties", newProperties, removeProperties, true, true); } Config logfeederEnvProperties = cluster.getDesiredConfigByType("logfeeder-env"); if (logfeederEnvProperties != null) { String content = logfeederEnvProperties.getProperties().get("content"); if (content.contains("infra_solr_ssl_enabled")) { content = content.replace("infra_solr_ssl_enabled", "logfeeder_use_ssl"); updateConfigurationPropertiesForCluster(cluster, "logfeeder-env", Collections.singletonMap("content", content), true, true); } } Config logsearchEnvProperties = cluster.getDesiredConfigByType("logsearch-env"); if (logsearchEnvProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logsearchEnvProperties.getProperties().get("content"); if (content.contains("infra_solr_ssl_enabled or logsearch_ui_protocol == 'https'")) { content = content.replace("infra_solr_ssl_enabled or logsearch_ui_protocol == 'https'", "logsearch_use_ssl"); } if (!content.equals(logsearchEnvProperties.getProperties().get("content"))) { newProperties.put("content", content); } if ("http".equals(logsearchEnvProperties.getProperties().get("logsearch_ui_protocol")) && "/etc/security/serverKeys/logsearch.trustStore.jks".equals(logsearchEnvProperties.getProperties().get("logsearch_truststore_location")) && "/etc/security/serverKeys/logsearch.keyStore.jks".equals(logsearchEnvProperties.getProperties().get("logsearch_keystore_location"))) { newProperties.put("logsearch_truststore_location", "/etc/ambari-logsearch-portal/conf/keys/logsearch.jks"); newProperties.put("logsearch_keystore_location", "/etc/ambari-logsearch-portal/conf/keys/logsearch.jks"); } Set<String> removeProperties = new HashSet<>(); removeProperties.add("logsearch_solr_audit_logs_use_ranger"); removeProperties.add("logsearch_solr_audit_logs_zk_node"); removeProperties.add("logsearch_solr_audit_logs_zk_quorum"); updateConfigurationPropertiesForCluster(cluster, "logsearch-env", newProperties, removeProperties, true, true); } Config logfeederLog4jProperties = cluster.getDesiredConfigByType("logfeeder-log4j"); if (logfeederLog4jProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logfeederLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_log_maxfilesize", "logfeeder_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logfeeder.log\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_log_maxbackupindex", "logfeeder_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logfeeder.log\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logfeeder_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_json_log_maxfilesize", "logfeeder_json_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logsearch-logfeeder.json\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\" />", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_json_log_maxbackupindex", "logfeeder_json_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logsearch-logfeeder.json\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logfeeder_json_log_maxfilesize}}MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\" />", "10", newProperties); newProperties.put("content", content); updateConfigurationPropertiesForCluster(cluster, "logfeeder-log4j", newProperties, true, true); } Config logsearchLog4jProperties = cluster.getDesiredConfigByType("logsearch-log4j"); if (logsearchLog4jProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logsearchLog4jProperties.getProperties().get("content"); if (content.contains("{{logsearch_log_dir}}/logsearch.err")) { content = content.replace("{{logsearch_log_dir}}/logsearch.err", "{{logsearch_log_dir}}/logsearch.log"); } if (content.contains("<priority value=\"warn\"/>")) { content = content.replace("<priority value=\"warn\"/>", "<priority value=\"info\"/>"); } content = SchemaUpgradeUtil.extractProperty(content, "logsearch_log_maxfilesize", "logsearch_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.log\" />\n" + " <param name=\"Threshold\" value=\"info\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\" />\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_log_maxbackupindex", "logsearch_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.log\" />\n" + " <param name=\"Threshold\" value=\"info\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_log_maxfilesize}}MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\" />\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_json_log_maxfilesize", "logsearch_json_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_json_log_maxbackupindex", "logsearch_json_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_json_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_audit_log_maxfilesize", "logsearch_audit_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-audit.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_audit_log_maxbackupindex", "logsearch_audit_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-audit.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_audit_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_perf_log_maxfilesize", "logsearch_perf_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-performance.json\"/>\n" + " <param name=\"Threshold\" value=\"info\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_perf_log_maxbackupindex", "logsearch_perf_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-performance.json\"/>\n" + " <param name=\"Threshold\" value=\"info\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_perf_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); newProperties.put("content", content); if (!content.equals(logsearchLog4jProperties.getProperties().get("content"))) { updateConfigurationPropertiesForCluster(cluster, "logsearch-log4j", newProperties, true, true); } } } } } } @Inject  UpgradeCatalog250(Injector injector); }
UpgradeCatalog250 extends AbstractUpgradeCatalog { protected void updateLogSearchConfigs() 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 logSearchProperties = cluster.getDesiredConfigByType("logsearch-properties"); if (logSearchProperties != null) { Map<String, String> newProperties = new HashMap<>(); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.enabled")) newProperties.put("logsearch.auth.external_auth.enabled", logSearchProperties.getProperties().get("logsearch.external.auth.enabled")); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.host_url")) newProperties.put("logsearch.auth.external_auth.host_url", logSearchProperties.getProperties().get("logsearch.external.auth.host_url")); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.login_url")) newProperties.put("logsearch.auth.external_auth.login_url", logSearchProperties.getProperties().get("logsearch.external.auth.login_url")); Set<String> removeProperties = new HashSet<>(); removeProperties.add("logsearch.external.auth.enabled"); removeProperties.add("logsearch.external.auth.host_url"); removeProperties.add("logsearch.external.auth.login_url"); updateConfigurationPropertiesForCluster(cluster, "logsearch-properties", newProperties, removeProperties, true, true); } Config logfeederEnvProperties = cluster.getDesiredConfigByType("logfeeder-env"); if (logfeederEnvProperties != null) { String content = logfeederEnvProperties.getProperties().get("content"); if (content.contains("infra_solr_ssl_enabled")) { content = content.replace("infra_solr_ssl_enabled", "logfeeder_use_ssl"); updateConfigurationPropertiesForCluster(cluster, "logfeeder-env", Collections.singletonMap("content", content), true, true); } } Config logsearchEnvProperties = cluster.getDesiredConfigByType("logsearch-env"); if (logsearchEnvProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logsearchEnvProperties.getProperties().get("content"); if (content.contains("infra_solr_ssl_enabled or logsearch_ui_protocol == 'https'")) { content = content.replace("infra_solr_ssl_enabled or logsearch_ui_protocol == 'https'", "logsearch_use_ssl"); } if (!content.equals(logsearchEnvProperties.getProperties().get("content"))) { newProperties.put("content", content); } if ("http".equals(logsearchEnvProperties.getProperties().get("logsearch_ui_protocol")) && "/etc/security/serverKeys/logsearch.trustStore.jks".equals(logsearchEnvProperties.getProperties().get("logsearch_truststore_location")) && "/etc/security/serverKeys/logsearch.keyStore.jks".equals(logsearchEnvProperties.getProperties().get("logsearch_keystore_location"))) { newProperties.put("logsearch_truststore_location", "/etc/ambari-logsearch-portal/conf/keys/logsearch.jks"); newProperties.put("logsearch_keystore_location", "/etc/ambari-logsearch-portal/conf/keys/logsearch.jks"); } Set<String> removeProperties = new HashSet<>(); removeProperties.add("logsearch_solr_audit_logs_use_ranger"); removeProperties.add("logsearch_solr_audit_logs_zk_node"); removeProperties.add("logsearch_solr_audit_logs_zk_quorum"); updateConfigurationPropertiesForCluster(cluster, "logsearch-env", newProperties, removeProperties, true, true); } Config logfeederLog4jProperties = cluster.getDesiredConfigByType("logfeeder-log4j"); if (logfeederLog4jProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logfeederLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_log_maxfilesize", "logfeeder_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logfeeder.log\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_log_maxbackupindex", "logfeeder_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logfeeder.log\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logfeeder_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_json_log_maxfilesize", "logfeeder_json_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logsearch-logfeeder.json\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\" />", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_json_log_maxbackupindex", "logfeeder_json_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logsearch-logfeeder.json\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logfeeder_json_log_maxfilesize}}MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\" />", "10", newProperties); newProperties.put("content", content); updateConfigurationPropertiesForCluster(cluster, "logfeeder-log4j", newProperties, true, true); } Config logsearchLog4jProperties = cluster.getDesiredConfigByType("logsearch-log4j"); if (logsearchLog4jProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logsearchLog4jProperties.getProperties().get("content"); if (content.contains("{{logsearch_log_dir}}/logsearch.err")) { content = content.replace("{{logsearch_log_dir}}/logsearch.err", "{{logsearch_log_dir}}/logsearch.log"); } if (content.contains("<priority value=\"warn\"/>")) { content = content.replace("<priority value=\"warn\"/>", "<priority value=\"info\"/>"); } content = SchemaUpgradeUtil.extractProperty(content, "logsearch_log_maxfilesize", "logsearch_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.log\" />\n" + " <param name=\"Threshold\" value=\"info\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\" />\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_log_maxbackupindex", "logsearch_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.log\" />\n" + " <param name=\"Threshold\" value=\"info\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_log_maxfilesize}}MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\" />\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_json_log_maxfilesize", "logsearch_json_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_json_log_maxbackupindex", "logsearch_json_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_json_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_audit_log_maxfilesize", "logsearch_audit_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-audit.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_audit_log_maxbackupindex", "logsearch_audit_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-audit.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_audit_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_perf_log_maxfilesize", "logsearch_perf_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-performance.json\"/>\n" + " <param name=\"Threshold\" value=\"info\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_perf_log_maxbackupindex", "logsearch_perf_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-performance.json\"/>\n" + " <param name=\"Threshold\" value=\"info\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_perf_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); newProperties.put("content", content); if (!content.equals(logsearchLog4jProperties.getProperties().get("content"))) { updateConfigurationPropertiesForCluster(cluster, "logsearch-log4j", newProperties, true, true); } } } } } } @Inject  UpgradeCatalog250(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); }
UpgradeCatalog250 extends AbstractUpgradeCatalog { protected void updateLogSearchConfigs() 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 logSearchProperties = cluster.getDesiredConfigByType("logsearch-properties"); if (logSearchProperties != null) { Map<String, String> newProperties = new HashMap<>(); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.enabled")) newProperties.put("logsearch.auth.external_auth.enabled", logSearchProperties.getProperties().get("logsearch.external.auth.enabled")); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.host_url")) newProperties.put("logsearch.auth.external_auth.host_url", logSearchProperties.getProperties().get("logsearch.external.auth.host_url")); if (!logSearchProperties.getProperties().containsKey("logsearch.auth.external_auth.login_url")) newProperties.put("logsearch.auth.external_auth.login_url", logSearchProperties.getProperties().get("logsearch.external.auth.login_url")); Set<String> removeProperties = new HashSet<>(); removeProperties.add("logsearch.external.auth.enabled"); removeProperties.add("logsearch.external.auth.host_url"); removeProperties.add("logsearch.external.auth.login_url"); updateConfigurationPropertiesForCluster(cluster, "logsearch-properties", newProperties, removeProperties, true, true); } Config logfeederEnvProperties = cluster.getDesiredConfigByType("logfeeder-env"); if (logfeederEnvProperties != null) { String content = logfeederEnvProperties.getProperties().get("content"); if (content.contains("infra_solr_ssl_enabled")) { content = content.replace("infra_solr_ssl_enabled", "logfeeder_use_ssl"); updateConfigurationPropertiesForCluster(cluster, "logfeeder-env", Collections.singletonMap("content", content), true, true); } } Config logsearchEnvProperties = cluster.getDesiredConfigByType("logsearch-env"); if (logsearchEnvProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logsearchEnvProperties.getProperties().get("content"); if (content.contains("infra_solr_ssl_enabled or logsearch_ui_protocol == 'https'")) { content = content.replace("infra_solr_ssl_enabled or logsearch_ui_protocol == 'https'", "logsearch_use_ssl"); } if (!content.equals(logsearchEnvProperties.getProperties().get("content"))) { newProperties.put("content", content); } if ("http".equals(logsearchEnvProperties.getProperties().get("logsearch_ui_protocol")) && "/etc/security/serverKeys/logsearch.trustStore.jks".equals(logsearchEnvProperties.getProperties().get("logsearch_truststore_location")) && "/etc/security/serverKeys/logsearch.keyStore.jks".equals(logsearchEnvProperties.getProperties().get("logsearch_keystore_location"))) { newProperties.put("logsearch_truststore_location", "/etc/ambari-logsearch-portal/conf/keys/logsearch.jks"); newProperties.put("logsearch_keystore_location", "/etc/ambari-logsearch-portal/conf/keys/logsearch.jks"); } Set<String> removeProperties = new HashSet<>(); removeProperties.add("logsearch_solr_audit_logs_use_ranger"); removeProperties.add("logsearch_solr_audit_logs_zk_node"); removeProperties.add("logsearch_solr_audit_logs_zk_quorum"); updateConfigurationPropertiesForCluster(cluster, "logsearch-env", newProperties, removeProperties, true, true); } Config logfeederLog4jProperties = cluster.getDesiredConfigByType("logfeeder-log4j"); if (logfeederLog4jProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logfeederLog4jProperties.getProperties().get("content"); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_log_maxfilesize", "logfeeder_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logfeeder.log\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_log_maxbackupindex", "logfeeder_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logfeeder.log\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logfeeder_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_json_log_maxfilesize", "logfeeder_json_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logsearch-logfeeder.json\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\" />", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logfeeder_json_log_maxbackupindex", "logfeeder_json_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logfeeder_log_dir}}/logsearch-logfeeder.json\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logfeeder_json_log_maxfilesize}}MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\" />", "10", newProperties); newProperties.put("content", content); updateConfigurationPropertiesForCluster(cluster, "logfeeder-log4j", newProperties, true, true); } Config logsearchLog4jProperties = cluster.getDesiredConfigByType("logsearch-log4j"); if (logsearchLog4jProperties != null) { Map<String, String> newProperties = new HashMap<>(); String content = logsearchLog4jProperties.getProperties().get("content"); if (content.contains("{{logsearch_log_dir}}/logsearch.err")) { content = content.replace("{{logsearch_log_dir}}/logsearch.err", "{{logsearch_log_dir}}/logsearch.log"); } if (content.contains("<priority value=\"warn\"/>")) { content = content.replace("<priority value=\"warn\"/>", "<priority value=\"info\"/>"); } content = SchemaUpgradeUtil.extractProperty(content, "logsearch_log_maxfilesize", "logsearch_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.log\" />\n" + " <param name=\"Threshold\" value=\"info\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\" />\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_log_maxbackupindex", "logsearch_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.log\" />\n" + " <param name=\"Threshold\" value=\"info\" />\n" + " <param name=\"append\" value=\"true\" />\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_log_maxfilesize}}MB\" />\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\" />\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_json_log_maxfilesize", "logsearch_json_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_json_log_maxbackupindex", "logsearch_json_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_json_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_audit_log_maxfilesize", "logsearch_audit_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-audit.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_audit_log_maxbackupindex", "logsearch_audit_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-audit.json\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_audit_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_perf_log_maxfilesize", "logsearch_perf_log_maxfilesize", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-performance.json\"/>\n" + " <param name=\"Threshold\" value=\"info\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"(\\w+)MB\"/>\n", "10", newProperties); content = SchemaUpgradeUtil.extractProperty(content, "logsearch_perf_log_maxbackupindex", "logsearch_perf_log_maxbackupindex", " <param name=\"file\" value=\"\\{\\{logsearch_log_dir}}/logsearch-performance.json\"/>\n" + " <param name=\"Threshold\" value=\"info\"/>\n" + " <param name=\"append\" value=\"true\"/>\n" + " <param name=\"maxFileSize\" value=\"\\{\\{logsearch_perf_log_maxfilesize}}MB\"/>\n" + " <param name=\"maxBackupIndex\" value=\"(\\w+)\"/>\n", "10", newProperties); newProperties.put("content", content); if (!content.equals(logsearchLog4jProperties.getProperties().get("content"))) { updateConfigurationPropertiesForCluster(cluster, "logsearch-log4j", 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; }