ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [09/12] ambari git commit: AMBARI-18516. Add ability to have services declare itself as tech-preview or mandatory.(vbrodetskyi)
Date Thu, 06 Oct 2016 16:00:43 GMT
AMBARI-18516. Add ability to have services declare itself as tech-preview or mandatory.(vbrodetskyi)


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

Branch: refs/heads/branch-feature-AMBARI-18456
Commit: 56e00acdc8d7357ba811fcd4dca4fbb23bad33be
Parents: 46cb402
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Thu Oct 6 04:59:49 2016 +0300
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Thu Oct 6 04:59:49 2016 +0300

----------------------------------------------------------------------
 .../server/controller/StackServiceResponse.java | 16 +++++++++--
 .../internal/StackServiceResourceProvider.java  |  6 ++++
 .../ambari/server/stack/ServiceModule.java      |  6 +++-
 .../apache/ambari/server/state/ServiceInfo.java | 27 ++++++++++++++++++
 .../src/main/resources/properties.json          |  1 +
 .../ambari/server/stack/ServiceModuleTest.java  | 19 +++++++++++++
 .../ambari/server/state/ServiceInfoTest.java    | 30 ++++++++++++++++++++
 7 files changed, 101 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/56e00acd/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
index 5865e20..75f65c0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
@@ -38,6 +38,7 @@ public class StackServiceResponse {
   private String userName;
   private String comments;
   private String serviceVersion;
+  private ServiceInfo.Selection selection;
   private boolean serviceCheckSupported;
   private List<String> customCommands;
 
@@ -73,6 +74,7 @@ public class StackServiceResponse {
     excludedConfigTypes = service.getExcludedConfigTypes();
     requiredServices = service.getRequiredServices();
     serviceCheckSupported = null != service.getCommandScript();
+    selection = service.getSelection();
 
     // the custom command names defined at the service (not component) level
     List<CustomCommandDefinition> definitions = service.getCustomCommands();
@@ -90,6 +92,14 @@ public class StackServiceResponse {
     serviceProperties = service.getServiceProperties();
   }
 
+  public ServiceInfo.Selection getSelection() {
+    return selection;
+  }
+
+  public void setSelection(ServiceInfo.Selection selection) {
+    this.selection = selection;
+  }
+
   public String getStackName() {
     return stackName;
   }
@@ -115,14 +125,14 @@ public class StackServiceResponse {
   }
 
   public String getServiceType() {
-	return serviceType;
+    return serviceType;
   }
 
   public void setServiceType(String serviceType) {
-	this.serviceType = serviceType;
+    this.serviceType = serviceType;
   }
 
-public String getServiceDisplayName() {
+  public String getServiceDisplayName() {
     return serviceDisplayName;
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/56e00acd/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
index 16713dd..0fc65eb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
@@ -67,6 +67,9 @@ public class StackServiceResourceProvider extends ReadOnlyResourceProvider
{
   private static final String COMMENTS_PROPERTY_ID = PropertyHelper.getPropertyId(
       "StackServices", "comments");
 
+  private static final String SELECTION_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServices", "selection");
+
   private static final String VERSION_PROPERTY_ID = PropertyHelper.getPropertyId(
       "StackServices", "service_version");
 
@@ -166,6 +169,9 @@ public class StackServiceResourceProvider extends ReadOnlyResourceProvider
{
     setResourceProperty(resource, VERSION_PROPERTY_ID,
         response.getServiceVersion(), requestedIds);
 
+    setResourceProperty(resource, SELECTION_PROPERTY_ID,
+        response.getSelection(), requestedIds);
+
     setResourceProperty(resource, CONFIG_TYPES,
         response.getConfigTypes(), requestedIds);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/56e00acd/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
b/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
index 34e65c3..826abbc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
@@ -258,6 +258,10 @@ public class ServiceModule extends BaseModule<ServiceModule, ServiceInfo>
implem
       serviceInfo.setChecksFolder(parent.getChecksFolder());
     }
 
+    if (serviceInfo.isSelectionEmpty()) {
+      serviceInfo.setSelection(parent.getSelection());
+    }
+
     mergeCustomCommands(parent.getCustomCommands(), serviceInfo.getCustomCommands());
     mergeConfigDependencies(parent);
     mergeComponents(parentModule, allStacks, commonServices, extensions);
@@ -644,7 +648,7 @@ public class ServiceModule extends BaseModule<ServiceModule, ServiceInfo>
implem
       addErrors(serviceInfo.getErrors());
     }
   }
-  
+
 
   @Override
   public String toString() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/56e00acd/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
index b0d81c3..7f83604 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
@@ -68,6 +68,7 @@ public class ServiceInfo implements Validable{
   private String version;
   private String comment;
   private String serviceType;
+  private Selection selection;
 
   @XmlTransient
   private List<PropertyInfo> properties;
@@ -324,6 +325,26 @@ public String getVersion() {
     this.version = version;
   }
 
+  public Selection getSelection() {
+    if (selection == null) {
+      return Selection.DEFAULT;
+    }
+    return selection;
+  }
+
+  public void setSelection(Selection selection) {
+    this.selection = selection;
+  }
+
+  /**
+   * Check if selection was presented in xml. We need this for proper stack inheritance,
because {@link ServiceInfo#getSelection}
+   * by default returns {@link Selection#DEFAULT}, even if no value found in metainfo.xml.
+   * @return true, if selection not defined in metainfo.xml
+   */
+  public boolean isSelectionEmpty() {
+    return selection == null;
+  }
+
   public String getComment() {
     return comment;
   }
@@ -977,4 +998,10 @@ public String getVersion() {
     }
   }
 
+  public enum Selection {
+    DEFAULT,
+    TECH_PREVIEW,
+    MANDATORY,
+    DEPRECATED
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/56e00acd/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index eb27878..30d83bd 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -208,6 +208,7 @@
         "StackServices/stack_version",
         "StackServices/service_name",
         "StackServices/display_name",
+        "StackServices/selection",
         "StackServices/user_name",
         "StackServices/comments",
         "StackServices/service_version",

http://git-wip-us.apache.org/repos/asf/ambari/blob/56e00acd/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
index a9a8fdb..47f5eb9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/stack/ServiceModuleTest.java
@@ -730,6 +730,25 @@ public class ServiceModuleTest {
   }
 
   @Test
+  public void testResolve_Service__selection() throws Exception {
+    ServiceInfo firstInfo = new ServiceInfo();
+    ServiceInfo secondInfo = new ServiceInfo();
+    ServiceInfo thirdInfo = new ServiceInfo();
+
+    firstInfo.setSelection(ServiceInfo.Selection.MANDATORY);
+
+    resolveService(secondInfo, firstInfo);
+
+    assertEquals(secondInfo.getSelection(), ServiceInfo.Selection.MANDATORY);
+
+    thirdInfo.setSelection(ServiceInfo.Selection.TECH_PREVIEW);
+
+    resolveService(thirdInfo, secondInfo);
+
+    assertEquals(thirdInfo.getSelection(), ServiceInfo.Selection.TECH_PREVIEW);
+  }
+
+  @Test
   public void testResolve_Configuration__attributes() throws Exception {
     ServiceInfo info = new ServiceInfo();
     ServiceInfo parentInfo = new ServiceInfo();

http://git-wip-us.apache.org/repos/asf/ambari/blob/56e00acd/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceInfoTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceInfoTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceInfoTest.java
index 1754cbb..9986ee3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceInfoTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceInfoTest.java
@@ -112,6 +112,36 @@ public class ServiceInfoTest {
   }
 
   @Test
+  public void testSelectionField() throws Exception {
+    String serviceInfoXmlDeprecated = "<metainfo>\n" +
+        "  <schemaVersion>2.0</schemaVersion>\n" +
+        "  <services>\n" +
+        "    <service>\n" +
+        "      <name>DEPRECATED</name>\n" +
+        "      <selection>DEPRECATED</selection>\n" +
+        "    </service>\n" +
+        "  </services>\n" +
+        "</metainfo>\n";
+    Map<String, ServiceInfo> serviceInfoMapDeprecated = getServiceInfo(serviceInfoXmlDeprecated);
+    ServiceInfo deprecated = serviceInfoMapDeprecated.get("DEPRECATED");
+    assertEquals(deprecated.getSelection(), ServiceInfo.Selection.DEPRECATED);
+    assertFalse(deprecated.isSelectionEmpty());
+
+    String serviceInfoXmlDefault = "<metainfo>\n" +
+        "  <schemaVersion>2.0</schemaVersion>\n" +
+        "  <services>\n" +
+        "    <service>\n" +
+        "      <name>DEFAULT</name>\n" +
+        "    </service>\n" +
+        "  </services>\n" +
+        "</metainfo>\n";
+    Map<String, ServiceInfo> serviceInfoMapDefault = getServiceInfo(serviceInfoXmlDefault);
+    ServiceInfo defaultSi = serviceInfoMapDefault.get("DEFAULT");
+    assertEquals(defaultSi.getSelection(), ServiceInfo.Selection.DEFAULT);
+    assertTrue(defaultSi.isSelectionEmpty());
+  }
+
+  @Test
   public void testSetRestartRequiredAfterRackChange() throws Exception {
     ServiceInfo serviceInfo = new ServiceInfo();
 


Mime
View raw message