You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ad...@apache.org on 2017/05/23 10:34:42 UTC

[44/49] ambari git commit: AMBARI-21035. Integrate ClusterService with Swagger, addendum (adoroszlai)

AMBARI-21035. Integrate ClusterService with Swagger, addendum (adoroszlai)


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

Branch: refs/heads/trunk
Commit: f2cad775e98e6478fcc4282a8eff1014cc00414d
Parents: f678794
Author: Attila Doroszlai <ad...@hortonworks.com>
Authored: Tue May 23 10:55:13 2017 +0200
Committer: Attila Doroszlai <ad...@hortonworks.com>
Committed: Tue May 23 10:55:13 2017 +0200

----------------------------------------------------------------------
 .../api/services/ClusterRequestSwagger.java     | 30 ++++++++++++++
 .../server/api/services/ClusterService.java     |  2 +-
 .../server/state/ClusterHealthReport.java       | 43 +++++++++++++++-----
 3 files changed, 64 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f2cad775/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterRequestSwagger.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterRequestSwagger.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterRequestSwagger.java
new file mode 100644
index 0000000..693a462
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterRequestSwagger.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.api.services;
+
+import org.apache.ambari.server.controller.ApiModel;
+import org.apache.ambari.server.controller.ClusterRequest;
+import org.apache.ambari.server.controller.internal.ClusterResourceProvider;
+
+import io.swagger.annotations.ApiModelProperty;
+
+@SuppressWarnings("unused") // for Swagger
+public interface ClusterRequestSwagger extends ApiModel {
+  @ApiModelProperty(name = ClusterResourceProvider.RESPONSE_KEY)
+  ClusterRequest getClusterRequest();
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f2cad775/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
index 80fcd2e..f61fb2a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
@@ -59,7 +59,7 @@ import io.swagger.annotations.ApiResponses;
 @Api(value = "/clusters", description = "Endpoint for cluster-specific operations")
 public class ClusterService extends BaseService {
 
-  private static final String CLUSTER_REQUEST_TYPE = "org.apache.ambari.server.controller.ClusterRequest";
+  private static final String CLUSTER_REQUEST_TYPE = "org.apache.ambari.server.api.services.ClusterRequestSwagger";
   private static final String ARTIFACT_REQUEST_TYPE = "org.apache.ambari.server.controller.ClusterArtifactRequest";
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/f2cad775/ambari-server/src/main/java/org/apache/ambari/server/state/ClusterHealthReport.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ClusterHealthReport.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ClusterHealthReport.java
index 4be44c6..90dac00 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ClusterHealthReport.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ClusterHealthReport.java
@@ -20,11 +20,24 @@ package org.apache.ambari.server.state;
 
 import org.codehaus.jackson.annotate.JsonProperty;
 
+import io.swagger.annotations.ApiModelProperty;
+
 /**
  * Cluster Health Report (part of Clusters API response)
  */
 public class ClusterHealthReport {
 
+  private static final String HOST_STALE_CONFIG = "Host/stale_config";
+  private static final String HOST_MAINTENANCE_STATE = "Host/maintenance_state";
+  private static final String HOST_HOST_STATE_HEALTHY = "Host/host_state/HEALTHY";
+  private static final String HOST_HOST_STATE_UNHEALTHY = "Host/host_state/UNHEALTHY";
+  private static final String HOST_HOST_STATE_INIT = "Host/host_state/INIT";
+  private static final String HOST_HOST_STATUS_HEALTHY = "Host/host_status/HEALTHY";
+  private static final String HOST_HOST_STATUS_UNHEALTHY = "Host/host_status/UNHEALTHY";
+  private static final String HOST_HOST_STATUS_UNKNOWN = "Host/host_status/UNKNOWN";
+  private static final String HOST_HOST_STATUS_ALERT = "Host/host_status/ALERT";
+  private static final String HOST_HOST_STATE_HEARTBEAT_LOST = "Host/host_state/HEARTBEAT_LOST";
+
   private int staleConfigsHosts;
   private int maintenanceStateHosts;
 
@@ -41,7 +54,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having stale_config set to true
    */
-  @JsonProperty("Host/stale_config")
+  @JsonProperty(HOST_STALE_CONFIG)
+  @ApiModelProperty(name = HOST_STALE_CONFIG)
   public int getStaleConfigsHosts() {
     return staleConfigsHosts;
   }
@@ -56,7 +70,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having maintenance state on
    */
-  @JsonProperty("Host/maintenance_state")
+  @JsonProperty(HOST_MAINTENANCE_STATE)
+  @ApiModelProperty(name = HOST_MAINTENANCE_STATE)
   public int getMaintenanceStateHosts() {
     return maintenanceStateHosts;
   }
@@ -71,7 +86,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host state HEALTHY
    */
-  @JsonProperty("Host/host_state/HEALTHY")
+  @JsonProperty(HOST_HOST_STATE_HEALTHY)
+  @ApiModelProperty(name = HOST_HOST_STATE_HEALTHY)
   public int getHealthyStateHosts() {
     return healthyStateHosts;
   }
@@ -86,7 +102,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host state UNHEALTHY
    */
-  @JsonProperty("Host/host_state/UNHEALTHY")
+  @JsonProperty(HOST_HOST_STATE_UNHEALTHY)
+  @ApiModelProperty(name = HOST_HOST_STATE_UNHEALTHY)
   public int getUnhealthyStateHosts() {
     return unhealthyStateHosts;
   }
@@ -101,7 +118,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host state INIT
    */
-  @JsonProperty("Host/host_state/INIT")
+  @JsonProperty(HOST_HOST_STATE_INIT)
+  @ApiModelProperty(name = HOST_HOST_STATE_INIT)
   public int getInitStateHosts() {
     return initStateHosts;
   }
@@ -116,7 +134,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host status HEALTHY
    */
-  @JsonProperty("Host/host_status/HEALTHY")
+  @JsonProperty(HOST_HOST_STATUS_HEALTHY)
+  @ApiModelProperty(name = HOST_HOST_STATUS_HEALTHY)
   public int getHealthyStatusHosts() {
     return healthyStatusHosts;
   }
@@ -131,7 +150,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host status UNHEALTHY
    */
-  @JsonProperty("Host/host_status/UNHEALTHY")
+  @JsonProperty(HOST_HOST_STATUS_UNHEALTHY)
+  @ApiModelProperty(name = HOST_HOST_STATUS_UNHEALTHY)
   public int getUnhealthyStatusHosts() {
     return unhealthyStatusHosts;
   }
@@ -146,7 +166,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host status UNKNOWN
    */
-  @JsonProperty("Host/host_status/UNKNOWN")
+  @JsonProperty(HOST_HOST_STATUS_UNKNOWN)
+  @ApiModelProperty(name = HOST_HOST_STATUS_UNKNOWN)
   public int getUnknownStatusHosts() {
     return unknownStatusHosts;
   }
@@ -161,7 +182,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host status ALERT
    */
-  @JsonProperty("Host/host_status/ALERT")
+  @JsonProperty(HOST_HOST_STATUS_ALERT)
+  @ApiModelProperty(name = HOST_HOST_STATUS_ALERT)
   public int getAlertStatusHosts() {
     return alertStatusHosts;
   }
@@ -176,7 +198,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host status HEARTBEAT_LOST
    */
-  @JsonProperty("Host/host_state/HEARTBEAT_LOST")
+  @JsonProperty(HOST_HOST_STATE_HEARTBEAT_LOST)
+  @ApiModelProperty(name = HOST_HOST_STATE_HEARTBEAT_LOST)
   public int getHeartbeatLostStateHosts() {
     return heartbeatLostStateHosts;
   }