You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2017/08/29 21:20:48 UTC
[5/6] ambari git commit: AMBARI-21824. MultiEverything : Make
services as sub-resource of ServiceGroups and use Servicegroup while doing
Creation, Update and retrieval of HostComponents and ServiceComponents.
http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
index 94b5985..7c4c9ab 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
@@ -23,7 +23,8 @@ package org.apache.ambari.server.controller;
public class ServiceComponentHostRequest {
private String clusterName; // REF
- private String serviceName;
+ private String serviceGroupName;
+ private String serviceDisplayName;
private String componentName;
private String hostname;
private String publicHostname;
@@ -33,32 +34,44 @@ public class ServiceComponentHostRequest {
private String staleConfig; // GET - predicate
private String adminState; // GET - predicate
private String maintenanceState; // UPDATE
-
+
public ServiceComponentHostRequest(String clusterName,
- String serviceName,
+ String serviceGroupName,
+ String serviceDisplayName,
String componentName,
String hostname,
String desiredState) {
super();
this.clusterName = clusterName;
- this.serviceName = serviceName;
+ this.serviceGroupName = serviceGroupName;
+ this.serviceDisplayName = serviceDisplayName;
this.componentName = componentName;
this.hostname = hostname;
this.desiredState = desiredState;
}
/**
+ * @return the service group Name
+ */
+ public String getServiceGroupName() { return serviceGroupName; }
+
+ /**
+ * @param serviceGroupName the service group Name to set
+ */
+ public void setServiceGroupName(String serviceGroupName) { this.serviceGroupName = serviceGroupName; }
+
+ /**
* @return the serviceName
*/
- public String getServiceName() {
- return serviceName;
+ public String getServiceDisplayName() {
+ return serviceDisplayName;
}
/**
- * @param serviceName the serviceName to set
+ * @param serviceDisplayName the serviceName to set
*/
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
+ public void setServiceDisplayName(String serviceDisplayName) {
+ this.serviceDisplayName = serviceDisplayName;
}
/**
@@ -106,64 +119,49 @@ public class ServiceComponentHostRequest {
/**
* @return the state
*/
- public String getState() {
- return state;
- }
+ public String getState() { return state; }
/**
* @param state the State to set
*/
- public void setState(String state) {
- this.state = state;
- }
+ public void setState(String state) { this.state = state; }
/**
* @return the clusterName
*/
- public String getClusterName() {
- return clusterName;
- }
+ public String getClusterName() { return clusterName; }
/**
* @param clusterName the clusterName to set
*/
- public void setClusterName(String clusterName) {
- this.clusterName = clusterName;
- }
+ public void setClusterName(String clusterName) { this.clusterName = clusterName; }
/**
* @param staleConfig whether the config is stale
*/
- public void setStaleConfig(String staleConfig) {
- this.staleConfig = staleConfig;
- }
+ public void setStaleConfig(String staleConfig) { this.staleConfig = staleConfig; }
/**
* @return Stale config indicator
*/
- public String getStaleConfig() {
- return staleConfig;
- }
+ public String getStaleConfig() { return staleConfig; }
/**
* @param adminState the adminState to use as predicate
*/
- public void setAdminState(String adminState) {
- this.adminState = adminState;
- }
+ public void setAdminState(String adminState) { this.adminState = adminState; }
/**
* @return the admin state of the component
*/
- public String getAdminState() {
- return adminState;
- }
+ public String getAdminState() { return adminState; }
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{" + " clusterName=").append(clusterName)
- .append(", serviceName=").append(serviceName)
+ .append(", serviceGroupName=").append(serviceGroupName)
+ .append(", serviceDisplayName=").append(serviceDisplayName)
.append(", componentName=").append(componentName)
.append(", hostname=").append(hostname)
.append(", publicHostname=").append(publicHostname)
@@ -180,22 +178,14 @@ public class ServiceComponentHostRequest {
/**
* @param state the maintenance state
*/
- public void setMaintenanceState(String state) {
- maintenanceState = state;
- }
+ public void setMaintenanceState(String state) { maintenanceState = state; }
/**
* @return the maintenance state
*/
- public String getMaintenanceState() {
- return maintenanceState;
- }
+ public String getMaintenanceState() { return maintenanceState; }
- public String getPublicHostname() {
- return publicHostname;
- }
+ public String getPublicHostname() { return publicHostname; }
- public void setPublicHostname(String publicHostname) {
- this.publicHostname = publicHostname;
- }
+ public void setPublicHostname(String publicHostname) { this.publicHostname = publicHostname; }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
index 7b75e06..ebfbf5c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
@@ -26,8 +26,14 @@ import org.apache.ambari.server.state.UpgradeState;
public class ServiceComponentHostResponse {
+ private Long clusterId; // REF
private String clusterName; // REF
+ private Long serviceGroupId;
+ private String serviceGroupName;
+ private Long serviceId;
private String serviceName;
+ private String serviceDisplayName;
+ private Long hostComponentId;
private String componentName;
private String displayName;
private String publicHostname;
@@ -44,12 +50,19 @@ public class ServiceComponentHostResponse {
private String maintenanceState = null;
private UpgradeState upgradeState = UpgradeState.NONE;
- public ServiceComponentHostResponse(String clusterName, String serviceName, String componentName,
- String displayName, String hostname, String publicHostname, String liveState, String version,
- String desiredState, String desiredStackVersion, String desiredRepositoryVersion,
- HostComponentAdminState adminState) {
+ public ServiceComponentHostResponse(Long clusterId, String clusterName, Long serviceGroupId, String serviceGroupName,
+ Long serviceId, String serviceName, String serviceDisplayName, Long hostComponentId,
+ String componentName, String displayName, String hostname, String publicHostname,
+ String liveState, String version, String desiredState, String desiredStackVersion,
+ String desiredRepositoryVersion, HostComponentAdminState adminState) {
+ this.clusterId = clusterId;
+ this.serviceGroupId = serviceGroupId;
+ this.serviceGroupName = serviceGroupName;
+ this.serviceId = serviceId;
this.clusterName = clusterName;
this.serviceName = serviceName;
+ this.serviceDisplayName = serviceDisplayName;
+ this.hostComponentId = hostComponentId;
this.componentName = componentName;
this.displayName = displayName;
this.hostname = hostname;
@@ -65,6 +78,46 @@ public class ServiceComponentHostResponse {
}
/**
+ * @return the serviceGroupId
+ */
+ public Long getServiceGroupId() { return serviceGroupId; }
+
+ /**
+ * @param serviceGroupId the serviceGroupId to set
+ */
+ public void setServiceGroupId(Long serviceGroupId) { this.serviceGroupId = serviceGroupId; }
+
+ /**
+ * @return the serviceGroupName
+ */
+ public String getServiceGroupName() { return serviceGroupName; }
+
+ /**
+ * @param serviceGroupName the serviceGroupName to set
+ */
+ public void setServiceGroupName(String serviceGroupName) { this.serviceGroupName = serviceGroupName; }
+
+ /**
+ * @return the serviceId
+ */
+ public Long getServiceId() { return serviceId; }
+
+ /**
+ * @param serviceId the serviceId to set
+ */
+ public void setServiceId(Long serviceId) { this.serviceId = serviceId; }
+
+ /**
+ * @return the hostComponentId
+ */
+ public Long getHostComponentId() { return hostComponentId; }
+
+ /**
+ * @param hostComponentId the hostComponentId to set
+ */
+ public void sethostComponentId(Long hostComponentId) { this.hostComponentId = hostComponentId; }
+
+ /**
* @return the serviceName
*/
public String getServiceName() {
@@ -79,6 +132,16 @@ public class ServiceComponentHostResponse {
}
/**
+ * @return the serviceName
+ */
+ public String getServiceDisplayName() { return serviceDisplayName; }
+
+ /**
+ * @param serviceDisplayName the serviceDisplayName to set
+ */
+ public void setServiceDisplayName(String serviceDisplayName) { this.serviceDisplayName = serviceDisplayName; }
+
+ /**
* @return the componentName
*/
public String getComponentName() {
@@ -186,6 +249,16 @@ public class ServiceComponentHostResponse {
}
/**
+ * @return the clusterId
+ */
+ public Long getClusterId() { return clusterId; }
+
+ /**
+ * @param clusterId the clusterId to set
+ */
+ public void setClusterId(Long clusterId) { this.clusterId = clusterId; }
+
+ /**
* @return the clusterName
*/
public String getClusterName() {
@@ -225,18 +298,51 @@ public class ServiceComponentHostResponse {
ServiceComponentHostResponse that =
(ServiceComponentHostResponse) o;
+ if (clusterId != null ?
+ !clusterId.equals(that.clusterId) : that.clusterId != null) {
+ return false;
+ }
+
if (clusterName != null ?
!clusterName.equals(that.clusterName) : that.clusterName != null) {
return false;
}
+
+ if (serviceGroupId != null ?
+ !serviceGroupId.equals(that.serviceGroupId) : that.serviceGroupId != null) {
+ return false;
+ }
+
+ if (serviceGroupName != null ?
+ !serviceGroupName.equals(that.serviceGroupName) : that.serviceGroupName != null) {
+ return false;
+ }
+
+ if (serviceId != null ?
+ !serviceId.equals(that.serviceId) : that.serviceId != null) {
+ return false;
+ }
+
if (serviceName != null ?
!serviceName.equals(that.serviceName) : that.serviceName != null) {
return false;
}
+
+ if (serviceDisplayName != null ?
+ !serviceDisplayName.equals(that.serviceDisplayName) : that.serviceDisplayName != null) {
+ return false;
+ }
+
if (componentName != null ?
!componentName.equals(that.componentName) : that.componentName != null) {
return false;
}
+
+ if (displayName != null ?
+ !displayName.equals(that.displayName) : that.displayName != null) {
+ return false;
+ }
+
if (hostname != null ?
!hostname.equals(that.hostname) : that.hostname != null) {
return false;
@@ -247,9 +353,15 @@ public class ServiceComponentHostResponse {
@Override
public int hashCode() {
- int result = clusterName != null ? clusterName.hashCode() : 0;
+ int result = clusterId != null? clusterId.intValue() : 0;
+ result = clusterName != null ? clusterName.hashCode() : 0;
+ result = 71 * result + (serviceGroupId != null ? serviceGroupId.hashCode() : 0);
+ result = 71 * result + (serviceGroupName != null ? serviceGroupName.hashCode() : 0);
+ result = 71 * result + (serviceId != null ? serviceId.hashCode() : 0);
result = 71 * result + (serviceName != null ? serviceName.hashCode() : 0);
+ result = 71 * result + (serviceDisplayName != null ? serviceDisplayName.hashCode() : 0);
result = 71 * result + (componentName != null ? componentName.hashCode() : 0);
+ result = 71 * result + (displayName != null ? displayName.hashCode() : 0);
result = 71 * result + (hostname != null ? hostname.hashCode() : 0);
return result;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java
index 3a65ff8..1556b70 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java
@@ -22,34 +22,30 @@ package org.apache.ambari.server.controller;
public class ServiceComponentRequest {
private String clusterName; // REF
-
- private String serviceName; // GET/CREATE/UPDATE/DELETE
-
+ private String serviceGroupName;
+ private String serviceDisplayName; // GET/CREATE/UPDATE/DELETE
private String componentName; // GET/CREATE/UPDATE/DELETE
-
private String desiredState; // CREATE/UPDATE
-
private String componentCategory;
-
private String recoveryEnabled; // CREATE/UPDATE
- public ServiceComponentRequest(String clusterName, String serviceName,
+ public ServiceComponentRequest(String clusterName, String serviceGroupName, String serviceDisplayName,
String componentName, String desiredState) {
- this(clusterName, serviceName, componentName, desiredState, null, null);
+ this(clusterName, serviceGroupName, serviceDisplayName, componentName, desiredState, null, null);
}
- public ServiceComponentRequest(String clusterName, String serviceName,
- String componentName, String desiredState,
- String recoveryEnabled) {
- this(clusterName, serviceName, componentName, desiredState, recoveryEnabled, null);
+ public ServiceComponentRequest(String clusterName, String serviceGroupName, String serviceDisplayName, String componentName,
+ String desiredState, String recoveryEnabled) {
+ this(clusterName, serviceGroupName, serviceDisplayName, componentName, desiredState, recoveryEnabled, null);
}
- public ServiceComponentRequest(String clusterName,
- String serviceName, String componentName,
+ public ServiceComponentRequest(String clusterName, String serviceGroupName,
+ String serviceDisplayName, String componentName,
String desiredState, String recoveryEnabled,
String componentCategory) {
this.clusterName = clusterName;
- this.serviceName = serviceName;
+ this.serviceGroupName = serviceGroupName;
+ this.serviceDisplayName = serviceDisplayName;
this.componentName = componentName;
this.desiredState = desiredState;
this.recoveryEnabled = recoveryEnabled;
@@ -57,25 +53,34 @@ public class ServiceComponentRequest {
}
/**
+ * @return the service group Name
+ */
+ public String getServiceGroupName() { return serviceGroupName; }
+
+ /**
+ * @param serviceGroupName the service group Name to set
+ */
+ public void setServiceGroupName(String serviceGroupName) { this.serviceGroupName = serviceGroupName; }
+
+ /**
* @return the serviceName
*/
- public String getServiceName() {
- return serviceName;
+ public String getServiceDisplayName() {
+ return serviceDisplayName;
}
/**
- * @param serviceName the serviceName to set
+ * @param serviceDisplayName the serviceDisplayName to set
*/
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
+ public void setServiceDisplayName(String serviceDisplayName) {
+ this.serviceDisplayName = serviceDisplayName;
}
+
/**
* @return the componentName
*/
- public String getComponentName() {
- return componentName;
- }
+ public String getComponentName() { return componentName; }
/**
* @param componentName the componentName to set
@@ -136,7 +141,8 @@ public class ServiceComponentRequest {
@Override
public String toString() {
- return String.format("[clusterName=%s, serviceName=%s, componentName=%s, desiredState=%s, recoveryEnabled=%s, componentCategory=%s]",
- clusterName, serviceName, clusterName, desiredState, recoveryEnabled, componentCategory);
+ return String.format("[clusterName=%s, serviceGroupName=%s, serviceDisplayName=%s, componentName=%s, " +
+ "desiredState=%s, recoveryEnabled=%s, componentCategory=%s]", clusterName, serviceGroupName,
+ serviceDisplayName, clusterName, desiredState, recoveryEnabled, componentCategory);
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
index 9bd3e44..b96fb8a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
@@ -28,7 +28,11 @@ public class ServiceComponentResponse {
private Long clusterId; // REF
private String clusterName; // REF
+ private Long serviceGroupId; // REF
+ private String serviceGroupName; // REF
+ private Long serviceId; // REF
private String serviceName;
+ private String serviceDisplayName;
private String componentName;
private String displayName;
private String desiredStackId;
@@ -39,14 +43,18 @@ public class ServiceComponentResponse {
private String desiredVersion;
private RepositoryVersionState repoState;
- public ServiceComponentResponse(Long clusterId, String clusterName, String serviceName,
- String componentName, StackId desiredStackId, String desiredState,
- Map<String, Integer> serviceComponentStateCount, boolean recoveryEnabled, String displayName,
- String desiredVersion, RepositoryVersionState repoState) {
-
+ public ServiceComponentResponse(Long clusterId, String clusterName, Long serviceGroupId, String serviceGroupName,
+ Long serviceId, String serviceName, String serviceDisplayName, String componentName,
+ StackId desiredStackId, String desiredState, Map<String, Integer> serviceComponentStateCount,
+ boolean recoveryEnabled, String displayName, String desiredVersion,
+ RepositoryVersionState repoState) {
this.clusterId = clusterId;
this.clusterName = clusterName;
+ this.serviceGroupId = serviceGroupId;
+ this.serviceGroupName = serviceGroupName;
+ this.serviceId = serviceId;
this.serviceName = serviceName;
+ this.serviceDisplayName = serviceDisplayName;
this.componentName = componentName;
this.displayName = displayName;
this.desiredStackId = desiredStackId.getStackId();
@@ -72,6 +80,46 @@ public class ServiceComponentResponse {
}
/**
+ * @return the serviceName
+ */
+ public String getServiceDisplayName() { return serviceDisplayName; }
+
+ /**
+ * @param serviceDisplayName the serviceDisplayName to set
+ */
+ public void setServiceDisplayName(String serviceDisplayName) { this.serviceDisplayName = serviceDisplayName; }
+
+ /**
+ * @return the serviceId
+ */
+ public Long getServiceId() { return serviceId; }
+
+ /**
+ * @param serviceId the serviceId to set
+ */
+ public void setServiceId(Long serviceId) { this.serviceId = serviceId; }
+
+ /**
+ * @return the serviceGroupId
+ */
+ public Long getServiceGroupId() { return serviceGroupId; }
+
+ /**
+ * @param serviceGroupId the serviceGroupId to set
+ */
+ public void setServiceGroupId(Long serviceGroupId) { this.serviceGroupId = serviceGroupId; }
+
+ /**
+ * @return the serviceGroupName
+ */
+ public String getServiceGroupName() { return serviceGroupName; }
+
+ /**
+ * @param serviceGroupName the serviceGroupName to set
+ */
+ public void setServiceGroupName(String serviceGroupName) { this.serviceGroupName = serviceGroupName; }
+
+ /**
* @return the componentName
*/
public String getComponentName() {
@@ -212,19 +260,49 @@ public class ServiceComponentResponse {
ServiceComponentResponse that =
(ServiceComponentResponse) o;
+ if (clusterId != null ?
+ !clusterId.equals(that.clusterId) : that.clusterId != null) {
+ return false;
+ }
+
if (clusterName != null ?
!clusterName.equals(that.clusterName) : that.clusterName != null) {
return false;
}
+
+ if (serviceGroupId != null ?
+ !serviceGroupId.equals(that.serviceGroupId) : that.serviceGroupId != null) {
+ return false;
+ }
+ if (serviceGroupName != null ?
+ !serviceGroupName.equals(that.serviceGroupName) : that.serviceGroupName != null) {
+ return false;
+ }
+ if (serviceId != null ?
+ !serviceId.equals(that.serviceId) : that.serviceId != null) {
+ return false;
+ }
+
if (serviceName != null ?
!serviceName.equals(that.serviceName) : that.serviceName != null) {
return false;
}
+
+ if (serviceDisplayName != null ?
+ !serviceDisplayName.equals(that.serviceDisplayName) : that.serviceDisplayName != null) {
+ return false;
+ }
+
if (componentName != null ?
!componentName.equals(that.componentName) : that.componentName != null){
return false;
}
+ if (displayName != null ?
+ !displayName.equals(that.displayName) : that.displayName != null) {
+ return false;
+ }
+
return true;
}
@@ -232,8 +310,13 @@ public class ServiceComponentResponse {
public int hashCode() {
int result = clusterId != null? clusterId.intValue() : 0;
result = 71 * result + (clusterName != null ? clusterName.hashCode() : 0);
+ result = 71 * result + (serviceGroupId != null ? serviceGroupId.hashCode() : 0);
+ result = 71 * result + (serviceGroupName != null ? serviceGroupName.hashCode() : 0);
+ result = 71 * result + (serviceId != null ? serviceId.hashCode() : 0);
result = 71 * result + (serviceName != null ? serviceName.hashCode() : 0);
+ result = 71 * result + (serviceDisplayName != null ? serviceDisplayName.hashCode() : 0);
result = 71 * result + (componentName != null ? componentName.hashCode():0);
+ result = 71 * result + (displayName != null ? displayName.hashCode():0);
return result;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
index 3b3c940..b084582 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
@@ -24,7 +24,9 @@ import io.swagger.annotations.ApiModelProperty;
public class ServiceRequest {
private String clusterName; // REF
- private String serviceName; // GET/CREATE/UPDATE/DELETE
+ private String serviceName; // GET/CREATE/DELETE
+ private String serviceDisplayName; // GET/CREATE/UPDATE/DELETE
+ private String serviceGroupName;
private String desiredState; // CREATE/UPDATE
private String maintenanceState; // UPDATE
private String credentialStoreEnabled; // CREATE/UPDATE/GET
@@ -36,19 +38,27 @@ public class ServiceRequest {
*/
private RepositoryVersionEntity resolvedRepository;
- public ServiceRequest(String clusterName, String serviceName,
+ public ServiceRequest(String clusterName, String serviceGroupName, String serviceName,
Long desiredRepositoryVersionId, String desiredState) {
- this(clusterName, serviceName, desiredRepositoryVersionId, desiredState, null);
+ this(clusterName, serviceGroupName, serviceName, serviceName, desiredRepositoryVersionId, desiredState, null);
}
- public ServiceRequest(String clusterName, String serviceName,
- Long desiredRepositoryVersionId, String desiredState, String credentialStoreEnabled) {
+ public ServiceRequest(String clusterName,
+ String serviceGroupName,
+ String serviceName,
+ String serviceDisplayName,
+ Long desiredRepositoryVersionId,
+ String desiredState,
+ String credentialStoreEnabled) {
this.clusterName = clusterName;
+ this.serviceGroupName = serviceGroupName;
this.serviceName = serviceName;
this.desiredState = desiredState;
this.desiredRepositoryVersionId = desiredRepositoryVersionId;
+ this.serviceDisplayName = serviceDisplayName;
+ this.desiredState = desiredState;
this.credentialStoreEnabled = credentialStoreEnabled;
// Credential store supported cannot be changed after
// creation since it comes from the stack definition.
@@ -56,119 +66,112 @@ public class ServiceRequest {
}
/**
- * @return the serviceName
+ * @return the service name
*/
@ApiModelProperty(name = "service_name")
- public String getServiceName() {
- return serviceName;
- }
+ public String getServiceName() { return serviceName; }
/**
- * @param serviceName the serviceName to set
+ * @param serviceName the Service Display Name to set
*/
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
+ public void setServiceName(String serviceName) { this.serviceName = serviceName; }
+
+ /**
+ * @return the service display name
+ */
+ @ApiModelProperty(name = "service_display_name")
+ public String getServiceDisplayName() { return serviceDisplayName; }
+
+ /**
+ * @param serviceDisplayName the Service Display Name to set
+ */
+ public void setServiceDisplayName(String serviceDisplayName) { this.serviceDisplayName = serviceDisplayName; }
+
+ /**
+ * @return the service group Name
+ */
+ public String getServiceGroupName() { return serviceGroupName; }
+
+ /**
+ * @param serviceGroupName the service group Name to set
+ */
+ public void setServiceGroupName(String serviceGroupName) { this.serviceGroupName = serviceGroupName; }
/**
* @return the desiredState
*/
@ApiModelProperty(name = "state")
- public String getDesiredState() {
- return desiredState;
- }
+ public String getDesiredState() { return desiredState; }
/**
* @param desiredState the desiredState to set
*/
- public void setDesiredState(String desiredState) {
- this.desiredState = desiredState;
- }
+ public void setDesiredState(String desiredState) { this.desiredState = desiredState; }
- public Long getDesiredRepositoryVersionId() {
- return desiredRepositoryVersionId;
- }
+ public Long getDesiredRepositoryVersionId() { return desiredRepositoryVersionId; }
/**
* @return the clusterName
*/
@ApiModelProperty(name = "cluster_name")
- public String getClusterName() {
- return clusterName;
- }
+ public String getClusterName() { return clusterName; }
/**
* @param clusterName the clusterName to set
*/
- public void setClusterName(String clusterName) {
- this.clusterName = clusterName;
- }
+ public void setClusterName(String clusterName) { this.clusterName = clusterName; }
/**
* @param state the new maintenance state
*/
- public void setMaintenanceState(String state) {
- maintenanceState = state;
- }
+ public void setMaintenanceState(String state) { maintenanceState = state; }
/**
* @return the maintenance state
*/
@ApiModelProperty(name = "maintenance_state")
- public String getMaintenanceState() {
- return maintenanceState;
- }
+ public String getMaintenanceState() { return maintenanceState; }
/**
* @return credential store enabled
*/
@ApiModelProperty(name = "credential_store_enabled")
- public String getCredentialStoreEnabled() {
- return credentialStoreEnabled;
- }
+ public String getCredentialStoreEnabled() { return credentialStoreEnabled; }
/**
* @return credential store supported
*/
- public String getCredentialStoreSupported() {
- return credentialStoreSupported;
- }
+ public String getCredentialStoreSupported() { return credentialStoreSupported; }
/**
* @param credentialStoreEnabled the new credential store enabled
*/
- public void setCredentialStoreEnabled(String credentialStoreEnabled) {
- this.credentialStoreEnabled = credentialStoreEnabled;
- }
+ public void setCredentialStoreEnabled(String credentialStoreEnabled) { this.credentialStoreEnabled = credentialStoreEnabled; }
/**
* @param credentialStoreSupported the new credential store supported
*/
@ApiModelProperty(name = "credential_store_supporteds")
- public void setCredentialStoreSupported(String credentialStoreSupported) {
- this.credentialStoreSupported = credentialStoreSupported;
- }
+ public void setCredentialStoreSupported(String credentialStoreSupported) { this.credentialStoreSupported = credentialStoreSupported; }
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("clusterName=").append(clusterName)
- .append(", serviceName=").append(serviceName)
- .append(", desiredState=").append(desiredState)
- .append(", credentialStoreEnabled=").append(credentialStoreEnabled)
- .append(", credentialStoreSupported=").append(credentialStoreSupported);
+ sb.append("clusterName=" + clusterName
+ + ", serviceGroupName=" + serviceGroupName
+ + ", serviceDisplayName=" + serviceDisplayName
+ + ", desiredState=" + desiredState
+ + ", maintenanceState=" + maintenanceState
+ + ", credentialStoreEnabled=" + credentialStoreEnabled
+ + ", credentialStoreSupported=" + credentialStoreSupported);
return sb.toString();
}
/**
* @param repositoryVersion
*/
- public void setResolvedRepository(RepositoryVersionEntity repositoryVersion) {
- resolvedRepository = repositoryVersion;
- }
+ public void setResolvedRepository(RepositoryVersionEntity repositoryVersion) { resolvedRepository = repositoryVersion; }
- public RepositoryVersionEntity getResolvedRepository() {
- return resolvedRepository;
- }
+ public RepositoryVersionEntity getResolvedRepository() { return resolvedRepository; }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
index ed1832a..f528b4e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
@@ -27,7 +27,11 @@ public class ServiceResponse {
private Long clusterId;
private String clusterName;
+ private Long serviceGroupId;
+ private String serviceGroupName;
+ private Long serviceId;
private String serviceName;
+ private String serviceDisplayName;
private StackId desiredStackId;
private String desiredRepositoryVersion;
private Long desiredRepositoryVersionId;
@@ -37,13 +41,17 @@ public class ServiceResponse {
private boolean credentialStoreSupported;
private boolean credentialStoreEnabled;
- public ServiceResponse(Long clusterId, String clusterName, String serviceName,
- StackId desiredStackId, String desiredRepositoryVersion,
- RepositoryVersionState repositoryVersionState, String desiredState,
- boolean credentialStoreSupported, boolean credentialStoreEnabled) {
+ public ServiceResponse(Long clusterId, String clusterName, Long serviceGroupId, String serviceGroupName,
+ Long serviceId, String serviceName, String serviceDisplayName, StackId desiredStackId,
+ String desiredRepositoryVersion, RepositoryVersionState repositoryVersionState, String desiredState,
+ boolean credentialStoreSupported, boolean credentialStoreEnabled) {
this.clusterId = clusterId;
this.clusterName = clusterName;
+ this.serviceGroupId = serviceGroupId;
+ this.serviceGroupName = serviceGroupName;
+ this.serviceId = serviceId;
this.serviceName = serviceName;
+ this.serviceDisplayName = serviceDisplayName;
this.desiredStackId = desiredStackId;
this.repositoryVersionState = repositoryVersionState;
setDesiredState(desiredState);
@@ -52,8 +60,6 @@ public class ServiceResponse {
this.credentialStoreEnabled = credentialStoreEnabled;
}
-
-
/**
* @return the serviceName
*/
@@ -99,6 +105,47 @@ public class ServiceResponse {
this.clusterName = clusterName;
}
+
+ /**
+ * @return the serviceGroupId
+ */
+ public Long getServiceGroupId() { return serviceGroupId; }
+
+ /**
+ * @param serviceGroupId the serviceGroupId to set
+ */
+ public void setServiceGroupId(Long serviceGroupId) { this.serviceGroupId = serviceGroupId; }
+
+ /**
+ * @return the service group name
+ */
+ public String getServiceGroupName() { return serviceGroupName; }
+
+ /**
+ * @param serviceGroupName the service group name
+ */
+ public void setServiceGroupName(String serviceGroupName) { this.serviceGroupName = serviceGroupName; }
+
+ /**
+ * @return the serviceId
+ */
+ public Long getServiceId() { return serviceId; }
+
+ /**
+ * @param serviceId the serviceId to set
+ */
+ public void setServiceId(Long serviceId) { this.serviceId = serviceId; }
+
+ /**
+ * @return the real serviceName
+ */
+ public String getServiceDisplayName() { return serviceDisplayName; }
+
+ /**
+ * @param serviceDisplayName the real serviceName to set
+ */
+ public void setserviceDisplayName(String serviceDisplayName) { this.serviceDisplayName = serviceDisplayName; }
+
/**
* @return the desiredState
*/
@@ -144,25 +191,37 @@ public class ServiceResponse {
@Override
public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
ServiceResponse that = (ServiceResponse) o;
if (clusterId != null ?
- !clusterId.equals(that.clusterId) : that.clusterId != null) {
+ !clusterId.equals(that.clusterId) : that.clusterId != null) {
return false;
}
if (clusterName != null ?
- !clusterName.equals(that.clusterName) : that.clusterName != null) {
+ !clusterName.equals(that.clusterName) : that.clusterName != null) {
+ return false;
+ }
+ if (serviceGroupId != null ?
+ !serviceGroupId.equals(that.serviceGroupId) : that.serviceGroupId != null) {
+ return false;
+ }
+ if (serviceGroupName != null ?
+ !serviceGroupName.equals(that.serviceGroupName) : that.serviceGroupName != null) {
+ return false;
+ }
+ if (serviceId != null ?
+ !serviceId.equals(that.serviceId) : that.serviceId != null) {
return false;
}
if (serviceName != null ?
- !serviceName.equals(that.serviceName) : that.serviceName != null) {
+ !serviceName.equals(that.serviceName) : that.serviceName != null) {
+ return false;
+ }
+ if (serviceDisplayName != null ?
+ !serviceDisplayName.equals(that.serviceDisplayName) : that.serviceDisplayName != null) {
return false;
}
@@ -224,7 +283,11 @@ public class ServiceResponse {
public int hashCode() {
int result = clusterId != null? clusterId.intValue() : 0;
result = 71 * result + (clusterName != null ? clusterName.hashCode() : 0);
+ result = 71 * result + (serviceGroupId != null ? serviceGroupId.hashCode() : 0);
+ result = 71 * result + (serviceGroupName != null ? serviceGroupName.hashCode() : 0);
+ result = 71 * result + (serviceId != null ? serviceId.hashCode() : 0);
result = 71 * result + (serviceName != null ? serviceName.hashCode() : 0);
+ result = 71 * result + (serviceDisplayName != null ? serviceDisplayName.hashCode() : 0);
return result;
}
@@ -244,7 +307,6 @@ public class ServiceResponse {
}
/**
- * @param id
*/
public Long getDesiredRepositoryVersionId() {
return desiredRepositoryVersionId;
http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
index 0242d7c..e154133 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
@@ -470,7 +470,7 @@ public abstract class AbstractProviderModule implements ProviderModule,
Set<String> hosts = null;
try {
Cluster cluster = managementController.getClusters().getCluster(clusterName);
- String serviceName = managementController.findServiceName(cluster, componentName);
+ String serviceName = managementController.findService(cluster, componentName);
hosts = cluster.getService(serviceName).getServiceComponent(componentName).getServiceComponentHosts().keySet();
} catch (Exception e) {
LOG.warn("Exception in getting host names for jmx metrics: ", e);
http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
index 166fc5f..2a8b8fe 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
@@ -116,6 +116,7 @@ public class ClientConfigResourceProvider extends AbstractControllerResourceProv
// ----- Property ID constants ---------------------------------------------
protected static final String COMPONENT_CLUSTER_NAME_PROPERTY_ID = "ServiceComponentInfo/cluster_name";
+ protected static final String COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID = "ServiceComponentInfo/service_group_name";
protected static final String COMPONENT_SERVICE_NAME_PROPERTY_ID = "ServiceComponentInfo/service_name";
protected static final String COMPONENT_COMPONENT_NAME_PROPERTY_ID = "ServiceComponentInfo/component_name";
protected static final String HOST_COMPONENT_HOST_NAME_PROPERTY_ID =
@@ -126,6 +127,7 @@ public class ClientConfigResourceProvider extends AbstractControllerResourceProv
private static Set<String> pkPropertyIds =
new HashSet<>(Arrays.asList(new String[]{
COMPONENT_CLUSTER_NAME_PROPERTY_ID,
+ COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID,
COMPONENT_SERVICE_NAME_PROPERTY_ID,
COMPONENT_COMPONENT_NAME_PROPERTY_ID}));
@@ -198,7 +200,7 @@ public class ClientConfigResourceProvider extends AbstractControllerResourceProv
ServiceComponentHostRequest schRequest = requests.iterator().next();
String requestComponentName = schRequest.getComponentName();
- String requestServiceName = schRequest.getServiceName();
+ String requestServiceName = schRequest.getServiceDisplayName();
String requestHostName = schRequest.getHostname();
Map<String,List<ServiceComponentHostResponse>> serviceToComponentMap = new HashMap<>();
@@ -904,6 +906,7 @@ public class ClientConfigResourceProvider extends AbstractControllerResourceProv
private ServiceComponentHostRequest getRequest(Map<String, Object> properties) {
return new ServiceComponentHostRequest(
(String) properties.get(COMPONENT_CLUSTER_NAME_PROPERTY_ID),
+ (String) properties.get(COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID),
(String) properties.get(COMPONENT_SERVICE_NAME_PROPERTY_ID),
(String) properties.get(COMPONENT_COMPONENT_NAME_PROPERTY_ID),
(String) properties.get(HOST_COMPONENT_HOST_NAME_PROPERTY_ID),
http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
index 2df3b00..4e2570f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
@@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -31,6 +32,7 @@ import org.apache.ambari.server.ClusterNotFoundException;
import org.apache.ambari.server.DuplicateResourceException;
import org.apache.ambari.server.ObjectNotFoundException;
import org.apache.ambari.server.ParentObjectNotFoundException;
+import org.apache.ambari.server.ServiceGroupNotFoundException;
import org.apache.ambari.server.ServiceNotFoundException;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.controller.AmbariManagementController;
@@ -47,6 +49,7 @@ import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
import org.apache.ambari.server.controller.spi.SystemException;
import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
import org.apache.ambari.server.security.authorization.AuthorizationException;
import org.apache.ambari.server.security.authorization.AuthorizationHelper;
import org.apache.ambari.server.security.authorization.ResourceType;
@@ -58,6 +61,7 @@ import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentFactory;
import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.ServiceGroup;
import org.apache.ambari.server.state.StackId;
import org.apache.ambari.server.state.State;
import org.apache.commons.lang.StringUtils;
@@ -72,26 +76,32 @@ import com.google.inject.persist.Transactional;
* Resource provider for component resources.
*/
public class ComponentResourceProvider extends AbstractControllerResourceProvider {
-
+ public static final String RESPONSE_KEY = "ServiceComponentInfo";
+ public static final String ALL_PROPERTIES = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "*";
// ----- Property ID constants ---------------------------------------------
// Components
- protected static final String COMPONENT_CLUSTER_NAME_PROPERTY_ID = "ServiceComponentInfo/cluster_name";
- protected static final String COMPONENT_SERVICE_NAME_PROPERTY_ID = "ServiceComponentInfo/service_name";
- protected static final String COMPONENT_COMPONENT_NAME_PROPERTY_ID = "ServiceComponentInfo/component_name";
- protected static final String COMPONENT_DISPLAY_NAME_PROPERTY_ID = "ServiceComponentInfo/display_name";
- protected static final String COMPONENT_STATE_PROPERTY_ID = "ServiceComponentInfo/state";
- protected static final String COMPONENT_CATEGORY_PROPERTY_ID = "ServiceComponentInfo/category";
- protected static final String COMPONENT_TOTAL_COUNT_PROPERTY_ID = "ServiceComponentInfo/total_count";
- protected static final String COMPONENT_STARTED_COUNT_PROPERTY_ID = "ServiceComponentInfo/started_count";
- protected static final String COMPONENT_INSTALLED_COUNT_PROPERTY_ID = "ServiceComponentInfo/installed_count";
- protected static final String COMPONENT_INIT_COUNT_PROPERTY_ID = "ServiceComponentInfo/init_count";
- protected static final String COMPONENT_UNKNOWN_COUNT_PROPERTY_ID = "ServiceComponentInfo/unknown_count";
- protected static final String COMPONENT_INSTALL_FAILED_COUNT_PROPERTY_ID = "ServiceComponentInfo/install_failed_count";
- protected static final String COMPONENT_RECOVERY_ENABLED_ID = "ServiceComponentInfo/recovery_enabled";
- protected static final String COMPONENT_DESIRED_STACK = "ServiceComponentInfo/desired_stack";
- protected static final String COMPONENT_DESIRED_VERSION = "ServiceComponentInfo/desired_version";
- protected static final String COMPONENT_REPOSITORY_STATE = "ServiceComponentInfo/repository_state";
+ protected static final String COMPONENT_CLUSTER_ID_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "cluster_id";
+ protected static final String COMPONENT_CLUSTER_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "cluster_name";
+ protected static final String COMPONENT_SERVICE_GROUP_ID_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_group_id";
+ protected static final String COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_group_name";
+ protected static final String COMPONENT_SERVICE_ID_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_id";
+ protected static final String COMPONENT_SERVICE_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_name";
+ protected static final String COMPONENT_SERVICE_DISPLAY_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_display_name";
+ protected static final String COMPONENT_COMPONENT_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "component_name";
+ protected static final String COMPONENT_DISPLAY_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "display_name";
+ protected static final String COMPONENT_STATE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "state";
+ protected static final String COMPONENT_CATEGORY_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "category";
+ protected static final String COMPONENT_TOTAL_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "total_count";
+ protected static final String COMPONENT_STARTED_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "started_count";
+ protected static final String COMPONENT_INSTALLED_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "installed_count";
+ protected static final String COMPONENT_INIT_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "init_count";
+ protected static final String COMPONENT_UNKNOWN_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "unknown_count";
+ protected static final String COMPONENT_INSTALL_FAILED_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "install_failed_count";
+ protected static final String COMPONENT_RECOVERY_ENABLED_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "recovery_enabled";
+ protected static final String COMPONENT_DESIRED_STACK = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "desired_stack";
+ protected static final String COMPONENT_DESIRED_VERSION = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "desired_version";
+ protected static final String COMPONENT_REPOSITORY_STATE = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "repository_state";
private static final String TRUE = "true";
@@ -100,7 +110,8 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
private static Set<String> pkPropertyIds = Sets.newHashSet(
COMPONENT_CLUSTER_NAME_PROPERTY_ID,
- COMPONENT_SERVICE_NAME_PROPERTY_ID,
+ COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID,
+ COMPONENT_SERVICE_DISPLAY_NAME_PROPERTY_ID,
COMPONENT_COMPONENT_NAME_PROPERTY_ID);
/**
@@ -115,8 +126,13 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
static {
// properties
+ PROPERTY_IDS.add(COMPONENT_CLUSTER_ID_PROPERTY_ID);
PROPERTY_IDS.add(COMPONENT_CLUSTER_NAME_PROPERTY_ID);
+ PROPERTY_IDS.add(COMPONENT_SERVICE_GROUP_ID_PROPERTY_ID);
+ PROPERTY_IDS.add(COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID);
+ PROPERTY_IDS.add(COMPONENT_SERVICE_ID_PROPERTY_ID);
PROPERTY_IDS.add(COMPONENT_SERVICE_NAME_PROPERTY_ID);
+ PROPERTY_IDS.add(COMPONENT_SERVICE_DISPLAY_NAME_PROPERTY_ID);
PROPERTY_IDS.add(COMPONENT_COMPONENT_NAME_PROPERTY_ID);
PROPERTY_IDS.add(COMPONENT_DISPLAY_NAME_PROPERTY_ID);
PROPERTY_IDS.add(COMPONENT_STATE_PROPERTY_ID);
@@ -137,7 +153,8 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
// keys
KEY_PROPERTY_IDS.put(Resource.Type.Component, COMPONENT_COMPONENT_NAME_PROPERTY_ID);
- KEY_PROPERTY_IDS.put(Resource.Type.Service, COMPONENT_SERVICE_NAME_PROPERTY_ID);
+ KEY_PROPERTY_IDS.put(Resource.Type.ServiceGroup, COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID);
+ KEY_PROPERTY_IDS.put(Resource.Type.Service, COMPONENT_SERVICE_DISPLAY_NAME_PROPERTY_ID);
KEY_PROPERTY_IDS.put(Resource.Type.Cluster, COMPONENT_CLUSTER_NAME_PROPERTY_ID);
}
@@ -175,16 +192,42 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
requests.add(getRequest(propertyMap));
}
- createResources(new Command<Void>() {
+ Set<ServiceComponentResponse> createSvcCmpnt = null;
+ createSvcCmpnt = createResources(new Command<Set<ServiceComponentResponse>>() {
@Override
- public Void invoke() throws AmbariException, AuthorizationException {
- createComponents(requests);
- return null;
+ public Set<ServiceComponentResponse> invoke() throws AmbariException, AuthorizationException {
+ return createComponents(requests);
}
});
- notifyCreate(Resource.Type.Component, request);
-
+ Set<Resource> associatedResources = new HashSet<>();
+ if (createSvcCmpnt != null) {
+ Iterator<ServiceComponentResponse> itr = createSvcCmpnt.iterator();
+ while (itr.hasNext()) {
+ ServiceComponentResponse response = itr.next();
+ notifyCreate(Resource.Type.Component, request);
+ Resource resource = new ResourceImpl(Resource.Type.Component);
+ resource.setProperty(COMPONENT_CLUSTER_ID_PROPERTY_ID, response.getClusterId());
+ resource.setProperty(COMPONENT_CLUSTER_NAME_PROPERTY_ID, response.getClusterName());
+ resource.setProperty(COMPONENT_SERVICE_GROUP_ID_PROPERTY_ID, response.getServiceGroupId());
+ resource.setProperty(COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID, response.getServiceGroupName());
+ resource.setProperty(COMPONENT_SERVICE_ID_PROPERTY_ID, response.getServiceId());
+ resource.setProperty(COMPONENT_SERVICE_NAME_PROPERTY_ID, response.getServiceName());
+ resource.setProperty(COMPONENT_SERVICE_DISPLAY_NAME_PROPERTY_ID, response.getServiceDisplayName());
+ resource.setProperty(COMPONENT_COMPONENT_NAME_PROPERTY_ID, response.getComponentName());
+ resource.setProperty(COMPONENT_DISPLAY_NAME_PROPERTY_ID, response.getDisplayName());
+ resource.setProperty(COMPONENT_STATE_PROPERTY_ID, response.getDesiredState());
+ resource.setProperty(COMPONENT_CATEGORY_PROPERTY_ID, response.getCategory());
+ resource.setProperty(COMPONENT_TOTAL_COUNT_PROPERTY_ID, response.getServiceComponentStateCount());
+ resource.setProperty(COMPONENT_RECOVERY_ENABLED_ID, response.isRecoveryEnabled());
+ resource.setProperty(COMPONENT_DESIRED_STACK, response.getDesiredStackId());
+ resource.setProperty(COMPONENT_DESIRED_VERSION, response.getDesiredVersion());
+ resource.setProperty(COMPONENT_DESIRED_VERSION, response.getRepositoryState());
+
+ associatedResources.add(resource);
+ }
+ return getRequestStatus(null, associatedResources);
+ }
return getRequestStatus(null);
}
@@ -211,8 +254,13 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
for (ServiceComponentResponse response : responses) {
Resource resource = new ResourceImpl(Resource.Type.Component);
+ setResourceProperty(resource, COMPONENT_CLUSTER_ID_PROPERTY_ID, response.getClusterId(), requestedIds);
setResourceProperty(resource, COMPONENT_CLUSTER_NAME_PROPERTY_ID, response.getClusterName(), requestedIds);
+ setResourceProperty(resource, COMPONENT_SERVICE_GROUP_ID_PROPERTY_ID, response.getServiceGroupId(), requestedIds);
+ setResourceProperty(resource, COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID, response.getServiceGroupName(), requestedIds);
+ setResourceProperty(resource, COMPONENT_SERVICE_ID_PROPERTY_ID, response.getServiceId(), requestedIds);
setResourceProperty(resource, COMPONENT_SERVICE_NAME_PROPERTY_ID, response.getServiceName(), requestedIds);
+ setResourceProperty(resource, COMPONENT_SERVICE_DISPLAY_NAME_PROPERTY_ID, response.getServiceDisplayName(), requestedIds);
setResourceProperty(resource, COMPONENT_COMPONENT_NAME_PROPERTY_ID, response.getComponentName(), requestedIds);
setResourceProperty(resource, COMPONENT_DISPLAY_NAME_PROPERTY_ID, response.getDisplayName(), requestedIds);
setResourceProperty(resource, COMPONENT_STATE_PROPERTY_ID, response.getDesiredState(), requestedIds);
@@ -262,18 +310,23 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
final Set<ServiceComponentRequest> requests = new HashSet<>();
+ DeleteStatusMetaData deleteStatusMetaData = null;
for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
requests.add(getRequest(propertyMap));
}
- RequestStatusResponse response = modifyResources(new Command<RequestStatusResponse>() {
+ deleteStatusMetaData = modifyResources(new Command<DeleteStatusMetaData>() {
@Override
- public RequestStatusResponse invoke() throws AmbariException, AuthorizationException {
- return deleteComponents(requests);
+ public DeleteStatusMetaData invoke() throws AmbariException, AuthorizationException {
+ deleteComponents(requests);
+ return new DeleteStatusMetaData();
}
});
notifyDelete(Resource.Type.Component, predicate);
- return getRequestStatus(response);
+ for(ServiceComponentRequest svcCmpntReq : requests) {
+ deleteStatusMetaData.addDeletedKey("component_name: "+svcCmpntReq.getComponentName());
+ }
+ return getRequestStatus(null, null, deleteStatusMetaData);
}
@@ -297,7 +350,8 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
private ServiceComponentRequest getRequest(Map<String, Object> properties) {
return new ServiceComponentRequest(
(String) properties.get(COMPONENT_CLUSTER_NAME_PROPERTY_ID),
- (String) properties.get(COMPONENT_SERVICE_NAME_PROPERTY_ID),
+ (String) properties.get(COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID),
+ (String) properties.get(COMPONENT_SERVICE_DISPLAY_NAME_PROPERTY_ID),
(String) properties.get(COMPONENT_COMPONENT_NAME_PROPERTY_ID),
(String) properties.get(COMPONENT_STATE_PROPERTY_ID),
(String) properties.get(COMPONENT_RECOVERY_ENABLED_ID),
@@ -305,14 +359,15 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
}
// Create the components for the given requests.
- public void createComponents(Set<ServiceComponentRequest> requests)
+ public Set<ServiceComponentResponse> createComponents(Set<ServiceComponentRequest> requests)
throws AmbariException, AuthorizationException {
if (requests.isEmpty()) {
LOG.warn("Received an empty requests set");
- return;
+ return null;
}
+ Set<ServiceComponentResponse> createdSvcCmpnt = new HashSet<>();
Clusters clusters = getManagementController().getClusters();
AmbariMetaInfo ambariMetaInfo = getManagementController().getAmbariMetaInfo();
ServiceComponentFactory serviceComponentFactory = getManagementController().getServiceComponentFactory();
@@ -323,11 +378,12 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
for (ServiceComponentRequest request : requests) {
Validate.notEmpty(request.getComponentName(), "component name should be non-empty");
+ Validate.notEmpty(request.getServiceGroupName(), "service group name should be non-empty");
+ Validate.notEmpty(request.getServiceDisplayName(), "service display name should be non-empty");
Cluster cluster = getClusterForRequest(request, clusters);
isAuthorized(cluster, getRequiredCreateAuthorizations());
- setServiceNameIfAbsent(request, cluster, ambariMetaInfo);
debug("Received a createComponent request: {}", request);
if (!componentNames.containsKey(request.getClusterName())) {
@@ -335,16 +391,16 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
}
Map<String, Set<String>> serviceComponents = componentNames.get(request.getClusterName());
- if (!serviceComponents.containsKey(request.getServiceName())) {
- serviceComponents.put(request.getServiceName(), new HashSet<String>());
+ if (!serviceComponents.containsKey(request.getServiceDisplayName())) {
+ serviceComponents.put(request.getServiceDisplayName(), new HashSet<String>());
}
- if (serviceComponents.get(request.getServiceName()).contains(request.getComponentName())) {
+ if (serviceComponents.get(request.getServiceDisplayName()).contains(request.getComponentName())) {
// throw error later for dup
duplicates.add(request.toString());
continue;
}
- serviceComponents.get(request.getServiceName()).add(request.getComponentName());
+ serviceComponents.get(request.getServiceDisplayName()).add(request.getComponentName());
if (StringUtils.isNotEmpty(request.getDesiredState())) {
Validate.isTrue(State.INIT == State.valueOf(request.getDesiredState()),
@@ -387,7 +443,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
// now doing actual work
for (ServiceComponentRequest request : requests) {
Cluster cluster = clusters.getCluster(request.getClusterName());
- Service s = cluster.getService(request.getServiceName());
+ Service s = cluster.getService(request.getServiceDisplayName());
ServiceComponent sc = serviceComponentFactory.createNew(s, request.getComponentName());
sc.setDesiredRepositoryVersion(s.getDesiredRepositoryVersion());
@@ -420,7 +476,9 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
}
s.addServiceComponent(sc);
+ createdSvcCmpnt.add(sc.convertToResponse());
}
+ return createdSvcCmpnt;
}
// Get the components for the given requests.
@@ -457,9 +515,15 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
final Service s = getServiceFromCluster(request, cluster);
ServiceComponent sc = s.getServiceComponent(request.getComponentName());
ServiceComponentResponse serviceComponentResponse = sc.convertToResponse();
-
StackId stackId = sc.getDesiredStackId();
+ ServiceGroup sg = null;
+ try {
+ sg = cluster.getServiceGroup(sc.getServiceGroupId());
+ } catch (ServiceGroupNotFoundException e) {
+ sg = null;
+ }
+
try {
ComponentInfo componentInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
stackId.getStackVersion(), s.getName(), request.getComponentName());
@@ -476,7 +540,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
}
Set<Service> services = new HashSet<>();
- if (StringUtils.isNotEmpty(request.getServiceName())) {
+ if (StringUtils.isNotEmpty(request.getServiceDisplayName())) {
services.add(getServiceFromCluster(request, cluster));
} else {
services.addAll(cluster.getServices().values());
@@ -554,12 +618,13 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
Validate.notEmpty(request.getComponentName(), "component name should be non-empty");
final Cluster cluster = getClusterForRequest(request, clusters);
final String clusterName = request.getClusterName();
+ final String serviceGroupName = request.getServiceGroupName();
+ final String serviceName = request.getServiceDisplayName();
final String componentName = request.getComponentName();
LOG.info("Received a updateComponent request: {}", request);
setServiceNameIfAbsent(request, cluster, ambariMetaInfo);
- final String serviceName = request.getServiceName();
debug("Received a updateComponent request: {}", request);
@@ -634,6 +699,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ " servicecomponent"
+ ", clusterName=" + cluster.getClusterName()
+ ", clusterId=" + cluster.getClusterId()
+ + ", serviceGroupName=" + serviceGroupName
+ ", serviceName=" + sc.getServiceName()
+ ", componentName=" + sc.getName()
+ ", recoveryEnabled=" + sc.isRecoveryEnabled()
@@ -646,6 +712,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
}
debug("Handling update to ServiceComponent"
+ ", clusterName=" + clusterName
+ + ", serviceGroupName=" + serviceGroupName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ ", recoveryEnabled=" + sc.isRecoveryEnabled()
@@ -660,6 +727,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
if (oldSchState == State.DISABLED || oldSchState == State.UNKNOWN) {
debug("Ignoring ServiceComponentHost"
+ ", clusterName=" + clusterName
+ + ", serviceGroupName=" + serviceGroupName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ ", recoveryEnabled=" + sc.isRecoveryEnabled()
@@ -673,6 +741,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
ignoredScHosts.add(sch);
debug("Ignoring ServiceComponentHost"
+ ", clusterName=" + clusterName
+ + ", serviceGroupName=" + serviceGroupName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ ", recoveryEnabled=" + sc.isRecoveryEnabled()
@@ -687,6 +756,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
ignoredScHosts.add(sch);
debug("Ignoring ServiceComponentHost in maintenance state"
+ ", clusterName=" + clusterName
+ + ", serviceGroupName=" + serviceGroupName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ ", recoveryEnabled=" + sc.isRecoveryEnabled()
@@ -701,6 +771,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ " servicecomponenthost"
+ ", clusterName=" + cluster.getClusterName()
+ ", clusterId=" + cluster.getClusterId()
+ + ", serviceGroupName=" + serviceGroupName
+ ", serviceName=" + sch.getServiceName()
+ ", componentName=" + sch.getServiceComponentName()
+ ", recoveryEnabled=" + sc.isRecoveryEnabled()
@@ -717,6 +788,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
debug("Handling update to ServiceComponentHost"
+ ", clusterName=" + clusterName
+ + ", serviceGroupName=" + serviceGroupName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ ", recoveryEnabled=" + sc.isRecoveryEnabled()
@@ -799,7 +871,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
private Service getServiceFromCluster(final ServiceComponentRequest request, final Cluster cluster) throws AmbariException {
try {
- return cluster.getService(request.getServiceName());
+ return cluster.getService(request.getServiceDisplayName());
} catch (ServiceNotFoundException e) {
throw new ParentObjectNotFoundException("Parent Service resource doesn't exist.", e);
}
@@ -829,11 +901,11 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
private void setServiceNameIfAbsent(final ServiceComponentRequest request,
final Cluster cluster,
final AmbariMetaInfo ambariMetaInfo) throws AmbariException {
- if (StringUtils.isEmpty(request.getServiceName())) {
+ if (StringUtils.isEmpty(request.getServiceDisplayName())) {
String componentName = request.getComponentName();
- String serviceName = getManagementController().findServiceName(cluster, componentName);
+ String serviceName = getManagementController().findService(cluster, componentName);
debug("Looking up service name for component, componentName={}, serviceName={}", componentName, serviceName);
@@ -842,7 +914,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", componentName=" + request.getComponentName()
+ ", clusterName=" + cluster.getClusterName());
}
- request.setServiceName(serviceName);
+ request.setServiceDisplayName(serviceName);
}
}