ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-13471 ZooKeeper "log4j.rootLogger" should have ROLLINGFILE instead of CONSOLE (dsen)
Date Mon, 19 Oct 2015 16:05:32 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk fefa1c44d -> fe230132f


AMBARI-13471 ZooKeeper "log4j.rootLogger" should have ROLLINGFILE instead of CONSOLE (dsen)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fe230132
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fe230132
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fe230132

Branch: refs/heads/trunk
Commit: fe230132f472d64b1cca39d365e958cc37fb150f
Parents: fefa1c4
Author: Dmytro Sen <dsen@apache.org>
Authored: Mon Oct 19 19:05:22 2015 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Mon Oct 19 19:05:22 2015 +0300

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog213.java       | 42 +++++++++-------
 .../ZOOKEEPER/configuration/zookeeper-log4j.xml |  4 +-
 .../server/upgrade/UpgradeCatalog213Test.java   | 50 ++++++++++++++++++--
 3 files changed, 72 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fe230132/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
index ed536cc..a5a1b7a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog213.java
@@ -62,6 +62,8 @@ public class UpgradeCatalog213 extends AbstractUpgradeCatalog {
   private static final String AMS_ENV = "ams-env";
   private static final String AMS_HBASE_ENV = "ams-hbase-env";
   private static final String HBASE_ENV_CONFIG = "hbase-env";
+  private static final String ZOOKEEPER_LOG4J_CONFIG = "zookeeper-log4j";
+  private static final String NIMBS_MONITOR_FREQ_SECS_PROPERTY = "nimbus.monitor.freq.secs";
   private static final String HADOOP_ENV_CONFIG = "hadoop-env";
   private static final String CONTENT_PROPERTY = "content";
   private static final String HADOOP_ENV_CONTENT_TO_APPEND = "\n{% if is_datanode_max_locked_memory_set
%}\n" +
@@ -174,6 +176,7 @@ public class UpgradeCatalog213 extends AbstractUpgradeCatalog {
     updateHbaseEnvConfig();
     updateHadoopEnv();
     updateKafkaConfigs();
+    updateZookeeperLog4j();
   }
 
   /**
@@ -276,26 +279,31 @@ public class UpgradeCatalog213 extends AbstractUpgradeCatalog {
     }
   }
 
-  protected void updateStormConfigs() throws AmbariException {
+  protected void updateZookeeperLog4j() throws AmbariException {
     AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
-    Clusters clusters = ambariManagementController.getClusters();
 
-    if (clusters != null) {
-      Map<String, Cluster> clusterMap = clusters.getClusters();
+    for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values())
{
+      Config zookeeperLog4jConfig = cluster.getDesiredConfigByType(ZOOKEEPER_LOG4J_CONFIG);
+      if (zookeeperLog4jConfig != null) {
+        String content = zookeeperLog4jConfig.getProperties().get(CONTENT_PROPERTY);
+        if (content != null) {
+          content = content.replaceAll("[\n^]\\s*log4j\\.rootLogger\\s*=\\s*INFO\\s*,\\s*CONSOLE",
"\nlog4j.rootLogger=INFO, ROLLINGFILE");
+          Map<String, String> updates = Collections.singletonMap(CONTENT_PROPERTY,
content);
+          updateConfigurationPropertiesForCluster(cluster, ZOOKEEPER_LOG4J_CONFIG, updates,
true, false);
+        }
+      }
+    }
+  }
 
-      if ((clusterMap != null) && !clusterMap.isEmpty()) {
-        // Iterate through the clusters and perform any configuration updates
-        for (final Cluster cluster : clusterMap.values()) {
-          Config stormSiteProps = cluster.getDesiredConfigByType(STORM_SITE);
-
-          if (stormSiteProps != null) {
-            String value = stormSiteProps.getProperties().get("nimbus.monitor.freq.secs");
-            if (value != null && value.equals("10")) {
-              Map<String, String> updates = new HashMap<String, String>();
-              updates.put("nimbus.monitor.freq.secs", "120");
-              updateConfigurationPropertiesForCluster(cluster, STORM_SITE, updates, true,
false);
-            }
-          }
+  protected void updateStormConfigs() throws AmbariException {
+    AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
+    for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values())
{
+      Config stormSiteProps = cluster.getDesiredConfigByType(STORM_SITE);
+      if (stormSiteProps != null) {
+        String nimbusMonitorFreqSecs = stormSiteProps.getProperties().get(NIMBS_MONITOR_FREQ_SECS_PROPERTY);
+        if (nimbusMonitorFreqSecs != null && nimbusMonitorFreqSecs.equals("10"))
{
+          Map<String, String> updates = Collections.singletonMap(NIMBS_MONITOR_FREQ_SECS_PROPERTY,
"120");
+          updateConfigurationPropertiesForCluster(cluster, STORM_SITE, updates, true, false);
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/fe230132/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/ZOOKEEPER/configuration/zookeeper-log4j.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/ZOOKEEPER/configuration/zookeeper-log4j.xml
b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/ZOOKEEPER/configuration/zookeeper-log4j.xml
index 6fcf5bc..d7edd1b 100644
--- a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/ZOOKEEPER/configuration/zookeeper-log4j.xml
+++ b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/ZOOKEEPER/configuration/zookeeper-log4j.xml
@@ -52,8 +52,8 @@
 # ZooKeeper Logging Configuration
 #
 
-# DEFAULT: console appender only
-log4j.rootLogger=INFO, CONSOLE
+# DEFAULT: rollingfile appender only
+log4j.rootLogger=INFO, ROLLINGFILE
 
 # Example with rolling log file
 #log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE

http://git-wip-us.apache.org/repos/asf/ambari/blob/fe230132/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
index 24471bd..34ff56b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog213Test.java
@@ -132,6 +132,7 @@ public class UpgradeCatalog213Test {
     Method updateStormConfigs = UpgradeCatalog213.class.getDeclaredMethod("updateStormConfigs");
     Method addNewConfigurationsFromXml = AbstractUpgradeCatalog.class.getDeclaredMethod("addNewConfigurationsFromXml");
     Method updateHbaseEnvConfig = UpgradeCatalog213.class.getDeclaredMethod("updateHbaseEnvConfig");
+    Method updateZookeeperLog4j = UpgradeCatalog213.class.getDeclaredMethod("updateZookeeperLog4j");
     Method updateHadoopEnvConfig = UpgradeCatalog213.class.getDeclaredMethod("updateHadoopEnv");
     Method updateAlertDefinitions = UpgradeCatalog213.class.getDeclaredMethod("updateAlertDefinitions");
 
@@ -143,6 +144,7 @@ public class UpgradeCatalog213Test {
         .addMockedMethod(updateHbaseEnvConfig)
         .addMockedMethod(updateAlertDefinitions)
         .addMockedMethod(updateKafkaConfigs)
+        .addMockedMethod(updateZookeeperLog4j)
         .addMockedMethod(updateHadoopEnvConfig)
         .createMock();
 
@@ -162,6 +164,8 @@ public class UpgradeCatalog213Test {
     expectLastCall().once();
     upgradeCatalog213.updateHDFSConfigs();
     expectLastCall().once();
+    upgradeCatalog213.updateZookeeperLog4j();
+    expectLastCall().once();
 
     replay(upgradeCatalog213);
 
@@ -212,10 +216,6 @@ public class UpgradeCatalog213Test {
     final Config mockStormSite = easyMockSupport.createNiceMock(Config.class);
     expect(mockStormSite.getProperties()).andReturn(propertiesStormSite).once();
 
-    final Map<String, String> propertiesExpectedHiveSite = new HashMap<String, String>()
{{
-      put("nimbus.monitor.freq.secs", "210");
-    }};
-
     final Injector mockInjector = Guice.createInjector(new AbstractModule() {
       @Override
       protected void configure() {
@@ -234,7 +234,7 @@ public class UpgradeCatalog213Test {
     }}).once();
 
     expect(mockClusterExpected.getDesiredConfigByType("storm-site")).andReturn(mockStormSite).atLeastOnce();
-    expect(mockStormSite.getProperties()).andReturn(propertiesExpectedHiveSite).atLeastOnce();
+    expect(mockStormSite.getProperties()).andReturn(propertiesStormSite).atLeastOnce();
 
     easyMockSupport.replayAll();
     mockInjector.getInstance(UpgradeCatalog213.class).updateStormConfigs();
@@ -507,6 +507,46 @@ public class UpgradeCatalog213Test {
   }
 
   @Test
+  public void testUpdateZookeeperLog4jConfig() throws AmbariException {
+    EasyMockSupport easyMockSupport = new EasyMockSupport();
+    final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
+    final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
+    final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
+    final Map<String, String> propertiesZookeeperLog4j = new HashMap<String, String>()
{
+      {
+        put("content", "log4j.rootLogger=INFO, CONSOLE");
+      }
+    };
+
+    final Config mockZookeeperLog4j = easyMockSupport.createNiceMock(Config.class);
+    expect(mockZookeeperLog4j.getProperties()).andReturn(propertiesZookeeperLog4j).once();
+
+    final Injector mockInjector = Guice.createInjector(new AbstractModule() {
+      @Override
+      protected void configure() {
+        bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
+        bind(Clusters.class).toInstance(mockClusters);
+        bind(EntityManager.class).toInstance(entityManager);
+
+        bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
+        bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+      }
+    });
+
+    expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
+    expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
+      put("normal", mockClusterExpected);
+    }}).atLeastOnce();
+
+    expect(mockClusterExpected.getDesiredConfigByType("zookeeper-log4j")).andReturn(mockZookeeperLog4j).atLeastOnce();
+    expect(mockZookeeperLog4j.getProperties()).andReturn(propertiesZookeeperLog4j).atLeastOnce();
+
+    easyMockSupport.replayAll();
+    mockInjector.getInstance(UpgradeCatalog213.class).updateZookeeperLog4j();
+    easyMockSupport.verifyAll();
+
+  }
+
   public void testGetSourceVersion() {
     final DBAccessor dbAccessor = createNiceMock(DBAccessor.class);
     UpgradeCatalog upgradeCatalog = getUpgradeCatalog(dbAccessor);


Mime
View raw message