ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [2/2] ambari git commit: AMBARI-18118. AlertDefinitionCommand intermittently provides stale configurations (dlysnichenko)
Date Thu, 11 Aug 2016 16:26:58 GMT
AMBARI-18118. AlertDefinitionCommand intermittently provides stale configurations (dlysnichenko)


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

Branch: refs/heads/branch-2.4
Commit: 056d83cdd8285712f8983d7542285d88b0a0e53e
Parents: d1c5e04
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Thu Aug 11 19:26:10 2016 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Thu Aug 11 19:26:38 2016 +0300

----------------------------------------------------------------------
 .../server/agent/AlertDefinitionCommand.java    | 39 ++------------------
 .../state/alerts/AlertDefinitionHashTest.java   |  7 ++++
 2 files changed, 10 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/056d83cd/ambari-server/src/main/java/org/apache/ambari/server/agent/AlertDefinitionCommand.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/AlertDefinitionCommand.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/AlertDefinitionCommand.java
index fdd7f1d..4d2e048 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/AlertDefinitionCommand.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/AlertDefinitionCommand.java
@@ -17,13 +17,11 @@
  */
 package org.apache.ambari.server.agent;
 
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.alert.AlertDefinition;
 import org.apache.ambari.server.state.alert.AlertDefinitionHash;
@@ -130,39 +128,8 @@ public class AlertDefinitionCommand extends AgentCommand {
    */
   public void addConfigs(ConfigHelper configHelper, Cluster cluster)
     throws AmbariException {
-
-    m_configurations = new HashMap<String, Map<String, String>>();
-
-    Map<String, Map<String, String>> allConfigTags =
-        configHelper.getEffectiveDesiredTags(cluster, m_hostName);
-
-    for(Config clusterConfig: cluster.getAllConfigs()) {
-      if (null == clusterConfig) {
-        // !!! hard to believe
-        continue;
-      }
-
-      Map<String, String> props = new HashMap<String, String>(clusterConfig.getProperties());
-
-      Map<String, Map<String, String>> configTags = new HashMap<String,
-              Map<String, String>>();
-
-      for (Map.Entry<String, Map<String, String>> entry : allConfigTags.entrySet())
{
-        if (entry.getKey().equals(clusterConfig.getType())) {
-          configTags.put(clusterConfig.getType(), entry.getValue());
-        }
-      }
-
-      Map<String, Map<String, String>> properties = configHelper
-              .getEffectiveConfigProperties(cluster, configTags);
-
-      if (!properties.isEmpty()) {
-        for (Map<String, String> propertyMap : properties.values()) {
-          props.putAll(propertyMap);
-        }
-      }
-
-      m_configurations.put(clusterConfig.getType(), props);
-    }
+    Map<String, Map<String, String>> configTags = configHelper.getEffectiveDesiredTags(cluster,
m_hostName);
+    Map<String, Map<String, String>> configurations = configHelper.getEffectiveConfigProperties(cluster,
configTags);
+    m_configurations = configurations;
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/056d83cd/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertDefinitionHashTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertDefinitionHashTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertDefinitionHashTest.java
index 74a349c..c534c4a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertDefinitionHashTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertDefinitionHashTest.java
@@ -80,6 +80,7 @@ public class AlertDefinitionHashTest extends TestCase {
   private List<AlertDefinitionEntity> m_agentDefinitions;
   private AlertDefinitionEntity m_hdfsService;
   AlertDefinitionEntity m_hdfsHost;
+  private ConfigHelper m_configHelper;
 
   /**
    *
@@ -201,6 +202,12 @@ public class AlertDefinitionHashTest extends TestCase {
 
     EasyMock.replay(m_mockClusters, m_mockCluster, m_mockDao);
     m_hash = m_injector.getInstance(AlertDefinitionHash.class);
+
+    // configHelper mock
+    m_configHelper = m_injector.getInstance(ConfigHelper.class);
+    EasyMock.expect(m_configHelper.getEffectiveDesiredTags((Cluster) anyObject(), EasyMock.anyString())).andReturn(new
HashMap<String, Map<String, String>>()).anyTimes();
+    EasyMock.expect(m_configHelper.getEffectiveConfigProperties((Cluster) anyObject(), (Map<String,
Map<String, String>>) anyObject())).andReturn(new HashMap<String, Map<String,
String>>()).anyTimes();
+    EasyMock.replay(m_configHelper);
   }
 
   /**


Mime
View raw message