incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject svn commit: r1454527 - in /incubator/ambari/trunk: ./ ambari-server/src/main/java/org/apache/ambari/server/state/ ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ ambari-server/src/test/java/org/apache/ambari/server/state/
Date Fri, 08 Mar 2013 20:14:34 GMT
Author: ncole
Date: Fri Mar  8 20:14:34 2013
New Revision: 1454527

URL: http://svn.apache.org/r1454527
Log:
AMBARI-1593. Change host override JSON to include version tag

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/DesiredConfigTest.java

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1454527&r1=1454526&r2=1454527&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Fri Mar  8 20:14:34 2013
@@ -12,6 +12,10 @@ Trunk (unreleased changes):
 
  NEW FEATURES
 
+ AMBARI-1593. Change host override JSON to include version tag (ncole)
+
+ AMBARI-1545. Integrate Frontend Security work to enable security on HDFS
+
  AMBARI-1555. Upgrade should validate that the from->to version is an allowed 
  combination. (Sumit Mohanty via swagle)
 

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java?rev=1454527&r1=1454526&r2=1454527&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java
(original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java
Fri Mar  8 20:14:34 2013
@@ -31,7 +31,7 @@ public class DesiredConfig {
 
   private String versionTag;
   private String serviceName;
-  private List<String> hostOverrides = null;
+  private List<HostOverride> hostOverrides = null;
 
   /**
    * Sets the version tag
@@ -72,7 +72,7 @@ public class DesiredConfig {
    * Sets the host overrides for the desired config.  Cluster-based desired configs only.
    * @param overrides the host names
    */
-  public void setHostOverrides(List<String> overrides) {
+  public void setHostOverrides(List<HostOverride> overrides) {
     hostOverrides = overrides;
   }
 
@@ -82,10 +82,44 @@ public class DesiredConfig {
    */
   @JsonSerialize(include = Inclusion.NON_EMPTY)
   @JsonProperty("host_overrides")
-  public List<String> getHostOverrides() {
+  public List<HostOverride> getHostOverrides() {
     return hostOverrides;
   }
 
+  /**
+   * Used to represent an override on a host.
+   */
+  public static class HostOverride {
+    private String hostName;
+    private String versionOverrideTag;
+
+    /**
+     * @param name the host name
+     * @param tag the config tag
+     */
+    public HostOverride(String name, String tag) {
+      hostName = name;
+      versionOverrideTag = tag;
+    }
+
+    /**
+     * @return the override host name
+     */
+    @JsonProperty("host_name")
+    public String getName() {
+      return hostName;
+    }
+
+    /**
+     * @return the override version tag
+     */
+    @JsonProperty("tag")
+    public String getVersionTag() {
+      return versionOverrideTag;
+    }
+
+  }
+
   @Override
   public String toString() {
     StringBuilder sb = new StringBuilder();
@@ -96,11 +130,11 @@ public class DesiredConfig {
     if (null != hostOverrides && hostOverrides.size() > 0) {
       sb.append(", hosts=[");
       int i = 0;
-      for (String h : hostOverrides)
+      for (DesiredConfig.HostOverride h : hostOverrides)
       {
         if (i++ != 0)
           sb.append(",");
-        sb.append(h);
+        sb.append(h.getName());
       }
 
       sb.append(']');

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java?rev=1454527&r1=1454526&r2=1454527&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
(original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
Fri Mar  8 20:14:34 2013
@@ -552,6 +552,7 @@ public class ClusterImpl implements Clus
     }
   }
 
+  @Override
   public Collection<Config> getAllConfigs() {
     readWriteLock.readLock().lock();
     try {
@@ -582,6 +583,7 @@ public class ClusterImpl implements Clus
     }
   }
 
+  @Override
   public void debugDump(StringBuilder sb) {
     loadServices();
     readWriteLock.readLock().lock();
@@ -719,7 +721,7 @@ public class ClusterImpl implements Clus
     }
 
     Collection<ClusterConfigMappingEntity> entities = clusterEntity.getConfigMappingEntities();
-    
+
     for (ClusterConfigMappingEntity e : entities) {
       if (e.isSelected() > 0 && e.getType().equals(config.getType())) {
         e.setSelected(0);
@@ -734,7 +736,7 @@ public class ClusterImpl implements Clus
     entity.setType(config.getType());
     entity.setVersion(config.getVersionTag());
     entities.add(entity);
-    
+
     clusterEntity.setConfigMappingEntities(entities);
 
     clusterDAO.merge(clusterEntity);
@@ -755,9 +757,10 @@ public class ClusterImpl implements Clus
             hostConfigMappingDAO.findSelectedHostsByType(clusterEntity.getClusterId().longValue(),
                 e.getType());
 
-        List<String> hosts = new ArrayList<String>();
+        List<DesiredConfig.HostOverride> hosts = new ArrayList<DesiredConfig.HostOverride>();
         for (HostConfigMappingEntity mappingEntity : hostMappings) {
-          hosts.add (mappingEntity.getHostName());
+          hosts.add (new DesiredConfig.HostOverride(mappingEntity.getHostName(),
+              mappingEntity.getVersion()));
         }
 
         c.setHostOverrides(hosts);

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/DesiredConfigTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/DesiredConfigTest.java?rev=1454527&r1=1454526&r2=1454527&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/DesiredConfigTest.java
(original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/state/DesiredConfigTest.java
Fri Mar  8 20:14:34 2013
@@ -33,16 +33,28 @@ public class DesiredConfigTest {
     DesiredConfig dc = new DesiredConfig();
     dc.setServiceName("service");
     dc.setVersion("global");
-    
+
     Assert.assertEquals("Expected service 'service'", "service", dc.getServiceName());
     Assert.assertEquals("Expected version 'global'", "global", dc.getVersion());
     Assert.assertNull("Expected null host overrides", dc.getHostOverrides());
-    
-    List<String> hosts = Arrays.asList("h1", "h2", "h3");
+
+    List<DesiredConfig.HostOverride> hosts = Arrays.asList(
+        new DesiredConfig.HostOverride("h1", "v2"),
+        new DesiredConfig.HostOverride("h2", "v3"));
     dc.setHostOverrides(hosts);
-    
+
     Assert.assertNotNull("Expected host overrides to be set", dc.getHostOverrides());
     Assert.assertEquals("Expected host override equality", hosts, dc.getHostOverrides());
   }
-  
+
+  @Test
+  public void testHostOverride() throws Exception {
+    DesiredConfig.HostOverride override = new DesiredConfig.HostOverride("h1", "v1");
+
+    Assert.assertNotNull(override.getName());
+    Assert.assertNotNull(override.getVersionTag());
+    Assert.assertEquals("Expected override host 'h1'", "h1", override.getName());
+    Assert.assertEquals("Expected override version 'v1'", "v1", override.getVersionTag());
+  }
+
 }



Mime
View raw message