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:31 UTC
[33/49] ambari git commit: AMBARI-20951. Integrate HostService
resource with Swagger
AMBARI-20951. Integrate HostService resource with Swagger
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0e13b018
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0e13b018
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0e13b018
Branch: refs/heads/trunk
Commit: 0e13b01849f1b13010a83b01861102a5febb5e7c
Parents: 4ede671
Author: Attila Doroszlai <ad...@hortonworks.com>
Authored: Mon Apr 24 09:46:37 2017 +0200
Committer: Attila Doroszlai <ad...@hortonworks.com>
Committed: Mon May 8 20:52:42 2017 +0200
----------------------------------------------------------------------
.../ambari/server/api/services/BaseService.java | 26 ++
.../ambari/server/api/services/HostService.java | 188 +++++++++---
.../request/eventcreator/HostEventCreator.java | 4 +-
.../ambari/server/controller/HostRequest.java | 72 ++---
.../ambari/server/controller/HostResponse.java | 287 +++++--------------
.../controller/RootServiceResponseFactory.java | 2 +-
.../internal/HostResourceProvider.java | 188 ++++++------
.../controller/internal/HostStatusHelper.java | 7 +-
...ootServiceHostComponentResourceProvider.java | 2 +-
.../internal/ScaleClusterRequest.java | 10 +-
.../controller/utilities/PropertyHelper.java | 2 +-
.../ambari/server/state/host/HostImpl.java | 6 +-
.../ambari/server/topology/AmbariContext.java | 2 +-
.../ambari/server/topology/HostRequest.java | 2 +-
.../server/api/services/HostServiceTest.java | 2 +-
.../request/creator/HostEventCreatorTest.java | 4 +-
.../AmbariManagementControllerTest.java | 54 ++--
.../internal/AbstractResourceProviderTest.java | 5 +-
.../internal/HostResourceProviderTest.java | 74 ++---
...erviceHostComponentResourceProviderTest.java | 11 +-
.../internal/ScaleClusterRequestTest.java | 14 +-
.../server/topology/TopologyManagerTest.java | 4 +-
22 files changed, 434 insertions(+), 532 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseService.java
index 0185d37..76d2b70 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseService.java
@@ -49,6 +49,32 @@ import org.slf4j.LoggerFactory;
public abstract class BaseService {
public final static MediaType MEDIA_TYPE_TEXT_CSV_TYPE = new MediaType("text", "csv");
+ static final String SUCCESSFUL_OPERATION = "Successful operation";
+ static final String REQUEST_ACCEPTED = "Request is accepted, but not completely processed yet";
+ static final String INVALID_ARGUMENTS = "Invalid arguments";
+ static final String CLUSTER_NOT_FOUND = "Cluster not found";
+ static final String CLUSTER_OR_HOST_NOT_FOUND = "Cluster or host not found";
+ static final String NOT_AUTHENTICATED = "Not authenticated";
+ static final String PERMISSION_DENIED = "Not permitted to perform the operation";
+ static final String SERVER_ERROR = "Internal server error";
+
+ static final String QUERY_FIELDS = "fields";
+ static final String QUERY_FILTER_DESCRIPTION = "Filter fields in the response (identifier fields are mandatory)";
+ static final String QUERY_SORT = "sortBy";
+ static final String QUERY_SORT_DESCRIPTION = "Sort resources in result by (asc | desc)";
+ static final String QUERY_PAGE_SIZE = "page_size";
+ static final String QUERY_PAGE_SIZE_DESCRIPTION = "The number of resources to be returned for the paged response.";
+ static final String DEFAULT_PAGE_SIZE = "10";
+ static final String QUERY_FROM = "from";
+ static final String QUERY_FROM_DESCRIPTION = "The starting page resource (inclusive). \"start\" is also accepted.";
+ static final String QUERY_FROM_TYPE = "integer";
+ static final String QUERY_FROM_VALUES = "range[0, infinity]";
+ static final String DEFAULT_FROM = "0";
+ static final String QUERY_TO = "to";
+ static final String QUERY_TO_DESCRIPTION = "The ending page resource (inclusive). \"end\" is also accepted.";
+ static final String QUERY_TO_TYPE = "integer";
+ static final String QUERY_TO_VALUES = "range[1, infinity]";
+
/**
* Logger instance.
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java
index c26c5d8..7b5f9cf 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/HostService.java
@@ -34,23 +34,39 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.controller.HostResponse;
import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.http.HttpStatus;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
/**
* Service responsible for hosts resource requests.
*/
-@Path("/hosts/")
+@Path("/hosts")
+@Api(value = "/hosts", description = "Endpoint for host-specific operations")
public class HostService extends BaseService {
+ private static final String UNKNOWN_HOSTS = "Attempt to add hosts that have not been registered";
+ private static final String HOST_ALREADY_EXISTS = "Attempt to create a host which already exists";
+ private static final String HOST_REQUEST_TYPE = "org.apache.ambari.server.controller.HostRequest";
+
/**
* Parent cluster id.
*/
- private String m_clusterName;
+ private final String m_clusterName;
/**
* Constructor.
*/
public HostService() {
+ this(null);
}
/**
@@ -68,17 +84,28 @@ public class HostService extends BaseService {
*
* @param headers http headers
* @param ui uri info
- * @param hostName host id
+ * @param hostName host name
* @return host resource representation
*/
@GET
@Path("{hostName}")
@Produces("text/plain")
+ @ApiOperation(value = "Returns information about a single host", response = HostResponse.Wrapper.class)
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = QUERY_FIELDS, value = QUERY_FILTER_DESCRIPTION, dataType = "string", paramType = "query"),
+ })
+ @ApiResponses({
+ @ApiResponse(code = HttpStatus.SC_OK, message = SUCCESSFUL_OPERATION),
+ @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = CLUSTER_OR_HOST_NOT_FOUND),
+ @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = NOT_AUTHENTICATED),
+ @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = PERMISSION_DENIED),
+ @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = SERVER_ERROR),
+ })
public Response getHost(String body, @Context HttpHeaders headers, @Context UriInfo ui,
- @PathParam("hostName") String hostName) {
-
+ @ApiParam(value = "host name", required = true) @PathParam("hostName") String hostName
+ ) {
return handleRequest(headers, body, ui, Request.Type.GET,
- createHostResource(m_clusterName, hostName, ui));
+ createHostResource(m_clusterName, hostName));
}
/**
@@ -91,9 +118,24 @@ public class HostService extends BaseService {
*/
@GET
@Produces("text/plain")
+ @ApiOperation(value = "Returns a collection of all hosts", response = HostResponse.Wrapper.class, responseContainer = "List")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = QUERY_FIELDS, value = QUERY_FILTER_DESCRIPTION, defaultValue = "Hosts/*", dataType = "string", paramType = "query"),
+ @ApiImplicitParam(name = QUERY_SORT, value = QUERY_SORT_DESCRIPTION, defaultValue = "Hosts/host_name.asc", dataType = "string", paramType = "query"),
+ @ApiImplicitParam(name = QUERY_PAGE_SIZE, value = QUERY_PAGE_SIZE_DESCRIPTION, defaultValue = DEFAULT_PAGE_SIZE, dataType = "integer", paramType = "query"),
+ @ApiImplicitParam(name = QUERY_FROM, value = QUERY_FROM_DESCRIPTION, allowableValues = QUERY_FROM_VALUES, defaultValue = DEFAULT_FROM, dataType = QUERY_FROM_TYPE, paramType = "query"),
+ @ApiImplicitParam(name = QUERY_TO, value = QUERY_TO_DESCRIPTION, allowableValues = QUERY_TO_VALUES, dataType = QUERY_TO_TYPE, paramType = "query"),
+ })
+ @ApiResponses({
+ @ApiResponse(code = HttpStatus.SC_OK, message = SUCCESSFUL_OPERATION),
+ @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = CLUSTER_NOT_FOUND),
+ @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = NOT_AUTHENTICATED),
+ @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = PERMISSION_DENIED),
+ @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = SERVER_ERROR),
+ })
public Response getHosts(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
return handleRequest(headers, body, ui, Request.Type.GET,
- createHostResource(m_clusterName, null, ui));
+ createHostResource(m_clusterName, null));
}
/**
@@ -109,10 +151,23 @@ public class HostService extends BaseService {
*/
@POST
@Produces("text/plain")
+ @ApiOperation(value = "Creates multiple hosts in a single request")
+ @ApiImplicitParams({
+ @ApiImplicitParam(dataType = HOST_REQUEST_TYPE, paramType = "body", allowMultiple = true)
+ })
+ @ApiResponses({
+ @ApiResponse(code = HttpStatus.SC_CREATED, message = SUCCESSFUL_OPERATION),
+ @ApiResponse(code = HttpStatus.SC_ACCEPTED, message = REQUEST_ACCEPTED),
+ @ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = UNKNOWN_HOSTS),
+ @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = CLUSTER_NOT_FOUND),
+ @ApiResponse(code = HttpStatus.SC_CONFLICT, message = HOST_ALREADY_EXISTS),
+ @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = NOT_AUTHENTICATED),
+ @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = PERMISSION_DENIED),
+ @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = SERVER_ERROR),
+ })
public Response createHosts(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
-
return handleRequest(headers, body, ui, Request.Type.POST,
- createHostResource(m_clusterName, null, ui));
+ createHostResource(m_clusterName, null));
}
/**
@@ -122,18 +177,32 @@ public class HostService extends BaseService {
* @param body http body
* @param headers http headers
* @param ui uri info
- * @param hostName host id
+ * @param hostName host name
*
* @return host resource representation
*/
@POST
@Path("{hostName}")
@Produces("text/plain")
+ @ApiOperation(value = "Creates a host")
+ @ApiImplicitParams({
+ @ApiImplicitParam(dataType = HOST_REQUEST_TYPE, paramType = "body")
+ })
+ @ApiResponses({
+ @ApiResponse(code = HttpStatus.SC_CREATED, message = SUCCESSFUL_OPERATION),
+ @ApiResponse(code = HttpStatus.SC_ACCEPTED, message = REQUEST_ACCEPTED),
+ @ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = INVALID_ARGUMENTS),
+ @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = CLUSTER_NOT_FOUND),
+ @ApiResponse(code = HttpStatus.SC_CONFLICT, message = HOST_ALREADY_EXISTS),
+ @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = NOT_AUTHENTICATED),
+ @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = PERMISSION_DENIED),
+ @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = SERVER_ERROR),
+ })
public Response createHost(String body, @Context HttpHeaders headers, @Context UriInfo ui,
- @PathParam("hostName") String hostName) {
-
+ @ApiParam(value = "host name", required = true) @PathParam("hostName") String hostName
+ ) {
return handleRequest(headers, body, ui, Request.Type.POST,
- createHostResource(m_clusterName, hostName, ui));
+ createHostResource(m_clusterName, hostName));
}
/**
@@ -143,18 +212,31 @@ public class HostService extends BaseService {
* @param body http body
* @param headers http headers
* @param ui uri info
- * @param hostName host id
+ * @param hostName host name
*
* @return information regarding updated host
*/
@PUT
@Path("{hostName}")
@Produces("text/plain")
+ @ApiOperation(value = "Updates a host")
+ @ApiImplicitParams({
+ @ApiImplicitParam(dataType = HOST_REQUEST_TYPE, paramType = "body")
+ })
+ @ApiResponses({
+ @ApiResponse(code = HttpStatus.SC_OK, message = SUCCESSFUL_OPERATION),
+ @ApiResponse(code = HttpStatus.SC_ACCEPTED, message = REQUEST_ACCEPTED),
+ @ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = INVALID_ARGUMENTS),
+ @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = CLUSTER_OR_HOST_NOT_FOUND),
+ @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = NOT_AUTHENTICATED),
+ @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = PERMISSION_DENIED),
+ @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = SERVER_ERROR),
+ })
public Response updateHost(String body, @Context HttpHeaders headers, @Context UriInfo ui,
- @PathParam("hostName") String hostName) {
-
+ @ApiParam(value = "host name", required = true) @PathParam("hostName") String hostName
+ ) {
return handleRequest(headers, body, ui, Request.Type.PUT,
- createHostResource(m_clusterName, hostName, ui));
+ createHostResource(m_clusterName, hostName));
}
/**
@@ -169,10 +251,22 @@ public class HostService extends BaseService {
*/
@PUT
@Produces("text/plain")
+ @ApiOperation(value = "Updates multiple hosts in a single request")
+ @ApiImplicitParams({
+ @ApiImplicitParam(dataType = HOST_REQUEST_TYPE, paramType = "body", allowMultiple = true)
+ })
+ @ApiResponses({
+ @ApiResponse(code = HttpStatus.SC_OK, message = SUCCESSFUL_OPERATION),
+ @ApiResponse(code = HttpStatus.SC_ACCEPTED, message = REQUEST_ACCEPTED),
+ @ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = INVALID_ARGUMENTS),
+ @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = CLUSTER_OR_HOST_NOT_FOUND),
+ @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = NOT_AUTHENTICATED),
+ @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = PERMISSION_DENIED),
+ @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = SERVER_ERROR),
+ })
public Response updateHosts(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
-
return handleRequest(headers, body, ui, Request.Type.PUT,
- createHostResource(m_clusterName, null, ui));
+ createHostResource(m_clusterName, null));
}
/**
@@ -181,32 +275,50 @@ public class HostService extends BaseService {
*
* @param headers http headers
* @param ui uri info
- * @param hostName host id
+ * @param hostName host name
*
* @return host resource representation
*/
@DELETE
@Path("{hostName}")
@Produces("text/plain")
+ @ApiOperation(value = "Deletes a host")
+ @ApiResponses({
+ @ApiResponse(code = HttpStatus.SC_OK, message = SUCCESSFUL_OPERATION),
+ @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = CLUSTER_OR_HOST_NOT_FOUND),
+ @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = NOT_AUTHENTICATED),
+ @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = PERMISSION_DENIED),
+ @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = SERVER_ERROR),
+ })
public Response deleteHost(@Context HttpHeaders headers, @Context UriInfo ui,
- @PathParam("hostName") String hostName) {
-
+ @ApiParam(value = "host name", required = true) @PathParam("hostName") String hostName
+ ) {
return handleRequest(headers, null, ui, Request.Type.DELETE,
- createHostResource(m_clusterName, hostName, ui));
+ createHostResource(m_clusterName, hostName));
}
@DELETE
@Produces("text/plain")
+ @ApiOperation(value = "Deletes multiple hosts in a single request")
+ @ApiImplicitParams({
+ @ApiImplicitParam(dataType = HOST_REQUEST_TYPE, paramType = "body", allowMultiple = true)
+ })
+ @ApiResponses({
+ @ApiResponse(code = HttpStatus.SC_OK, message = SUCCESSFUL_OPERATION),
+ @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = CLUSTER_OR_HOST_NOT_FOUND),
+ @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = NOT_AUTHENTICATED),
+ @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = PERMISSION_DENIED),
+ @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = SERVER_ERROR),
+ })
public Response deleteHosts(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
-
return handleRequest(headers, body, ui, Request.Type.DELETE,
- createHostResource(m_clusterName, null, ui));
+ createHostResource(m_clusterName, null));
}
/**
* Get the host_components sub-resource.
*
- * @param hostName host id
+ * @param hostName host name
* @return the host_components service
*/
@Path("{hostName}/host_components")
@@ -217,7 +329,7 @@ public class HostService extends BaseService {
/**
* Get the kerberos_identities sub-resource.
*
- * @param hostName host id
+ * @param hostName host name
* @return the host_components service
*/
@Path("{hostName}/kerberos_identities")
@@ -228,7 +340,7 @@ public class HostService extends BaseService {
/**
* Get the alerts sub-resource.
*
- * @param hostName host id
+ * @param hostName host name
* @return the alerts service
*/
@Path("{hostName}/alerts")
@@ -239,11 +351,8 @@ public class HostService extends BaseService {
/**
* Gets the alert history service
*
- * @param request
- * the request
- * @param hostName
- * the host name
- *
+ * @param request the request
+ * @param hostName the host name
* @return the alert history service
*/
@Path("{hostName}/alert_history")
@@ -257,11 +366,8 @@ public class HostService extends BaseService {
/**
* Gets the host stack versions service.
*
- * @param request
- * the request
- * @param hostName
- * the host name
- *
+ * @param request the request
+ * @param hostName the host name
* @return the host stack versions service
*/
@Path("{hostName}/stack_versions")
@@ -274,15 +380,11 @@ public class HostService extends BaseService {
/**
* Create a service resource instance.
*
- *
- *
* @param clusterName cluster
* @param hostName host name
- * @param ui uri information
- *
* @return a host resource instance
*/
- ResourceInstance createHostResource(String clusterName, String hostName, UriInfo ui) {
+ protected ResourceInstance createHostResource(String clusterName, String hostName) {
Map<Resource.Type,String> mapIds = new HashMap<>();
mapIds.put(Resource.Type.Host, hostName);
if (clusterName != null) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/HostEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/HostEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/HostEventCreator.java
index d05fe9d..eec7a3a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/HostEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/HostEventCreator.java
@@ -59,7 +59,7 @@ public class HostEventCreator implements RequestAuditEventCreator {
/**
* Pattern to retrieve hostname from url
*/
- private static final Pattern HOSTNAME_PATTERN = Pattern.compile(".*" + HostResourceProvider.HOST_NAME_PROPERTY_ID + "\\s*=\\s*([^&\\s]+).*");
+ private static final Pattern HOSTNAME_PATTERN = Pattern.compile(".*" + HostResourceProvider.HOST_HOST_NAME_PROPERTY_ID + "\\s*=\\s*([^&\\s]+).*");
/**
* {@inheritDoc}
@@ -109,7 +109,7 @@ public class HostEventCreator implements RequestAuditEventCreator {
.withResultStatus(result.getStatus())
.withUrl(request.getURI())
.withRemoteIp(request.getRemoteAddress())
- .withHostName(RequestAuditEventCreatorHelper.getNamedProperty(request, HostResourceProvider.HOST_NAME_PROPERTY_ID))
+ .withHostName(RequestAuditEventCreatorHelper.getNamedProperty(request, HostResourceProvider.HOST_HOST_NAME_PROPERTY_ID))
.build();
case QUERY_POST:
return AddComponentToHostRequestAuditEvent.builder()
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
index a616839..98fd37d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
@@ -19,28 +19,28 @@
package org.apache.ambari.server.controller;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-public class HostRequest {
+import org.apache.ambari.server.controller.internal.HostResourceProvider;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class HostRequest implements ApiModel {
private String hostname;
private String publicHostname;
private String clusterName; // CREATE/UPDATE
- private Map<String, String> hostAttributes; // CREATE/UPDATE
private String rackInfo;
private List<ConfigurationRequest> desiredConfigs; // UPDATE
private String maintenanceState; // UPDATE
private String blueprint;
- private String hostgroup;
- private String hostToClone;
+ private String hostGroup;
- public HostRequest(String hostname, String clusterName, Map<String, String> hostAttributes) {
+ public HostRequest(String hostname, String clusterName) {
this.hostname = hostname;
this.clusterName = clusterName;
- this.hostAttributes = hostAttributes;
}
+ @ApiModelProperty(name = HostResourceProvider.HOST_NAME_PROPERTY_ID)
public String getHostname() {
return hostname;
}
@@ -49,6 +49,7 @@ public class HostRequest {
this.hostname = hostname;
}
+ @ApiModelProperty(hidden = true)
public String getClusterName() {
return clusterName;
}
@@ -57,14 +58,7 @@ public class HostRequest {
this.clusterName = clusterName;
}
- public Map<String, String> getHostAttributes() {
- return hostAttributes;
- }
-
- public void setHostAttributes(Map<String, String> hostAttributes) {
- this.hostAttributes = hostAttributes;
- }
-
+ @ApiModelProperty(name = HostResourceProvider.RACK_INFO_PROPERTY_ID)
public String getRackInfo() {
return rackInfo;
}
@@ -72,7 +66,8 @@ public class HostRequest {
public void setRackInfo(String info) {
rackInfo = info;
}
-
+
+ @ApiModelProperty(name = HostResourceProvider.PUBLIC_NAME_PROPERTY_ID)
public String getPublicHostName() {
return publicHostname;
}
@@ -84,15 +79,17 @@ public class HostRequest {
public void setDesiredConfigs(List<ConfigurationRequest> request) {
desiredConfigs = request;
}
-
+
+ @ApiModelProperty(name = HostResourceProvider.DESIRED_CONFIGS_PROPERTY_ID)
public List<ConfigurationRequest> getDesiredConfigs() {
return desiredConfigs;
}
-
+
public void setMaintenanceState(String state) {
maintenanceState = state;
}
-
+
+ @ApiModelProperty(name = HostResourceProvider.MAINTENANCE_STATE_PROPERTY_ID)
public String getMaintenanceState() {
return maintenanceState;
}
@@ -101,44 +98,21 @@ public class HostRequest {
blueprint = blueprintName;
}
+ @ApiModelProperty(name = HostResourceProvider.BLUEPRINT_PROPERTY_ID)
public String getBlueprintName() {
return blueprint;
}
- public void setHostGroupName(String hostgroupName) {
- hostgroup = hostgroupName;
+ public void setHostGroupName(String hostGroupName) {
+ hostGroup = hostGroupName;
}
+ @ApiModelProperty(name = HostResourceProvider.HOST_GROUP_PROPERTY_ID)
public String getHostGroupName() {
- return hostgroup;
- }
-
- public void setHostToClone(String hostname) {
- hostToClone = hostname;
- }
-
- public String getHostToClone() {
- return hostToClone;
+ return hostGroup;
}
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("{ hostname=").append(hostname).append(", clusterName=").append(clusterName);
- if (hostAttributes != null) {
- sb.append(", hostAttributes=[");
- int i = 0;
- for (Entry<String, String> attr : hostAttributes.entrySet()) {
- if (i != 0) {
- sb.append(",");
- }
- ++i;
- sb.append(attr.getKey());
- sb.append("=");
- sb.append(attr.getValue());
- }
- sb.append(']');
- }
- sb.append(" }");
- return sb.toString();
+ return "{ hostname=" + hostname + ", clusterName=" + clusterName + " }";
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
index 8032801..2479514 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
@@ -22,16 +22,20 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import org.apache.ambari.server.agent.AgentEnv;
import org.apache.ambari.server.agent.DiskInfo;
import org.apache.ambari.server.agent.RecoveryReport;
+import org.apache.ambari.server.controller.internal.HostResourceProvider;
import org.apache.ambari.server.state.AgentVersion;
-import org.apache.ambari.server.state.DesiredConfig;
import org.apache.ambari.server.state.HostConfig;
import org.apache.ambari.server.state.HostHealthStatus;
+import org.apache.ambari.server.state.HostState;
import org.apache.ambari.server.state.MaintenanceState;
+import io.swagger.annotations.ApiModelProperty;
+
public class HostResponse {
private String hostname;
@@ -44,42 +48,28 @@ public class HostResponse {
private String ipv4;
/**
- * Host IP if ipv6 interface available
- */
- private String ipv6;
-
- /**
* Count of cores on Host
*/
- private int cpuCount;
+ private long cpuCount;
/**
* Count of physical cores on Host
*/
- private int phCpuCount;
-
-
+ private long phCpuCount;
+
/**
* Os Architecture
*/
private String osArch;
+ private String osFamily;
+
/**
* OS Type
*/
private String osType;
/**
- * OS Information
- */
- private String osInfo;
-
- /**
- * Amount of available memory for the Host
- */
- private long availableMemBytes;
-
- /**
* Amount of physical memory for the Host
*/
private long totalMemBytes;
@@ -137,14 +127,12 @@ public class HostResponse {
/**
* Public name.
*/
- private String publicHostname = null;
+ private String publicHostname;
/**
* Host State
*/
- private String hostState;
-
- private Map<String, DesiredConfig> desiredConfigs;
+ private HostState hostState;
/**
* Configs derived from Config groups
@@ -156,25 +144,22 @@ public class HostResponse {
*/
private String status;
- private MaintenanceState maintenanceState = null;
+ private MaintenanceState maintenanceState;
public HostResponse(String hostname, String clusterName,
- String ipv4, String ipv6, int cpuCount, int phCpuCount, String osArch, String osType,
- String osInfo, long availableMemBytes, long totalMemBytes,
+ String ipv4, int cpuCount, int phCpuCount, String osArch, String osType,
+ long totalMemBytes,
List<DiskInfo> disksInfo, long lastHeartbeatTime,
long lastRegistrationTime, String rackInfo,
Map<String, String> hostAttributes, AgentVersion agentVersion,
- HostHealthStatus healthStatus, String hostState, String status) {
+ HostHealthStatus healthStatus, HostState hostState, String status) {
this.hostname = hostname;
this.clusterName = clusterName;
this.ipv4 = ipv4;
- this.ipv6 = ipv6;
this.cpuCount = cpuCount;
this.phCpuCount = phCpuCount;
this.osArch = osArch;
this.osType = osType;
- this.osInfo = osInfo;
- this.availableMemBytes = availableMemBytes;
this.totalMemBytes = totalMemBytes;
this.disksInfo = disksInfo;
this.lastHeartbeatTime = lastHeartbeatTime;
@@ -183,37 +168,30 @@ public class HostResponse {
this.hostAttributes = hostAttributes;
this.agentVersion = agentVersion;
this.healthStatus = healthStatus;
- this.setHostState(hostState);
+ this.hostState = hostState;
this.status = status;
}
//todo: why are we passing in empty strings for host/cluster name instead of null?
public HostResponse(String hostname) {
- this(hostname, "", "", "",
- 0, 0, "", "",
- "", 0, 0, new ArrayList<DiskInfo>(),
+ this(hostname, "", "",
+ 0, 0, "", "",
+ 0, new ArrayList<DiskInfo>(),
0, 0, "",
new HashMap<String, String>(),
null, null, null, null);
}
- /**
- * @return the hostname
- */
+ @ApiModelProperty(name = HostResourceProvider.HOST_NAME_PROPERTY_ID)
public String getHostname() {
return hostname;
}
- /**
- * @param hostname the hostname to set
- */
public void setHostname(String hostname) {
this.hostname = hostname;
}
- /**
- * @return the clusterNames
- */
+ @ApiModelProperty(name = HostResourceProvider.CLUSTER_NAME_PROPERTY_ID)
public String getClusterName() {
return clusterName;
}
@@ -225,300 +203,175 @@ public class HostResponse {
this.clusterName = clusterName;
}
- /**
- * @return the ipv4
- */
+ @ApiModelProperty(name = HostResourceProvider.IP_PROPERTY_ID)
public String getIpv4() {
return ipv4;
}
- /**
- * @param ipv4 the ipv4 to set
- */
public void setIpv4(String ipv4) {
this.ipv4 = ipv4;
}
- /**
- * @return the ipv6
- */
- public String getIpv6() {
- return ipv6;
- }
-
- /**
- * @param ipv6 the ipv6 to set
- */
- public void setIpv6(String ipv6) {
- this.ipv6 = ipv6;
- }
-
- /**
- * @return the cpuCount
- */
- public int getCpuCount() {
+ @ApiModelProperty(name = HostResourceProvider.CPU_COUNT_PROPERTY_ID)
+ public long getCpuCount() {
return cpuCount;
}
- /**
- * @param cpuCount the cpuCount to set
- */
- public void setCpuCount(int cpuCount) {
+ public void setCpuCount(long cpuCount) {
this.cpuCount = cpuCount;
}
- /**
- * @return the phCpuCount
- */
- public int getPhCpuCount() {
+ @ApiModelProperty(name = HostResourceProvider.PHYSICAL_CPU_COUNT_PROPERTY_ID)
+ public long getPhCpuCount() {
return phCpuCount;
}
- /**
- * @param phCpuCount the physical cpu count to set
- */
- public void setPhCpuCount(int phCpuCount) {
+ public void setPhCpuCount(long phCpuCount) {
this.phCpuCount = phCpuCount;
}
-
-
- /**
- * @return the osArch
- */
+ @ApiModelProperty(name = HostResourceProvider.OS_ARCH_PROPERTY_ID)
public String getOsArch() {
return osArch;
}
- /**
- * @param osArch the osArch to set
- */
public void setOsArch(String osArch) {
this.osArch = osArch;
}
- /**
- * @return the osType
- */
- public String getOsType() {
- return osType;
+ @ApiModelProperty(name = HostResourceProvider.OS_FAMILY_PROPERTY_ID)
+ public String getOsFamily() {
+ return osFamily;
}
- /**
- * @param osType the osType to set
- */
- public void setOsType(String osType) {
- this.osType = osType;
+ public void setOsFamily(String osFamily) {
+ this.osFamily = osFamily;
}
- /**
- * @return the osInfo
- */
- public String getOsInfo() {
- return osInfo;
- }
-
- /**
- * @param osInfo the osInfo to set
- */
- public void setOsInfo(String osInfo) {
- this.osInfo = osInfo;
- }
-
- /**
- * @return the availableMemBytes
- */
- public long getAvailableMemBytes() {
- return availableMemBytes;
+ @ApiModelProperty(name = HostResourceProvider.OS_TYPE_PROPERTY_ID)
+ public String getOsType() {
+ return osType;
}
- /**
- * @param availableMemBytes the availableMemBytes to set
- */
- public void setAvailableMemBytes(long availableMemBytes) {
- this.availableMemBytes = availableMemBytes;
+ public void setOsType(String osType) {
+ this.osType = osType;
}
- /**
- * @return the totalMemBytes
- */
+ @ApiModelProperty(name = HostResourceProvider.TOTAL_MEM_PROPERTY_ID)
public long getTotalMemBytes() {
return totalMemBytes;
}
- /**
- * @param totalMemBytes the totalMemBytes to set
- */
public void setTotalMemBytes(long totalMemBytes) {
this.totalMemBytes = totalMemBytes;
}
- /**
- * @return the disksInfo
- */
+ @ApiModelProperty(name = HostResourceProvider.DISK_INFO_PROPERTY_ID)
public List<DiskInfo> getDisksInfo() {
return disksInfo;
}
- /**
- * @param disksInfo the disksInfo to set
- */
public void setDisksInfo(List<DiskInfo> disksInfo) {
this.disksInfo = disksInfo;
}
- /**
- * @return the lastHeartbeatTime
- */
+ @ApiModelProperty(name = HostResourceProvider.LAST_HEARTBEAT_TIME_PROPERTY_ID)
public long getLastHeartbeatTime() {
return lastHeartbeatTime;
}
- /**
- * @param lastHeartbeatTime the lastHeartbeatTime to set
- */
public void setLastHeartbeatTime(long lastHeartbeatTime) {
this.lastHeartbeatTime = lastHeartbeatTime;
}
- /**
- * @return the lastRegistrationTime
- */
+ @ApiModelProperty(name = HostResourceProvider.LAST_REGISTRATION_TIME_PROPERTY_ID)
public long getLastRegistrationTime() {
return lastRegistrationTime;
}
- /**
- * @param lastRegistrationTime the lastRegistrationTime to set
- */
public void setLastRegistrationTime(long lastRegistrationTime) {
this.lastRegistrationTime = lastRegistrationTime;
}
- /**
- * @return the rackInfo
- */
+ @ApiModelProperty(name = HostResourceProvider.RACK_INFO_PROPERTY_ID)
public String getRackInfo() {
return rackInfo;
}
- /**
- * @param rackInfo the rackInfo to set
- */
public void setRackInfo(String rackInfo) {
this.rackInfo = rackInfo;
}
- /**
- * @return the hostAttributes
- */
+ @ApiModelProperty(hidden = true)
public Map<String, String> getHostAttributes() {
return hostAttributes;
}
- /**
- * @param hostAttributes the hostAttributes to set
- */
public void setHostAttributes(Map<String, String> hostAttributes) {
this.hostAttributes = hostAttributes;
}
- /**
- * @return the agentVersion
- */
+ @ApiModelProperty(hidden = true)
public AgentVersion getAgentVersion() {
return agentVersion;
}
- /**
- * @param agentVersion the agentVersion to set
- */
public void setAgentVersion(AgentVersion agentVersion) {
this.agentVersion = agentVersion;
}
- /**
- * @return the healthStatus
- */
- public HostHealthStatus getHealthStatus() {
- return healthStatus;
+ @ApiModelProperty(name = HostResourceProvider.HOST_HEALTH_REPORT_PROPERTY_ID)
+ public String getHealthReport() {
+ return healthStatus.getHealthReport();
}
- /**
- * @param healthStatus the healthStatus to set
- */
public void setHealthStatus(HostHealthStatus healthStatus) {
this.healthStatus = healthStatus;
}
-
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- HostResponse that = (HostResponse) o;
-
- if (hostname != null ?
- !hostname.equals(that.hostname) : that.hostname != null) {
- return false;
- }
+ HostResponse other = (HostResponse) o;
- return true;
+ return Objects.equals(hostname, other.hostname);
}
@Override
public int hashCode() {
- int result = hostname != null ? hostname.hashCode() : 0;
- return result;
+ return Objects.hashCode(hostname);
}
+ @ApiModelProperty(name = HostResourceProvider.PUBLIC_NAME_PROPERTY_ID)
public String getPublicHostName() {
return publicHostname;
}
-
+
public void setPublicHostName(String name) {
publicHostname = name;
}
- /**
- * @return the hostState
- */
- public String getHostState() {
+ @ApiModelProperty(name = HostResourceProvider.STATE_PROPERTY_ID)
+ public HostState getHostState() {
return hostState;
}
- /**
- * @param hostState the hostState to set
- */
- public void setHostState(String hostState) {
+ public void setHostState(HostState hostState) {
this.hostState = hostState;
}
-
+ @ApiModelProperty(name = HostResourceProvider.LAST_AGENT_ENV_PROPERTY_ID)
public AgentEnv getLastAgentEnv() {
return lastAgentEnv;
}
- /**
- * @param agentEnv
- */
public void setLastAgentEnv(AgentEnv agentEnv) {
lastAgentEnv = agentEnv;
}
- /**
- * @param desired
- */
- public void setDesiredConfigs(Map<String, DesiredConfig> desired) {
- desiredConfigs = desired;
- }
-
- public Map<String, DesiredConfig> getDesiredConfigs() {
- return desiredConfigs;
- }
-
+ @ApiModelProperty(name = HostResourceProvider.DESIRED_CONFIGS_PROPERTY_ID)
public Map<String, HostConfig> getDesiredHostConfigs() {
return desiredHostConfigs;
}
@@ -527,6 +380,7 @@ public class HostResponse {
this.desiredHostConfigs = desiredHostConfigs;
}
+ @ApiModelProperty(name = HostResourceProvider.HOST_STATUS_PROPERTY_ID)
public String getStatus() {
return status;
}
@@ -535,31 +389,25 @@ public class HostResponse {
this.status = status;
}
- /**
- * @param state the maintenance state
- */
public void setMaintenanceState(MaintenanceState state) {
maintenanceState = state;
}
- /**
- * @return the maintenance state
- */
+ @ApiModelProperty(name = HostResourceProvider.MAINTENANCE_STATE_PROPERTY_ID)
public MaintenanceState getMaintenanceState() {
return maintenanceState;
}
/**
* Get the recovery summary for the host
- * @return
*/
+ @ApiModelProperty(name = HostResourceProvider.RECOVERY_SUMMARY_PROPERTY_ID)
public String getRecoverySummary() {
return recoverySummary;
}
/**
* Set the recovery summary for the host
- * @return
*/
public void setRecoverySummary(String recoverySummary) {
this.recoverySummary = recoverySummary;
@@ -567,17 +415,22 @@ public class HostResponse {
/**
* Get the detailed recovery report
- * @return
*/
+ @ApiModelProperty(name = HostResourceProvider.RECOVERY_REPORT_PROPERTY_ID)
public RecoveryReport getRecoveryReport() {
return recoveryReport;
}
/**
* Set the detailed recovery report
- * @param recoveryReport
*/
public void setRecoveryReport(RecoveryReport recoveryReport) {
this.recoveryReport = recoveryReport;
}
+
+ public interface Wrapper extends ApiModel {
+ @ApiModelProperty(name = HostResourceProvider.RESPONSE_KEY)
+ @SuppressWarnings("unused")
+ HostResponse getHostResponse();
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceResponseFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceResponseFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceResponseFactory.java
index 40fe369..2ceb769 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceResponseFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceResponseFactory.java
@@ -223,7 +223,7 @@ public class RootServiceResponseFactory extends
RUNNING_STATE, getComponentVersion(component.getComponentName(), host), component.getProperties()));
else
response.add(new RootServiceHostComponentResponse(host.getHostname(), component.getComponentName(),
- host.getHostState(), getComponentVersion(component.getComponentName(), host), component.getProperties()));
+ host.getHostState().toString(), getComponentVersion(component.getComponentName(), host), component.getProperties()));
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
index f604a7f..8a78911 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostResourceProvider.java
@@ -39,7 +39,6 @@ import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.controller.ConfigurationRequest;
import org.apache.ambari.server.controller.HostRequest;
import org.apache.ambari.server.controller.HostResponse;
-import org.apache.ambari.server.controller.MaintenanceStateHelper;
import org.apache.ambari.server.controller.RequestStatusResponse;
import org.apache.ambari.server.controller.ServiceComponentHostRequest;
import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
@@ -88,78 +87,67 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
// ----- Property ID constants ---------------------------------------------
// Hosts
- public static final String HOST_CLUSTER_NAME_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "cluster_name");
- public static final String HOST_NAME_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "host_name");
- public static final String HOST_PUBLIC_NAME_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "public_host_name");
- public static final String HOST_IP_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "ip");
- public static final String HOST_TOTAL_MEM_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "total_mem");
- public static final String HOST_CPU_COUNT_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "cpu_count");
- public static final String HOST_PHYSICAL_CPU_COUNT_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "ph_cpu_count");
- public static final String HOST_OS_ARCH_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "os_arch");
- public static final String HOST_OS_TYPE_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "os_type");
- public static final String HOST_OS_FAMILY_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "os_family");
- public static final String HOST_RACK_INFO_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "rack_info");
- public static final String HOST_LAST_HEARTBEAT_TIME_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "last_heartbeat_time");
- public static final String HOST_LAST_REGISTRATION_TIME_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "last_registration_time");
- public static final String HOST_DISK_INFO_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "disk_info");
-
-
- public static final String HOST_HOST_STATUS_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "host_status");
- public static final String HOST_MAINTENANCE_STATE_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "maintenance_state");
-
- public static final String HOST_HOST_HEALTH_REPORT_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "host_health_report");
- public static final String HOST_RECOVERY_REPORT_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "recovery_report");
- public static final String HOST_RECOVERY_SUMMARY_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "recovery_summary");
- public static final String HOST_STATE_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "host_state");
- public static final String HOST_LAST_AGENT_ENV_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "last_agent_env");
- public static final String HOST_DESIRED_CONFIGS_PROPERTY_ID =
- PropertyHelper.getPropertyId("Hosts", "desired_configs");
-
- public static final String BLUEPRINT_PROPERTY_ID =
- PropertyHelper.getPropertyId(null, "blueprint");
- public static final String HOSTGROUP_PROPERTY_ID =
- PropertyHelper.getPropertyId(null, "host_group");
- public static final String HOST_NAME_NO_CATEGORY_PROPERTY_ID =
- PropertyHelper.getPropertyId(null, "host_name");
- public static final String HOST_COUNT_PROPERTY_ID =
- PropertyHelper.getPropertyId(null, "host_count");
- public static final String HOST_PREDICATE_PROPERTY_ID =
- PropertyHelper.getPropertyId(null, "host_predicate");
+ public static final String RESPONSE_KEY = "Hosts";
+
+ public static final String CLUSTER_NAME_PROPERTY_ID = "cluster_name";
+ public static final String CPU_COUNT_PROPERTY_ID = "cpu_count";
+ public static final String DESIRED_CONFIGS_PROPERTY_ID = "desired_configs";
+ public static final String DISK_INFO_PROPERTY_ID = "disk_info";
+ public static final String HOST_HEALTH_REPORT_PROPERTY_ID = "host_health_report";
+ public static final String HOST_NAME_PROPERTY_ID = "host_name";
+ public static final String HOST_STATUS_PROPERTY_ID = "host_status";
+ public static final String IP_PROPERTY_ID = "ip";
+ public static final String LAST_AGENT_ENV_PROPERTY_ID = "last_agent_env";
+ public static final String LAST_HEARTBEAT_TIME_PROPERTY_ID = "last_heartbeat_time";
+ public static final String LAST_REGISTRATION_TIME_PROPERTY_ID = "last_registration_time";
+ public static final String MAINTENANCE_STATE_PROPERTY_ID = "maintenance_state";
+ public static final String OS_ARCH_PROPERTY_ID = "os_arch";
+ public static final String OS_FAMILY_PROPERTY_ID = "os_family";
+ public static final String OS_TYPE_PROPERTY_ID = "os_type";
+ public static final String PHYSICAL_CPU_COUNT_PROPERTY_ID = "ph_cpu_count";
+ public static final String PUBLIC_NAME_PROPERTY_ID = "public_host_name";
+ public static final String RACK_INFO_PROPERTY_ID = "rack_info";
+ public static final String RECOVERY_REPORT_PROPERTY_ID = "recovery_report";
+ public static final String RECOVERY_SUMMARY_PROPERTY_ID = "recovery_summary";
+ public static final String STATE_PROPERTY_ID = "host_state";
+ public static final String TOTAL_MEM_PROPERTY_ID = "total_mem";
+
+ public static final String HOST_CLUSTER_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + CLUSTER_NAME_PROPERTY_ID;
+ public static final String HOST_CPU_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + CPU_COUNT_PROPERTY_ID;
+ public static final String HOST_DESIRED_CONFIGS_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + DESIRED_CONFIGS_PROPERTY_ID;
+ public static final String HOST_DISK_INFO_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + DISK_INFO_PROPERTY_ID;
+ public static final String HOST_HOST_HEALTH_REPORT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + HOST_HEALTH_REPORT_PROPERTY_ID;
+ public static final String HOST_HOST_STATUS_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + HOST_STATUS_PROPERTY_ID;
+ public static final String HOST_IP_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + IP_PROPERTY_ID;
+ public static final String HOST_LAST_AGENT_ENV_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + LAST_AGENT_ENV_PROPERTY_ID;
+ public static final String HOST_LAST_HEARTBEAT_TIME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + LAST_HEARTBEAT_TIME_PROPERTY_ID;
+ public static final String HOST_LAST_REGISTRATION_TIME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + LAST_REGISTRATION_TIME_PROPERTY_ID;
+ public static final String HOST_MAINTENANCE_STATE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + MAINTENANCE_STATE_PROPERTY_ID;
+ public static final String HOST_HOST_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + HOST_NAME_PROPERTY_ID;
+ public static final String HOST_OS_ARCH_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + OS_ARCH_PROPERTY_ID;
+ public static final String HOST_OS_FAMILY_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + OS_FAMILY_PROPERTY_ID;
+ public static final String HOST_OS_TYPE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + OS_TYPE_PROPERTY_ID;
+ public static final String HOST_PHYSICAL_CPU_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + PHYSICAL_CPU_COUNT_PROPERTY_ID;
+ public static final String HOST_PUBLIC_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + PUBLIC_NAME_PROPERTY_ID;
+ public static final String HOST_RACK_INFO_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + RACK_INFO_PROPERTY_ID;
+ public static final String HOST_RECOVERY_REPORT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + RECOVERY_REPORT_PROPERTY_ID;
+ public static final String HOST_RECOVERY_SUMMARY_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + RECOVERY_SUMMARY_PROPERTY_ID;
+ public static final String HOST_STATE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + STATE_PROPERTY_ID;
+ public static final String HOST_TOTAL_MEM_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + TOTAL_MEM_PROPERTY_ID;
+
+ public static final String BLUEPRINT_PROPERTY_ID = "blueprint";
+ public static final String HOST_GROUP_PROPERTY_ID = "host_group";
+ public static final String HOST_COUNT_PROPERTY_ID = "host_count";
+ public static final String HOST_PREDICATE_PROPERTY_ID = "host_predicate";
//todo use the same json structure for cluster host addition (cluster template and upscale)
- public static final String HOST_RACK_INFO_NO_CATEGORY_PROPERTY_ID =
- PropertyHelper.getPropertyId(null, "rack_info");
protected static final String FORCE_DELETE_COMPONENTS = "force_delete_components";
private static Set<String> pkPropertyIds =
new HashSet<>(Arrays.asList(new String[]{
- HOST_NAME_PROPERTY_ID}));
-
- @Inject
- private MaintenanceStateHelper maintenanceStateHelper;
+ HOST_HOST_NAME_PROPERTY_ID}));
@Inject
private OsFamily osFamily;
@@ -250,7 +238,7 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
setResourceProperty(resource, HOST_CLUSTER_NAME_PROPERTY_ID,
response.getClusterName(), requestedIds);
}
- setResourceProperty(resource, HOST_NAME_PROPERTY_ID,
+ setResourceProperty(resource, HOST_HOST_NAME_PROPERTY_ID,
response.getHostname(), requestedIds);
setResourceProperty(resource, HOST_PUBLIC_NAME_PROPERTY_ID,
response.getPublicHostName(), requestedIds);
@@ -259,22 +247,15 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
setResourceProperty(resource, HOST_TOTAL_MEM_PROPERTY_ID,
response.getTotalMemBytes(), requestedIds);
setResourceProperty(resource, HOST_CPU_COUNT_PROPERTY_ID,
- (long) response.getCpuCount(), requestedIds);
+ response.getCpuCount(), requestedIds);
setResourceProperty(resource, HOST_PHYSICAL_CPU_COUNT_PROPERTY_ID,
- (long) response.getPhCpuCount(), requestedIds);
+ response.getPhCpuCount(), requestedIds);
setResourceProperty(resource, HOST_OS_ARCH_PROPERTY_ID,
response.getOsArch(), requestedIds);
setResourceProperty(resource, HOST_OS_TYPE_PROPERTY_ID,
response.getOsType(), requestedIds);
-
- String hostOsFamily = osFamily.find(response.getOsType());
- if (hostOsFamily == null) {
- LOG.error("Can not find host OS family. For OS type = '{}' and host name = '{}'",
- response.getOsType(), response.getHostname());
- }
setResourceProperty(resource, HOST_OS_FAMILY_PROPERTY_ID,
- hostOsFamily, requestedIds);
-
+ response.getOsFamily(), requestedIds);
setResourceProperty(resource, HOST_RACK_INFO_PROPERTY_ID,
response.getRackInfo(), requestedIds);
setResourceProperty(resource, HOST_LAST_HEARTBEAT_TIME_PROPERTY_ID,
@@ -286,7 +267,7 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
setResourceProperty(resource, HOST_HOST_STATUS_PROPERTY_ID,
response.getStatus(),requestedIds);
setResourceProperty(resource, HOST_HOST_HEALTH_REPORT_PROPERTY_ID,
- response.getHealthStatus().getHealthReport(), requestedIds);
+ response.getHealthReport(), requestedIds);
setResourceProperty(resource, HOST_RECOVERY_REPORT_PROPERTY_ID,
response.getRecoveryReport(), requestedIds);
setResourceProperty(resource, HOST_RECOVERY_SUMMARY_PROPERTY_ID,
@@ -363,12 +344,11 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
Set<String> baseUnsupported = super.checkPropertyIds(propertyIds);
baseUnsupported.remove(BLUEPRINT_PROPERTY_ID);
- baseUnsupported.remove(HOSTGROUP_PROPERTY_ID);
- baseUnsupported.remove(HOST_NAME_NO_CATEGORY_PROPERTY_ID);
- //todo: constants
+ baseUnsupported.remove(HOST_GROUP_PROPERTY_ID);
+ baseUnsupported.remove(HOST_NAME_PROPERTY_ID);
baseUnsupported.remove(HOST_COUNT_PROPERTY_ID);
baseUnsupported.remove(HOST_PREDICATE_PROPERTY_ID);
- baseUnsupported.remove(HOST_RACK_INFO_NO_CATEGORY_PROPERTY_ID);
+ baseUnsupported.remove(RACK_INFO_PROPERTY_ID);
return checkConfigPropertyIds(baseUnsupported, "Hosts");
}
@@ -397,7 +377,7 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
Set<Map<String, Object>> properties = request.getProperties();
if (properties != null && ! properties.isEmpty()) {
//todo: for now, either all or none of the hosts need to specify a hg. Unable to mix.
- String hgName = (String) properties.iterator().next().get(HOSTGROUP_PROPERTY_ID);
+ String hgName = (String) properties.iterator().next().get(HOST_GROUP_PROPERTY_ID);
isHostGroupRequest = hgName != null && ! hgName.isEmpty();
}
return isHostGroupRequest;
@@ -413,21 +393,21 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
private HostRequest getRequest(Map<String, Object> properties) {
if (properties == null) {
- return new HostRequest(null, null, null);
+ return new HostRequest(null, null);
}
HostRequest hostRequest = new HostRequest(
getHostNameFromProperties(properties),
- (String) properties.get(HOST_CLUSTER_NAME_PROPERTY_ID),
- null);
+ (String) properties.get(HOST_CLUSTER_NAME_PROPERTY_ID)
+ );
hostRequest.setPublicHostName((String) properties.get(HOST_PUBLIC_NAME_PROPERTY_ID));
String rackInfo = (String) ((null != properties.get(HOST_RACK_INFO_PROPERTY_ID))? properties.get(HOST_RACK_INFO_PROPERTY_ID):
- properties.get(HOST_RACK_INFO_NO_CATEGORY_PROPERTY_ID));
+ properties.get(RACK_INFO_PROPERTY_ID));
hostRequest.setRackInfo(rackInfo);
hostRequest.setBlueprintName((String) properties.get(BLUEPRINT_PROPERTY_ID));
- hostRequest.setHostGroupName((String) properties.get(HOSTGROUP_PROPERTY_ID));
+ hostRequest.setHostGroupName((String) properties.get(HOST_GROUP_PROPERTY_ID));
Object o = properties.get(HOST_MAINTENANCE_STATE_PROPERTY_ID);
if (null != o) {
@@ -446,7 +426,6 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
* Accepts a request with registered hosts and if the request contains a cluster name then will map all of the
* hosts onto that cluster.
* @param request Request that must contain registered hosts, and optionally a cluster.
- * @throws AmbariException
*/
public synchronized void createHosts(Request request)
throws AmbariException {
@@ -469,7 +448,7 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
for (Map<String, Object> propertyMap : propertySet) {
HostRequest hostRequest = getRequest(propertyMap);
hostRequests.add(hostRequest);
- if (! propertyMap.containsKey(HOSTGROUP_PROPERTY_ID)) {
+ if (! propertyMap.containsKey(HOST_GROUP_PROPERTY_ID)) {
createHostResource(clusters, duplicates, unknowns, allHosts, hostRequest);
}
}
@@ -518,9 +497,6 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
clusterSet.add(hostRequest.getClusterName());
allClusterSet.add(hostRequest.getClusterName());
hostClustersMap.put(hostRequest.getHostname(), clusterSet);
- if (hostRequest.getHostAttributes() != null) {
- hostAttributes.put(hostRequest.getHostname(), hostRequest.getHostAttributes());
- }
}
}
clusters.updateHostWithClusterAndAttributes(hostClustersMap, hostAttributes);
@@ -603,7 +579,7 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
for (HostRequest request : requests) {
try {
- response.addAll(getHosts(controller, request));
+ response.addAll(getHosts(controller, request, osFamily));
} catch (HostNotFoundException e) {
if (requests.size() == 1) {
// only throw exception if 1 request.
@@ -615,7 +591,10 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
return response;
}
- protected static Set<HostResponse> getHosts(AmbariManagementController controller, HostRequest request)
+ /**
+ * @param osFamily provides OS to OS family lookup; may be null if OS family is ignored anyway (eg. for liveness check)
+ */
+ protected static Set<HostResponse> getHosts(AmbariManagementController controller, HostRequest request, OsFamily osFamily)
throws AmbariException {
//TODO/FIXME host can only belong to a single cluster so get host directly from Cluster
@@ -665,6 +644,13 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
r.setClusterName(clusterName);
r.setDesiredHostConfigs(h.getDesiredHostConfigs(cluster, desiredConfigs));
r.setMaintenanceState(h.getMaintenanceState(cluster.getClusterId()));
+ if (osFamily != null) {
+ String hostOsFamily = osFamily.find(r.getOsType());
+ if (hostOsFamily == null) {
+ LOG.error("Can not find host OS family. For OS type = '{}' and host name = '{}'", r.getOsType(), r.getHostname());
+ }
+ r.setOsFamily(hostOsFamily);
+ }
response.add(r);
} else if (hostName != null) {
@@ -726,13 +712,6 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
// do nothing
}
- if (null != request.getHostAttributes()) {
- if(!AuthorizationHelper.isAuthorized(ResourceType.CLUSTER, resourceId, RoleAuthorization.HOST_ADD_DELETE_HOSTS)) {
- throw new AuthorizationException("The authenticated user is not authorized to update host attributes");
- }
- host.setHostAttributes(request.getHostAttributes());
- }
-
String rackInfo = host.getRackInfo();
String requestRackInfo = request.getRackInfo();
boolean rackChange = requestRackInfo != null && !requestRackInfo.equals(rackInfo);
@@ -999,9 +978,6 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
/**
* Removes hostname from the stateful cluster topology
- * @param clusters
- * @param hostRequest
- * @throws AmbariException
*/
private void removeHostFromClusterTopology(Clusters clusters, HostRequest hostRequest) throws AmbariException{
if (hostRequest.getClusterName() == null) {
@@ -1032,10 +1008,10 @@ public class HostResourceProvider extends AbstractControllerResourceProvider {
* @return the host name for the host request
*/
private String getHostNameFromProperties(Map<String, Object> properties) {
- String hostname = (String) properties.get(HOST_NAME_PROPERTY_ID);
+ String hostname = (String) properties.get(HOST_HOST_NAME_PROPERTY_ID);
return hostname != null ? hostname :
- (String) properties.get(HOST_NAME_NO_CATEGORY_PROPERTY_ID);
+ (String) properties.get(HOST_NAME_PROPERTY_ID);
}
//todo: for api/v1/hosts we also end up here so we need to ensure proper 400 response
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStatusHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStatusHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStatusHelper.java
index 96457ed..11512c4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStatusHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStatusHelper.java
@@ -72,9 +72,8 @@ public class HostStatusHelper {
HostResponse hostResponse;
try {
- HostRequest hostRequest = new HostRequest(hostName, clusterName,
- Collections.<String, String>emptyMap());
- Set<HostResponse> hosts = HostResourceProvider.getHosts(managementController, hostRequest);
+ HostRequest hostRequest = new HostRequest(hostName, clusterName);
+ Set<HostResponse> hosts = HostResourceProvider.getHosts(managementController, hostRequest, null);
hostResponse = hosts.size() == 1 ? hosts.iterator().next() : null;
} catch (AmbariException e) {
@@ -83,6 +82,6 @@ public class HostStatusHelper {
}
//Cluster without host
return hostResponse != null &&
- !hostResponse.getHostState().equals(HostState.HEARTBEAT_LOST.name());
+ !hostResponse.getHostState().equals(HostState.HEARTBEAT_LOST);
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceHostComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceHostComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceHostComponentResourceProvider.java
index c2fb844..d5c33c1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceHostComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceHostComponentResourceProvider.java
@@ -163,7 +163,7 @@ public class RootServiceHostComponentResourceProvider extends
AmbariManagementController controller = getManagementController();
//Get all hosts of all clusters
Set<HostResponse> hosts = HostResourceProvider.getHosts(controller,
- new HostRequest(request.getHostName(), null, null));
+ new HostRequest(request.getHostName(), null), null);
return controller.getRootServiceResponseFactory().getRootServiceHostComponent(request, hosts);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
index b5d2f9d..5e9091f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
@@ -112,7 +112,7 @@ public class ScaleClusterRequest extends BaseClusterRequest {
throw new InvalidTopologyTemplateException("Blueprint name must be specified for all host groups");
}
- String hgName = String.valueOf(properties.get(HostResourceProvider.HOSTGROUP_PROPERTY_ID));
+ String hgName = String.valueOf(properties.get(HostResourceProvider.HOST_GROUP_PROPERTY_ID));
if (hgName == null || hgName.equals("null")) {
throw new InvalidTopologyTemplateException("A name must be specified for all host groups");
}
@@ -187,8 +187,8 @@ public class ScaleClusterRequest extends BaseClusterRequest {
String rackInfo = null;
if (properties.containsKey(HostResourceProvider.HOST_RACK_INFO_PROPERTY_ID)) {
rackInfo = (String) properties.get(HostResourceProvider.HOST_RACK_INFO_PROPERTY_ID);
- } else if (properties.containsKey(HostResourceProvider.HOST_RACK_INFO_NO_CATEGORY_PROPERTY_ID)) {
- rackInfo = (String) properties.get(HostResourceProvider.HOST_RACK_INFO_NO_CATEGORY_PROPERTY_ID);
+ } else if (properties.containsKey(HostResourceProvider.RACK_INFO_PROPERTY_ID)) {
+ rackInfo = (String) properties.get(HostResourceProvider.RACK_INFO_PROPERTY_ID);
} else {
LOGGER.debug("No rack info provided");
}
@@ -226,9 +226,9 @@ public class ScaleClusterRequest extends BaseClusterRequest {
*/
//todo: this was copied exactly from HostResourceProvider
private String getHostNameFromProperties(Map<String, Object> properties) {
- String hostName = (String) properties.get(HostResourceProvider.HOST_NAME_PROPERTY_ID);
+ String hostName = (String) properties.get(HostResourceProvider.HOST_HOST_NAME_PROPERTY_ID);
if (hostName == null) {
- hostName = (String) properties.get(HostResourceProvider.HOST_NAME_NO_CATEGORY_PROPERTY_ID);
+ hostName = (String) properties.get(HostResourceProvider.HOST_NAME_PROPERTY_ID);
}
return hostName;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java
index c747a33..3fb59be 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java
@@ -49,7 +49,7 @@ public class PropertyHelper {
private static final String SQLSERVER_PROPERTIES_FILE = "sqlserver_properties.json";
private static final String JMX_PROPERTIES_FILE = "jmx_properties.json";
private static final String KEY_PROPERTIES_FILE = "key_properties.json";
- private static final char EXTERNAL_PATH_SEP = '/';
+ public static final char EXTERNAL_PATH_SEP = '/';
/**
* Aggregate functions implicitly supported by the Metrics Service
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
index db228b1..4624ea8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
@@ -938,25 +938,21 @@ public class HostImpl implements Host {
public HostResponse convertToResponse() {
HostResponse r = new HostResponse(getHostName());
- r.setAgentVersion(getAgentVersion());
- r.setAvailableMemBytes(getAvailableMemBytes());
r.setPhCpuCount(getPhCpuCount());
r.setCpuCount(getCpuCount());
r.setDisksInfo(getDisksInfo());
r.setHealthStatus(getHealthStatus());
r.setHostAttributes(getHostAttributes());
r.setIpv4(getIPv4());
- r.setIpv6(getIPv6());
r.setLastHeartbeatTime(getLastHeartbeatTime());
r.setLastAgentEnv(lastAgentEnv);
r.setLastRegistrationTime(getLastRegistrationTime());
r.setOsArch(getOsArch());
- r.setOsInfo(getOsInfo());
r.setOsType(getOsType());
r.setRackInfo(getRackInfo());
r.setTotalMemBytes(getTotalMemBytes());
r.setPublicHostName(getPublicHostName());
- r.setHostState(getState().toString());
+ r.setHostState(getState());
r.setStatus(getStatus());
r.setRecoveryReport(getRecoveryReport());
r.setRecoverySummary(getRecoveryReport().getSummary());
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
index 6d12402..f2b616c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
@@ -264,7 +264,7 @@ public class AmbariContext {
Map<String, Object> properties = new HashMap<>();
properties.put(HostResourceProvider.HOST_CLUSTER_NAME_PROPERTY_ID, clusterName);
- properties.put(HostResourceProvider.HOST_NAME_PROPERTY_ID, hostName);
+ properties.put(HostResourceProvider.HOST_HOST_NAME_PROPERTY_ID, hostName);
properties.put(HostResourceProvider.HOST_RACK_INFO_PROPERTY_ID, host.getRackInfo());
try {
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
index 168d13b..54420a4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
@@ -488,7 +488,7 @@ public class HostRequest implements Comparable<HostRequest> {
private void buildPropertyMap(HostImpl host) {
hostResource = new ResourceImpl(Resource.Type.Host);
- hostResource.setProperty(HostResourceProvider.HOST_NAME_PROPERTY_ID,
+ hostResource.setProperty(HostResourceProvider.HOST_HOST_NAME_PROPERTY_ID,
host.getHostName());
hostResource.setProperty(HostResourceProvider.HOST_PUBLIC_NAME_PROPERTY_ID,
host.getPublicHostName());
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/test/java/org/apache/ambari/server/api/services/HostServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/HostServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/HostServiceTest.java
index 6aef04d..84f08ae 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/HostServiceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/HostServiceTest.java
@@ -96,7 +96,7 @@ public class HostServiceTest extends BaseServiceTest {
}
@Override
- ResourceInstance createHostResource(String clusterName, String hostName, UriInfo ui) {
+ protected ResourceInstance createHostResource(String clusterName, String hostName) {
assertEquals(m_clusterId, clusterName);
assertEquals(m_hostId, hostName);
return getTestResource();
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/HostEventCreatorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/HostEventCreatorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/HostEventCreatorTest.java
index 2d1cefc..bc32aff 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/HostEventCreatorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/audit/request/creator/HostEventCreatorTest.java
@@ -45,7 +45,7 @@ public class HostEventCreatorTest extends AuditEventCreatorTestBase{
HostEventCreator creator = new HostEventCreator();
Map<String,Object> properties = new HashMap<>();
- properties.put(HostResourceProvider.HOST_NAME_PROPERTY_ID, "ambari1.example.com");
+ properties.put(HostResourceProvider.HOST_HOST_NAME_PROPERTY_ID, "ambari1.example.com");
Request request = AuditEventCreatorTestHelper.createRequest(Request.Type.POST, Resource.Type.Host, properties, null);
Result result = AuditEventCreatorTestHelper.createResult(new ResultStatus(ResultStatus.STATUS.OK));
@@ -73,7 +73,7 @@ public class HostEventCreatorTest extends AuditEventCreatorTestBase{
properties.put("host_components", set);
- Request request = AuditEventCreatorTestHelper.createRequest(Request.Type.QUERY_POST, Resource.Type.Host, properties, null, HostResourceProvider.HOST_NAME_PROPERTY_ID + "=ambari1.example.com");
+ Request request = AuditEventCreatorTestHelper.createRequest(Request.Type.QUERY_POST, Resource.Type.Host, properties, null, HostResourceProvider.HOST_HOST_NAME_PROPERTY_ID + "=ambari1.example.com");
Result result = AuditEventCreatorTestHelper.createResult(new ResultStatus(ResultStatus.STATUS.OK));
AuditEvent event = AuditEventCreatorTestHelper.getEvent(creator, request, result);
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 554e089..d613a2e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -1803,7 +1803,7 @@ public class AmbariManagementControllerTest {
Map<String, String> hostAttributes = null;
- HostRequest r1 = new HostRequest(host1, null, hostAttributes);
+ HostRequest r1 = new HostRequest(host1, null);
r1.toString();
Set<HostRequest> requests = new HashSet<>();
@@ -1820,7 +1820,7 @@ public class AmbariManagementControllerTest {
setOsFamily(clusters.getHost(host1), "redhat", "5.9");
setOsFamily(clusters.getHost(host2), "redhat", "5.9");
- HostRequest request = new HostRequest(host2, "foo", new HashMap<String, String>());
+ HostRequest request = new HostRequest(host2, "foo");
requests.add(request);
try {
@@ -1874,9 +1874,9 @@ public class AmbariManagementControllerTest {
setOsFamily(clusters.getHost(host2), "redhat", "5.9");
setOsFamily(clusters.getHost(host3), "redhat", "5.9");
- HostRequest r1 = new HostRequest(host1, cluster1, null);
- HostRequest r2 = new HostRequest(host2, cluster1, null);
- HostRequest r3 = new HostRequest(host3, null, null);
+ HostRequest r1 = new HostRequest(host1, cluster1);
+ HostRequest r2 = new HostRequest(host2, cluster1);
+ HostRequest r3 = new HostRequest(host3, null);
Set<HostRequest> set1 = new HashSet<>();
set1.add(r1);
@@ -1902,7 +1902,7 @@ public class AmbariManagementControllerTest {
try {
set1.clear();
HostRequest rInvalid =
- new HostRequest(host1, null, null);
+ new HostRequest(host1, null);
set1.add(rInvalid);
HostResourceProviderTest.createHosts(controller, set1);
fail("Expected failure for invalid host");
@@ -1915,7 +1915,7 @@ public class AmbariManagementControllerTest {
try {
set1.clear();
HostRequest rInvalid =
- new HostRequest(host1, cluster1, null);
+ new HostRequest(host1, cluster1);
set1.add(rInvalid);
HostResourceProviderTest.createHosts(controller, set1);
fail("Expected failure for invalid cluster");
@@ -1928,9 +1928,9 @@ public class AmbariManagementControllerTest {
try {
set1.clear();
HostRequest rInvalid1 =
- new HostRequest(host1, cluster1, null);
+ new HostRequest(host1, cluster1);
HostRequest rInvalid2 =
- new HostRequest(host1, cluster1, null);
+ new HostRequest(host1, cluster1);
set1.add(rInvalid1);
set1.add(rInvalid2);
HostResourceProviderTest.createHosts(controller, set1);
@@ -3094,7 +3094,7 @@ public class AmbariManagementControllerTest {
attrs.put("a2", "b2");
clusters.getHost(host4).setHostAttributes(attrs);
- HostRequest r = new HostRequest(null, null, null);
+ HostRequest r = new HostRequest(null, null);
Set<HostResponse> resps = HostResourceProviderTest.getHosts(controller, Collections.singleton(r));
@@ -3127,7 +3127,7 @@ public class AmbariManagementControllerTest {
Assert.assertEquals(4, foundHosts.size());
- r = new HostRequest(host1, null, null);
+ r = new HostRequest(host1, null);
resps = HostResourceProviderTest.getHosts(controller, Collections.singleton(r));
Assert.assertEquals(1, resps.size());
HostResponse resp = resps.iterator().next();
@@ -8884,7 +8884,7 @@ public class AmbariManagementControllerTest {
// Case 1: Attempt delete when components still exist
Set<HostRequest> requests = new HashSet<>();
requests.clear();
- requests.add(new HostRequest(host1, cluster1, null));
+ requests.add(new HostRequest(host1, cluster1));
try {
HostResourceProviderTest.deleteHosts(controller, requests, false, false);
fail("Expect failure deleting hosts when components exist and have not been deleted.");
@@ -8993,7 +8993,7 @@ public class AmbariManagementControllerTest {
// Case 1: Attempt delete when components still exist
Set<HostRequest> requests = new HashSet<>();
requests.clear();
- requests.add(new HostRequest(host1, cluster1, null));
+ requests.add(new HostRequest(host1, cluster1));
try {
HostResourceProviderTest.deleteHosts(controller, requests);
fail("Expect failure deleting hosts when components exist and have not been deleted.");
@@ -9020,7 +9020,7 @@ public class AmbariManagementControllerTest {
// Deletion without specifying cluster should be successful
requests.clear();
- requests.add(new HostRequest(host1, null, null));
+ requests.add(new HostRequest(host1, null));
try {
HostResourceProviderTest.deleteHosts(controller, requests);
} catch (Exception e) {
@@ -9033,7 +9033,7 @@ public class AmbariManagementControllerTest {
// Case 3: Delete host that is still part of the cluster, and specify the cluster_name in the request
requests.clear();
- requests.add(new HostRequest(host2, cluster1, null));
+ requests.add(new HostRequest(host2, cluster1));
try {
HostResourceProviderTest.deleteHosts(controller, requests);
} catch (Exception e) {
@@ -9046,7 +9046,7 @@ public class AmbariManagementControllerTest {
// Case 4: Attempt to delete a host that has already been deleted
requests.clear();
- requests.add(new HostRequest(host1, null, null));
+ requests.add(new HostRequest(host1, null));
try {
HostResourceProviderTest.deleteHosts(controller, requests);
Assert.fail("Expected a HostNotFoundException trying to remove a host that was already deleted.");
@@ -9064,7 +9064,7 @@ public class AmbariManagementControllerTest {
// Case 5: Attempt to delete a host that was never added to the cluster
requests.clear();
- requests.add(new HostRequest(host3, null, null));
+ requests.add(new HostRequest(host3, null));
try {
HostResourceProviderTest.deleteHosts(controller, requests);
Assert.fail("Expected a HostNotFoundException trying to remove a host that was never added.");
@@ -9307,7 +9307,7 @@ public class AmbariManagementControllerTest {
// add some hosts
Set<HostRequest> hrs = new HashSet<>();
- hrs.add(new HostRequest(HOST1, CLUSTER_NAME, null));
+ hrs.add(new HostRequest(HOST1, CLUSTER_NAME));
HostResourceProviderTest.createHosts(amc, hrs);
Set<ServiceRequest> serviceRequests = new HashSet<>();
@@ -9422,9 +9422,9 @@ public class AmbariManagementControllerTest {
ComponentResourceProviderTest.createComponents(amc, serviceComponentRequests);
Set<HostRequest> hostRequests = new HashSet<>();
- hostRequests.add(new HostRequest(host1, cluster1, null));
- hostRequests.add(new HostRequest(host2, cluster1, null));
- hostRequests.add(new HostRequest(host3, cluster1, null));
+ hostRequests.add(new HostRequest(host1, cluster1));
+ hostRequests.add(new HostRequest(host2, cluster1));
+ hostRequests.add(new HostRequest(host3, cluster1));
HostResourceProviderTest.createHosts(amc, hostRequests);
@@ -9703,7 +9703,7 @@ public class AmbariManagementControllerTest {
ComponentResourceProviderTest.createComponents(amc, serviceComponentRequests);
Set<HostRequest> hostRequests = new HashSet<>();
- hostRequests.add(new HostRequest(HOST1, CLUSTER_NAME, null));
+ hostRequests.add(new HostRequest(HOST1, CLUSTER_NAME));
HostResourceProviderTest.createHosts(amc, hostRequests);
@@ -10232,7 +10232,7 @@ public class AmbariManagementControllerTest {
}
// passivate a host
- HostRequest hr = new HostRequest(host1, cluster1, requestProperties);
+ HostRequest hr = new HostRequest(host1, cluster1);
hr.setMaintenanceState(MaintenanceState.ON.name());
HostResourceProviderTest.updateHosts(controller, Collections.singleton(hr)
);
@@ -10274,9 +10274,9 @@ public class AmbariManagementControllerTest {
}
// passivate several hosts
- HostRequest hr1 = new HostRequest(host1, cluster1, requestProperties);
+ HostRequest hr1 = new HostRequest(host1, cluster1);
hr1.setMaintenanceState(MaintenanceState.ON.name());
- HostRequest hr2 = new HostRequest(host2, cluster1, requestProperties);
+ HostRequest hr2 = new HostRequest(host2, cluster1);
hr2.setMaintenanceState(MaintenanceState.ON.name());
Set<HostRequest> set = new HashSet<>();
set.add(hr1);
@@ -10292,9 +10292,9 @@ public class AmbariManagementControllerTest {
host.getMaintenanceState(cluster.getClusterId()));
// reset
- hr1 = new HostRequest(host1, cluster1, requestProperties);
+ hr1 = new HostRequest(host1, cluster1);
hr1.setMaintenanceState(MaintenanceState.OFF.name());
- hr2 = new HostRequest(host2, cluster1, requestProperties);
+ hr2 = new HostRequest(host2, cluster1);
hr2.setMaintenanceState(MaintenanceState.OFF.name());
set = new HashSet<>();
set.add(hr1);
http://git-wip-us.apache.org/repos/asf/ambari/blob/0e13b018/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
index c761323..e828ab1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
@@ -468,7 +468,7 @@ public class AbstractResourceProviderTest {
private final HostRequest hostRequest;
public HostRequestSetMatcher(String hostname, String clusterName, Map<String, String> hostAttributes) {
- hostRequest = new HostRequest(hostname, clusterName, hostAttributes);
+ hostRequest = new HostRequest(hostname, clusterName);
add(hostRequest);
}
@@ -488,8 +488,7 @@ public class AbstractResourceProviderTest {
return request instanceof HostRequest &&
eq(((HostRequest) request).getClusterName(), hostRequest.getClusterName()) &&
- eq(((HostRequest) request).getHostname(), hostRequest.getHostname()) &&
- eq(((HostRequest) request).getHostAttributes(), hostRequest.getHostAttributes());
+ eq(((HostRequest) request).getHostname(), hostRequest.getHostname());
}
@Override