소스 검색

[AMBARI-24814] Add a rolling_restart_supported flag at the stack service endpoint (dsen) (#2500)

Dmitry Sen 7 년 전
부모
커밋
a2c6fd99a4

+ 15 - 0
ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java

@@ -78,6 +78,11 @@ public class StackServiceResponse {
    */
   private boolean credentialStoreRequired;
 
+  /**
+   * Whether the service supports rolling restart.
+   * */
+  private boolean rollingRestartSupported;
+
   private boolean isSupportDeleteViaUI;
 
   private final boolean ssoIntegrationSupported;
@@ -121,6 +126,7 @@ public class StackServiceResponse {
     isSupportDeleteViaUI = service.isSupportDeleteViaUI();
     ssoIntegrationSupported = service.isSingleSignOnSupported();
     ssoIntegrationRequiresKerberos = service.isKerberosRequiredForSingleSignOnIntegration();
+    rollingRestartSupported = service.isRollingRestartSupported();
   }
 
   @ApiModelProperty(name = "selection")
@@ -360,6 +366,15 @@ public class StackServiceResponse {
     return ssoIntegrationRequiresKerberos;
   }
 
+  @ApiModelProperty(name = "rolling_restart_supported")
+  public boolean isRollingRestartSupported() {
+    return rollingRestartSupported;
+  }
+
+  public void setRollingRestartSupported(boolean rollingRestartSupported) {
+    this.rollingRestartSupported = rollingRestartSupported;
+  }
+
   public interface StackServiceResponseSwagger extends ApiModel {
     @ApiModelProperty(name = "StackServices")
     public StackServiceResponse getStackServiceResponse();

+ 9 - 1
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java

@@ -111,6 +111,9 @@ public class StackServiceResourceProvider extends ReadOnlyResourceProvider {
   private static final String SSO_INTEGRATION_REQUIRES_KERBEROS_PROPERTY_ID = PropertyHelper.getPropertyId(
     "StackServices", "sso_integration_requires_kerberos");
 
+  private static final String ROLLING_RESTART_SUPPORTED_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServices", "rolling_restart_supported");
+
   /**
    * The key property ids for a StackVersion resource.
    */
@@ -144,7 +147,8 @@ public class StackServiceResourceProvider extends ReadOnlyResourceProvider {
       CREDENTIAL_STORE_ENABLED,
       SUPPORT_DELETE_VIA_UI,
       SSO_INTEGRATION_SUPPORTED_PROPERTY_ID,
-      SSO_INTEGRATION_REQUIRES_KERBEROS_PROPERTY_ID);
+      SSO_INTEGRATION_REQUIRES_KERBEROS_PROPERTY_ID,
+      ROLLING_RESTART_SUPPORTED_PROPERTY_ID);
 
   /**
    * KerberosServiceDescriptorFactory used to create KerberosServiceDescriptor instances
@@ -254,6 +258,10 @@ public class StackServiceResourceProvider extends ReadOnlyResourceProvider {
     setResourceProperty(resource, SUPPORT_DELETE_VIA_UI,
         response.isSupportDeleteViaUI(), requestedIds);
 
+    setResourceProperty(resource, ROLLING_RESTART_SUPPORTED_PROPERTY_ID,
+        response.isRollingRestartSupported(),  requestedIds);
+
+
     setResourceProperty(resource, SSO_INTEGRATION_SUPPORTED_PROPERTY_ID, response.isSsoIntegrationSupported(), requestedIds);
     setResourceProperty(resource, SSO_INTEGRATION_REQUIRES_KERBEROS_PROPERTY_ID, response.isSsoIntegrationRequiresKerberos(), requestedIds);
 

+ 14 - 0
ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java

@@ -329,6 +329,12 @@ public class ServiceInfo implements Validable {
   @XmlTransient
   private File serverActionsFolder;
 
+  /**
+   * Used to determine if rolling restart is supported
+   * */
+  @XmlElement(name = "rollingRestartSupported")
+  private boolean rollingRestartSupported;
+
   public boolean isDeleted() {
     return isDeleted;
   }
@@ -1050,6 +1056,14 @@ public class ServiceInfo implements Validable {
     return kerberosDescriptorFile;
   }
 
+  public boolean isRollingRestartSupported() {
+    return rollingRestartSupported;
+  }
+
+  public void setRollingRestartSupported(boolean rollingRestartSupported) {
+    this.rollingRestartSupported = rollingRestartSupported;
+  }
+
   /**
    * @return the widgets descriptor file, or <code>null</code> if none exists
    */

+ 47 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/ServiceInfoTest.java

@@ -848,6 +848,53 @@ public class ServiceInfoTest {
     assertNull(service.getKerberosEnabledTest());
   }
 
+  @Test
+  public void testIsRollingRestartSupported() throws JAXBException {
+    // set to True
+    String serviceInfoXml =
+        "<metainfo>" +
+            "  <schemaVersion>2.0</schemaVersion>" +
+            "  <services>" +
+            "    <service>" +
+            "      <name>SERVICE</name>" +
+            "      <rollingRestartSupported>true</rollingRestartSupported>" +
+            "    </service>" +
+            "  </services>" +
+            "</metainfo>";
+    Map<String, ServiceInfo> serviceInfoMap = getServiceInfo(serviceInfoXml);
+    assertTrue(serviceInfoMap.get("SERVICE").isRollingRestartSupported());
+    assertTrue(serviceInfoMap.get("SERVICE").isValid());
+
+    // set to False
+    serviceInfoXml =
+        "<metainfo>" +
+            "  <schemaVersion>2.0</schemaVersion>" +
+            "  <services>" +
+            "    <service>" +
+            "      <name>SERVICE</name>" +
+            "      <rollingRestartSupported>false</rollingRestartSupported>" +
+            "    </service>" +
+            "  </services>" +
+            "</metainfo>";
+    serviceInfoMap = getServiceInfo(serviceInfoXml);
+    assertFalse(serviceInfoMap.get("SERVICE").isRollingRestartSupported());
+    assertTrue(serviceInfoMap.get("SERVICE").isValid());
+
+    // default to False
+    serviceInfoXml =
+        "<metainfo>" +
+            "  <schemaVersion>2.0</schemaVersion>" +
+            "  <services>" +
+            "    <service>" +
+            "      <name>SERVICE</name>" +
+            "    </service>" +
+            "  </services>" +
+            "</metainfo>";
+    serviceInfoMap = getServiceInfo(serviceInfoXml);
+    assertFalse(serviceInfoMap.get("SERVICE").isRollingRestartSupported());
+    assertTrue(serviceInfoMap.get("SERVICE").isValid());
+  }
+
   private static Map<String, ServiceInfo> getServiceInfo(String xml) throws JAXBException {
     InputStream configStream = new ByteArrayInputStream(xml.getBytes());
     JAXBContext jaxbContext = JAXBContext.newInstance(ServiceMetainfoXml.class);