You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sm...@apache.org on 2016/02/19 16:59:01 UTC
ambari git commit: AMBARI-15077: Auto-start services - Backend API
and DB changes for component auto start.
Repository: ambari
Updated Branches:
refs/heads/trunk a0c4dcc5d -> fca04c305
AMBARI-15077: Auto-start services - Backend API and DB changes for component auto start.
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fca04c30
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fca04c30
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fca04c30
Branch: refs/heads/trunk
Commit: fca04c305c472db7a11d9b121b3de38a4f176f84
Parents: a0c4dcc
Author: Nahappan Somasundaram <ns...@hortonworks.com>
Authored: Thu Feb 18 14:22:21 2016 -0800
Committer: Nahappan Somasundaram <ns...@hortonworks.com>
Committed: Fri Feb 19 07:55:33 2016 -0800
----------------------------------------------------------------------
.../controller/ServiceComponentRequest.java | 35 +++++++--
.../controller/ServiceComponentResponse.java | 22 +++++-
.../internal/ComponentResourceProvider.java | 38 ++++++++++
.../ServiceComponentDesiredStateEntity.java | 11 +++
.../ambari/server/state/ServiceComponent.java | 14 ++++
.../server/state/ServiceComponentImpl.java | 80 +++++++++++++++++---
.../main/resources/Ambari-DDL-Derby-CREATE.sql | 1 +
.../main/resources/Ambari-DDL-MySQL-CREATE.sql | 1 +
.../main/resources/Ambari-DDL-Oracle-CREATE.sql | 1 +
.../resources/Ambari-DDL-Postgres-CREATE.sql | 1 +
.../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql | 1 +
.../resources/Ambari-DDL-SQLAnywhere-CREATE.sql | 1 +
.../resources/Ambari-DDL-SQLServer-CREATE.sql | 1 +
.../src/main/resources/properties.json | 1 +
.../AmbariManagementControllerTest.java | 3 +
.../internal/ComponentResourceProviderTest.java | 37 +++++----
16 files changed, 218 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/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 78b9897..ba0b84f 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
@@ -31,21 +31,28 @@ public class ServiceComponentRequest {
private String componentCategory;
+ private String recoveryEnabled; // CREATE/UPDATE
+
public ServiceComponentRequest(String clusterName, String serviceName,
String componentName, String desiredState) {
- this.clusterName = clusterName;
- this.serviceName = serviceName;
- this.componentName = componentName;
- this.desiredState = desiredState;
+ this(clusterName, serviceName, 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 serviceName, String componentName,
- String desiredState, String componentCategory) {
+ String desiredState, String recoveryEnabled,
+ String componentCategory) {
this.clusterName = clusterName;
this.serviceName = serviceName;
this.componentName = componentName;
this.desiredState = desiredState;
+ this.recoveryEnabled = recoveryEnabled;
this.componentCategory = componentCategory;
}
@@ -105,6 +112,20 @@ public class ServiceComponentRequest {
this.clusterName = clusterName;
}
+ /**
+ * @return recoveryEnabled
+ */
+ public String getRecoveryEnabled() {
+ return recoveryEnabled;
+ }
+
+ /**
+ * @param recoveryEnabled the recoveryEnabled value to set.
+ */
+ public void setRecoveryEnabled(String recoveryEnabled) {
+ this.recoveryEnabled = recoveryEnabled;
+ }
+
public String getComponentCategory() {
return componentCategory;
}
@@ -115,7 +136,7 @@ public class ServiceComponentRequest {
@Override
public String toString() {
- return String.format("[clusterName=%s, serviceName=%s, componentName=%s, desiredState=%s, componentCategory=%s]",
- clusterName, serviceName, clusterName, desiredState, componentCategory);
+ return String.format("[clusterName=%s, serviceName=%s, componentName=%s, desiredState=%s, recoveryEnabled=%s, componentCategory=%s]",
+ clusterName, serviceName, clusterName, desiredState, recoveryEnabled, componentCategory);
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/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 f7dd301..381b114 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
@@ -41,6 +41,8 @@ public class ServiceComponentResponse {
private int installedCount;
+ private boolean recoveryEnabled;
+
public ServiceComponentResponse(Long clusterId, String clusterName,
String serviceName,
String componentName,
@@ -48,7 +50,8 @@ public class ServiceComponentResponse {
String desiredState,
int totalCount,
int startedCount,
- int installedCount) {
+ int installedCount,
+ boolean recoveryEnabled) {
super();
this.clusterId = clusterId;
this.clusterName = clusterName;
@@ -59,6 +62,7 @@ public class ServiceComponentResponse {
this.totalCount = totalCount;
this.startedCount = startedCount;
this.installedCount = installedCount;
+ this.recoveryEnabled = recoveryEnabled;
}
/**
@@ -211,6 +215,22 @@ public class ServiceComponentResponse {
this.totalCount = totalCount;
}
+ /**
+ * Get a true or false value indicating if the service component is auto start enabled
+ * @return true or false
+ */
+ public boolean isRecoveryEnabled() {
+ return recoveryEnabled;
+ }
+
+ /**
+ * Set a true or false value indicating whether the service component is auto start enabled
+ * @param recoveryEnabled
+ */
+ public void setRecoveryEnabled(boolean recoveryEnabled) {
+ this.recoveryEnabled = recoveryEnabled;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/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 3ad6e64..b339adf 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
@@ -84,6 +84,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
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_RECOVERY_ENABLED_ID = "ServiceComponentInfo/recovery_enabled";
private static final String TRUE = "true";
@@ -178,6 +179,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
setResourceProperty(resource, COMPONENT_TOTAL_COUNT_PROPERTY_ID, response.getTotalCount(), requestedIds);
setResourceProperty(resource, COMPONENT_STARTED_COUNT_PROPERTY_ID, response.getStartedCount(), requestedIds);
setResourceProperty(resource, COMPONENT_INSTALLED_COUNT_PROPERTY_ID, response.getInstalledCount(), requestedIds);
+ setResourceProperty(resource, COMPONENT_RECOVERY_ENABLED_ID, String.valueOf(response.isRecoveryEnabled()), requestedIds);
resources.add(resource);
}
@@ -251,6 +253,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
(String) properties.get(COMPONENT_SERVICE_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),
(String) properties.get(COMPONENT_CATEGORY_PROPERTY_ID));
}
@@ -463,6 +466,9 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
Map<String, Map<String, Set<String>>> componentNames = new HashMap<>();
Set<State> seenNewStates = new HashSet<>();
+ Collection<ServiceComponent> recoveryEnabledComponents = new ArrayList<>();
+ Collection<ServiceComponent> recoveryDisabledComponents = new ArrayList<>();
+
// Determine operation level
Resource.Type reqOpLvl;
if (requestProperties.containsKey(RequestOperationLevel.OPERATION_LEVEL_ID)) {
@@ -513,6 +519,20 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
continue;
}
+ // Gather the components affected by the change in
+ // auto start state
+ if (!StringUtils.isEmpty(request.getRecoveryEnabled())) {
+ boolean newRecoveryEnabled = Boolean.parseBoolean(request.getRecoveryEnabled());
+ boolean oldRecoveryEnabled = sc.isRecoveryEnabled();
+ if (newRecoveryEnabled != oldRecoveryEnabled) {
+ if (newRecoveryEnabled) {
+ recoveryEnabledComponents.add(sc);
+ } else {
+ recoveryDisabledComponents.add(sc);
+ }
+ }
+ }
+
if (newState == null) {
debug("Nothing to do for new updateServiceComponent request, request ={}, newDesiredState=null" + request);
continue;
@@ -539,9 +559,11 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterId=" + cluster.getClusterId()
+ ", serviceName=" + sc.getServiceName()
+ ", componentName=" + sc.getName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", currentDesiredState=" + oldScState
+ ", newDesiredState=" + newState);
}
+
if (!changedComps.containsKey(newState)) {
changedComps.put(newState, new ArrayList<ServiceComponent>());
}
@@ -549,6 +571,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterName=" + clusterName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", currentDesiredState=" + oldScState
+ ", newDesiredState=" + newState);
@@ -562,6 +585,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterName=" + clusterName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", hostname=" + sch.getHostName()
+ ", currentState=" + oldSchState
+ ", newDesiredState=" + newState);
@@ -574,6 +598,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterName=" + clusterName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", hostname=" + sch.getHostName()
+ ", currentState=" + oldSchState
+ ", newDesiredState=" + newState);
@@ -587,6 +612,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterName=" + clusterName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", hostname=" + sch.getHostName());
continue;
@@ -600,6 +626,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterId=" + cluster.getClusterId()
+ ", serviceName=" + sch.getServiceName()
+ ", componentName=" + sch.getServiceComponentName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", hostname=" + sch.getHostName()
+ ", currentState=" + oldSchState
+ ", newDesiredState=" + newState);
@@ -615,6 +642,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterName=" + clusterName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", hostname=" + sch.getHostName()
+ ", currentState=" + oldSchState
+ ", newDesiredState=" + newState);
@@ -628,6 +656,16 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
// TODO additional validation?
+ // Validations completed. Update the affected service components now.
+
+ for (ServiceComponent sc : recoveryEnabledComponents) {
+ sc.setRecoveryEnabled(true);
+ }
+
+ for (ServiceComponent sc : recoveryDisabledComponents) {
+ sc.setRecoveryEnabled(false);
+ }
+
Cluster cluster = clusters.getCluster(clusterNames.iterator().next());
return getManagementController().createAndPersistStages(cluster, requestProperties, null, null, changedComps, changedScHosts,
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
index bda2543..630eef2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
@@ -55,6 +55,9 @@ public class ServiceComponentDesiredStateEntity {
@Enumerated(EnumType.STRING)
private State desiredState = State.INIT;
+ @Column(name = "recovery_enabled", nullable = false, insertable = true, updatable = true)
+ private Integer recoveryEnabled = 0;
+
/**
* Unidirectional one-to-one association to {@link StackEntity}
*/
@@ -112,6 +115,14 @@ public class ServiceComponentDesiredStateEntity {
this.desiredStack = desiredStack;
}
+ public boolean isRecoveryEnabled() {
+ return recoveryEnabled != 0;
+ }
+
+ public void setRecoveryEnabled(boolean recoveryEnabled) {
+ this.recoveryEnabled = (recoveryEnabled == false) ? 0 : 1;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
index 7803045..dcb7cf6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
@@ -28,6 +28,20 @@ public interface ServiceComponent {
String getName();
+ /**
+ * Get a true or false value specifying
+ * if auto start was enabled for this component.
+ * @return true or false
+ */
+ boolean isRecoveryEnabled();
+
+ /**
+ * Set a true or false value specifying if this
+ * component is to be enabled for auto start or not.
+ * @param recoveryEnabled - true or false
+ */
+ void setRecoveryEnabled(boolean recoveryEnabled);
+
String getServiceName();
long getClusterId();
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
index 7e1dd1d..7b866a9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
@@ -95,6 +95,7 @@ public class ServiceComponentImpl implements ServiceComponent {
desiredStateEntity.setDesiredState(State.INIT);
desiredStateEntity.setServiceName(service.getName());
desiredStateEntity.setClusterId(service.getClusterId());
+ desiredStateEntity.setRecoveryEnabled(false);
desiredStateEntityPK = getDesiredStateEntityPK(desiredStateEntity);
setDesiredStackVersion(service.getDesiredStackVersion());
@@ -190,6 +191,55 @@ public class ServiceComponentImpl implements ServiceComponent {
return null;
}
+ /**
+ * Get the recoveryEnabled value.
+ *
+ * @return true or false
+ */
+ @Override
+ public boolean isRecoveryEnabled() {
+ ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+ if (desiredStateEntity != null) {
+ return desiredStateEntity.isRecoveryEnabled();
+ } else {
+ LOG.warn("Trying to fetch a member from an entity object that may " +
+ "have been previously deleted, serviceName = " + service.getName() + ", " +
+ "componentName = " + componentName);
+ }
+ return false;
+ }
+
+ /**
+ * Set the recoveryEnabled field in the entity object.
+ *
+ * @param recoveryEnabled - true or false
+ */
+ @Override
+ public void setRecoveryEnabled(boolean recoveryEnabled) {
+ readWriteLock.writeLock().lock();
+ try {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Setting RecoveryEnabled of Component" + ", clusterName="
+ + service.getCluster().getClusterName() + ", clusterId="
+ + service.getCluster().getClusterId() + ", serviceName="
+ + service.getName() + ", componentName=" + getName()
+ + ", oldRecoveryEnabled=" + isRecoveryEnabled() + ", newRecoveryEnabled="
+ + recoveryEnabled);
+ }
+ ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+ if (desiredStateEntity != null) {
+ desiredStateEntity.setRecoveryEnabled(recoveryEnabled);
+ saveIfPersisted();
+ } else {
+ LOG.warn("Setting a member on an entity object that may have been " +
+ "previously deleted, serviceName = " + service.getName());
+ }
+
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ }
+
@Override
public String getServiceName() {
return service.getName();
@@ -256,7 +306,8 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterId=" + service.getCluster().getClusterId()
+ ", serviceName=" + service.getName()
+ ", serviceComponentName=" + getName()
- + ", hostname=" + hostComponent.getHostName());
+ + ", hostname=" + hostComponent.getHostName()
+ + ", recoveryEnabled=" + isRecoveryEnabled());
}
if (hostComponents.containsKey(hostComponent.getHostName())) {
throw new AmbariException("Cannot add duplicate ServiceComponentHost"
@@ -264,7 +315,8 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterId=" + service.getCluster().getClusterId()
+ ", serviceName=" + service.getName()
+ ", serviceComponentName=" + getName()
- + ", hostname=" + hostComponent.getHostName());
+ + ", hostname=" + hostComponent.getHostName()
+ + ", recoveryEnabled=" + isRecoveryEnabled());
}
// FIXME need a better approach of caching components by host
ClusterImpl clusterImpl = (ClusterImpl) service.getCluster();
@@ -292,6 +344,7 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterId=" + service.getCluster().getClusterId()
+ ", serviceName=" + service.getName()
+ ", serviceComponentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", hostname=" + hostName);
}
if (hostComponents.containsKey(hostName)) {
@@ -300,6 +353,7 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterId=" + service.getCluster().getClusterId()
+ ", serviceName=" + service.getName()
+ ", serviceComponentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", hostname=" + hostName);
}
ServiceComponentHost hostComponent = serviceComponentHostFactory.createNew(this, hostName);
@@ -363,11 +417,11 @@ public class ServiceComponentImpl implements ServiceComponent {
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Setting DesiredState of Service" + ", clusterName="
- + service.getCluster().getClusterName() + ", clusterId="
- + service.getCluster().getClusterId() + ", serviceName="
- + service.getName() + ", serviceComponentName=" + getName()
- + ", oldDesiredState=" + getDesiredState() + ", newDesiredState="
- + state);
+ + service.getCluster().getClusterName() + ", clusterId="
+ + service.getCluster().getClusterId() + ", serviceName="
+ + service.getName() + ", serviceComponentName=" + getName()
+ + ", oldDesiredState=" + getDesiredState() + ", newDesiredState="
+ + state);
}
ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
if (desiredStateEntity != null) {
@@ -437,7 +491,8 @@ public class ServiceComponentImpl implements ServiceComponent {
ServiceComponentResponse r = new ServiceComponentResponse(getClusterId(),
cluster.getClusterName(), service.getName(), getName(),
getDesiredStackVersion().getStackId(), getDesiredState().toString(),
- getTotalCount(), getStartedCount(), getInstalledCount());
+ getTotalCount(), getStartedCount(), getInstalledCount(),
+ isRecoveryEnabled());
return r;
} finally {
readWriteLock.readLock().unlock();
@@ -449,11 +504,13 @@ public class ServiceComponentImpl implements ServiceComponent {
return service.getCluster().getClusterName();
}
+
@Override
public void debugDump(StringBuilder sb) {
readWriteLock.readLock().lock();
try {
sb.append("ServiceComponent={ serviceComponentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", clusterName=" + service.getCluster().getClusterName()
+ ", clusterId=" + service.getCluster().getClusterId()
+ ", serviceName=" + service.getName() + ", desiredStackVersion="
@@ -603,6 +660,7 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterName=" + getClusterName()
+ ", serviceName=" + getServiceName()
+ ", componentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", hostname=" + sch.getHostName());
return false;
}
@@ -626,7 +684,8 @@ public class ServiceComponentImpl implements ServiceComponent {
LOG.info("Deleting all servicecomponenthosts for component"
+ ", clusterName=" + getClusterName()
+ ", serviceName=" + getServiceName()
- + ", componentName=" + getName());
+ + ", componentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled());
for (ServiceComponentHost sch : hostComponents.values()) {
if (!sch.canBeRemoved()) {
throw new AmbariException("Found non removable hostcomponent "
@@ -635,6 +694,7 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterName=" + getClusterName()
+ ", serviceName=" + getServiceName()
+ ", componentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", hostname=" + sch.getHostName());
}
}
@@ -663,12 +723,14 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterName=" + getClusterName()
+ ", serviceName=" + getServiceName()
+ ", componentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", hostname=" + sch.getHostName());
if (!sch.canBeRemoved()) {
throw new AmbariException("Could not delete hostcomponent from cluster"
+ ", clusterName=" + getClusterName()
+ ", serviceName=" + getServiceName()
+ ", componentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", hostname=" + sch.getHostName());
}
sch.delete();
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
index 8aee031..6d63a90 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@ -176,6 +176,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
PRIMARY KEY (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index 4940e9d..e395902 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -177,6 +177,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(100) NOT NULL,
+ recovery_enabled TINYINT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index e43a7fc..0f957e6 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -167,6 +167,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id NUMBER(19) NOT NULL,
desired_state VARCHAR2(255) NOT NULL,
service_name VARCHAR2(255) NOT NULL,
+ recovery_enabled NUMBER(1) DEFAULT 0 NOT NULL,
PRIMARY KEY (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index 848d9e0..7daf4ae 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -176,6 +176,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
PRIMARY KEY (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
index a379575..28c025f 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
@@ -201,6 +201,7 @@ CREATE TABLE ambari.servicecomponentdesiredstate (
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
PRIMARY KEY (component_name, cluster_id, service_name)
);
GRANT ALL PRIVILEGES ON TABLE ambari.servicecomponentdesiredstate TO :username;
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index b57d377..c9d6ac2 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -166,6 +166,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id NUMERIC(19) NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled BIT NOT NULL DEFAULT 0,
PRIMARY KEY (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index b2fd5e2..4d6f0e8 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -186,6 +186,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled BIT NOT NULL DEFAULT 0,
PRIMARY KEY CLUSTERED (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index 4052ad2..8ccae05 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -62,6 +62,7 @@
"ServiceComponentInfo/total_count",
"ServiceComponentInfo/started_count",
"ServiceComponentInfo/installed_count",
+ "ServiceComponentInfo/recovery_enabled",
"params/run_smoke_test",
"_"
],
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/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 ffee3fa..1a223e1 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
@@ -5683,6 +5683,7 @@ public class AmbariManagementControllerTest {
clusters.getCluster(clusterName).getService(serviceName)
.getServiceComponents().values()) {
Assert.assertEquals(State.INSTALLED, sc.getDesiredState());
+ Assert.assertFalse(sc.isRecoveryEnabled()); // default value of recoveryEnabled
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
Assert.assertEquals(State.INSTALLED, sch.getDesiredState());
Assert.assertEquals(State.INIT, sch.getState());
@@ -5699,6 +5700,7 @@ public class AmbariManagementControllerTest {
for (ServiceComponent sc :
clusters.getCluster(clusterName).getService(serviceName)
.getServiceComponents().values()) {
+ sc.setRecoveryEnabled(true);
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
sch.setState(State.INSTALLED);
}
@@ -5718,6 +5720,7 @@ public class AmbariManagementControllerTest {
clusters.getCluster(clusterName).getService(serviceName)
.getServiceComponents().values()) {
Assert.assertEquals(State.INSTALLED, sc.getDesiredState());
+ Assert.assertTrue(sc.isRecoveryEnabled());
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
Assert.assertEquals(State.INSTALLED, sch.getDesiredState());
Assert.assertEquals(State.INSTALLED, sch.getState());
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
index f38fab1..d24ca09 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
@@ -225,11 +225,14 @@ public class ComponentResourceProviderTest {
expect(service.getServiceComponents()).andReturn(serviceComponentMap).anyTimes();
expect(serviceComponent1.convertToResponse()).andReturn(
- new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component100", null, "", 1, 1, 0));
+ new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component100", null, "", 1, 1, 0,
+ true /* recovery enabled */));
expect(serviceComponent2.convertToResponse()).andReturn(
- new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, "", 1, 1, 0));
+ new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, "", 1, 1, 0,
+ false /* recovery not enabled */));
expect(serviceComponent3.convertToResponse()).andReturn(
- new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null, "", 1, 1, 0));
+ new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null, "", 1, 1, 0,
+ true /* recovery enabled */));
expect(ambariMetaInfo.getComponent((String) anyObject(),
(String) anyObject(), (String) anyObject(), (String) anyObject()))
@@ -258,6 +261,7 @@ public class ComponentResourceProviderTest {
propertyIds.add(ComponentResourceProvider.COMPONENT_TOTAL_COUNT_PROPERTY_ID);
propertyIds.add(ComponentResourceProvider.COMPONENT_STARTED_COUNT_PROPERTY_ID);
propertyIds.add(ComponentResourceProvider.COMPONENT_INSTALLED_COUNT_PROPERTY_ID);
+ propertyIds.add(ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID);
Predicate predicate = new PredicateBuilder()
.property(ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID)
@@ -282,6 +286,8 @@ public class ComponentResourceProviderTest {
ComponentResourceProvider.COMPONENT_STARTED_COUNT_PROPERTY_ID));
Assert.assertEquals(0, resource.getPropertyValue(
ComponentResourceProvider.COMPONENT_INSTALLED_COUNT_PROPERTY_ID));
+ Assert.assertEquals(String.valueOf(true), resource.getPropertyValue(
+ ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID));
}
// verify
@@ -364,11 +370,14 @@ public class ComponentResourceProviderTest {
expect(component3Info.getCategory()).andReturn(null);
expect(serviceComponent1.convertToResponse()).andReturn(
- new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, "", 1, 0, 1));
+ new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, "", 1, 0, 1,
+ false /* recovery not enabled */));
expect(serviceComponent2.convertToResponse()).andReturn(
- new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null, "", 1, 0, 1));
+ new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null, "", 1, 0, 1,
+ false /* recovery not enabled */));
expect(serviceComponent3.convertToResponse()).andReturn(
- new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component103", null, "", 1, 0, 1));
+ new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component103", null, "", 1, 0, 1,
+ false /* recovery not enabled */));
expect(serviceComponent1.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
expect(serviceComponent2.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
expect(serviceComponent3.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
@@ -412,6 +421,7 @@ public class ComponentResourceProviderTest {
Map<String, Object> properties = new LinkedHashMap<String, Object>();
+ properties.put(ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID, String.valueOf(true) /* recovery enabled */);
properties.put(ComponentResourceProvider.COMPONENT_STATE_PROPERTY_ID, "STARTED");
properties.put(ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -607,7 +617,7 @@ public class ComponentResourceProviderTest {
// requests
ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
- null);
+ null, String.valueOf(true /* recovery enabled */));
Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
setRequests.add(request1);
@@ -667,14 +677,15 @@ public class ComponentResourceProviderTest {
// requests
ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
- null);
+ null, String.valueOf(true /* recovery enabled */));
ServiceComponentRequest request2 = new ServiceComponentRequest("cluster1", "service1", "component2",
- null);
+ null, String.valueOf(true /* recovery enabled */));
ServiceComponentRequest request3 = new ServiceComponentRequest("cluster1", "service1", "component3",
- null);
+ null, String.valueOf(true /* recovery enabled */));
ServiceComponentRequest request4 = new ServiceComponentRequest("cluster1", "service1", "component4",
- null);
- ServiceComponentRequest request5 = new ServiceComponentRequest("cluster1", "service2", null, null);
+ null, String.valueOf(true /* recovery enabled */));
+ ServiceComponentRequest request5 = new ServiceComponentRequest("cluster1", "service2", null, null,
+ String.valueOf(true /* recovery enabled */));
Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
setRequests.add(request1);
@@ -758,7 +769,7 @@ public class ComponentResourceProviderTest {
// requests
ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
- null);
+ null, String.valueOf(true /* recovery enabled */));
Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
setRequests.add(request1);