This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-2.7 by this push:
new 6e14430 AMBARI-25041. Scale hosts does not install component if
service is in maintenance mode (#2787)
6e14430 is described below
commit 6e14430857028efe9418c169547633ecdd46b8de
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Tue Jan 29 16:02:22 2019 +0100
AMBARI-25041. Scale hosts does not install component if service is in
maintenance mode (#2787)
---
.../internal/HostComponentResourceProvider.java | 6 +++++-
.../controller/internal/RequestOperationLevel.java | 21 +++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
index 96197c0..c245b95 100644
---
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
+++
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
@@ -390,6 +390,9 @@ public class HostComponentResourceProvider extends
AbstractControllerResourcePro
(skipInstallForComponents, ";"));
requestInfo.put(AmbariManagementControllerImpl.DONT_SKIP_INSTALL_FOR_COMPONENTS,
StringUtils.join
(dontSkipInstallForComponents, ";"));
+ // 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));
Request installRequest =
PropertyHelper.getUpdateRequest(installProperties, requestInfo);
@@ -437,6 +440,8 @@ public class HostComponentResourceProvider extends
AbstractControllerResourcePro
Map<String, String> requestInfo = new HashMap<>();
requestInfo.put("context", String.format("Start components on host %s",
hostName));
requestInfo.put("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);
@@ -500,7 +505,6 @@ public class HostComponentResourceProvider extends
AbstractControllerResourcePro
return requestStages.getRequestStatusResponse();
}
-
/**
* Update the host component identified by the given request object with the
* values carried by the given request object.
diff --git
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestOperationLevel.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestOperationLevel.java
index ed43722..2e1e18e 100644
---
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestOperationLevel.java
+++
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestOperationLevel.java
@@ -21,6 +21,8 @@ import java.util.Map;
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 class RequestOperationLevel {
", 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
+ );
+ }
+
}