Skip to content
Permalink
Browse files
AMBARI-25041. Scale hosts does not install component if service is in…
… maintenance mode (#2720)
  • Loading branch information
adoroszlai committed Dec 13, 2018
1 parent 66b6f7f commit ab3e2b6f17057cbe78d5e3f9385b83394c2aca6a
Showing 2 changed files with 26 additions and 1 deletion.
@@ -396,6 +396,9 @@ public RequestStatusResponse install(String cluster, String hostname, Collection
Map<String, String> requestInfo = new HashMap<>();
requestInfo.put("context", String.format("Install components on host %s", hostname));
requestInfo.put(CLUSTER_PHASE_PROPERTY, CLUSTER_PHASE_INITIAL_INSTALL);
// although the operation is really for a specific host, the level needs to be set to HostComponent
// to make sure that any service in maintenance mode does not prevent install/start on the new host during scale-up
requestInfo.putAll(RequestOperationLevel.propertiesFor(Resource.Type.HostComponent, cluster));
addProvisionActionProperties(skipInstallForComponents, dontSkipInstallForComponents, requestInfo);

Request installRequest = PropertyHelper.getUpdateRequest(installProperties, requestInfo);
@@ -469,6 +472,8 @@ public RequestStatusResponse start(String cluster, String hostName, Collection<S
Map<String, String> requestInfo = new HashMap<>();
requestInfo.put("context", String.format("Start components on host %s", hostName));
requestInfo.put(CLUSTER_PHASE_PROPERTY, CLUSTER_PHASE_INITIAL_START);
// see rationale for marking the operation as HostComponent-level at "Install components on host"
requestInfo.putAll(RequestOperationLevel.propertiesFor(Resource.Type.HostComponent, cluster));
requestInfo.put(Setting.SETTING_NAME_SKIP_FAILURE, Boolean.toString(skipFailure));

Predicate clusterPredicate = new EqualsPredicate<>(CLUSTER_NAME, cluster);
@@ -532,7 +537,6 @@ public RequestStatusResponse start(String cluster, String hostName, Collection<S
return requestStages.getRequestStatusResponse();
}


/**
* Update the host component identified by the given request object with the
* values carried by the given request object.
@@ -21,6 +21,8 @@

import org.apache.ambari.server.controller.spi.Resource;

import com.google.common.collect.ImmutableMap;

/**
* Operation level is specified along with some requests. It identifies
* the logical level, at which the operation is executed.
@@ -183,4 +185,23 @@ public String toString() {
", hostName='" + hostName + '\'' +
'}';
}

/**
* Create a map of required properties to be added to a request info map which is
* then used to create a {@link RequestOperationLevel} object.
* Other properties (service name, host name, host component name) can be set on
* the request info map itself as needed.
*
* @param type resource type for which to calculate the operation level
* @param clusterName cluster name
* @return immutable map with required properties: operation level and cluster name
* @throws IllegalArgumentException if the given resource {@code type} is not mapped to any operation level
*/
public static Map<String, String> propertiesFor(Resource.Type type, String clusterName) {
return ImmutableMap.of(
OPERATION_LEVEL_ID, getExternalLevelName(type.name()),
OPERATION_CLUSTER_ID, clusterName
);
}

}

0 comments on commit ab3e2b6

Please sign in to comment.