You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2017/07/13 19:14:54 UTC
[36/37] ambari git commit: AMBARI-21450. Initial cherry-picking for
feature branch (ncole)
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
index f75fb41..1b0e0e0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -47,13 +47,14 @@ import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.controller.internal.RequestResourceFilter;
import org.apache.ambari.server.customactions.ActionDefinition;
-import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
-import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
import org.apache.ambari.server.orm.entities.OperatingSystemEntity;
import org.apache.ambari.server.orm.entities.RepositoryEntity;
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.ServiceInfo;
import org.apache.ambari.server.state.StackId;
@@ -91,8 +92,6 @@ public class AmbariActionExecutionHelper {
private MaintenanceStateHelper maintenanceStateHelper;
@Inject
private Configuration configs;
- @Inject
- private ClusterVersionDAO clusterVersionDAO;
/**
* Validates the request to execute an action.
@@ -148,8 +147,6 @@ public class AmbariActionExecutionHelper {
actionRequest.getClusterName());
}
- StackId stackId = cluster.getCurrentStackVersion();
-
String expectedService = actionDef.getTargetService() == null ? "" : actionDef.getTargetService();
String actualService = resourceFilter == null || resourceFilter.getServiceName() == null ? "" : resourceFilter.getServiceName();
@@ -159,11 +156,14 @@ public class AmbariActionExecutionHelper {
}
targetService = expectedService;
- if (targetService == null || targetService.isEmpty()) {
+ if (StringUtils.isBlank(targetService)) {
targetService = actualService;
}
- if (targetService != null && !targetService.isEmpty()) {
+ if (StringUtils.isNotBlank(targetService)) {
+ Service service = cluster.getService(targetService);
+ StackId stackId = service.getDesiredStackId();
+
ServiceInfo serviceInfo;
try {
serviceInfo = ambariMetaInfo.getService(stackId.getStackName(), stackId.getStackVersion(),
@@ -186,16 +186,20 @@ public class AmbariActionExecutionHelper {
}
targetComponent = expectedComponent;
- if (targetComponent == null || targetComponent.isEmpty()) {
+ if (StringUtils.isBlank(targetComponent)) {
targetComponent = actualComponent;
}
- if (!targetComponent.isEmpty() && targetService.isEmpty()) {
+ if (StringUtils.isNotBlank(targetComponent) && StringUtils.isBlank(targetService)) {
throw new AmbariException("Action " + actionRequest.getActionName() + " targets component " + targetComponent +
" without specifying the target service.");
}
- if (targetComponent != null && !targetComponent.isEmpty()) {
+ if (StringUtils.isNotBlank(targetComponent)) {
+ Service service = cluster.getService(targetService);
+ ServiceComponent component = service.getServiceComponent(targetComponent);
+ StackId stackId = component.getDesiredStackId();
+
ComponentInfo compInfo;
try {
compInfo = ambariMetaInfo.getComponent(stackId.getStackName(), stackId.getStackVersion(),
@@ -283,13 +287,16 @@ public class AmbariActionExecutionHelper {
}
if (null != cluster) {
- StackId stackId = cluster.getCurrentStackVersion();
+// StackId stackId = cluster.getCurrentStackVersion();
if (serviceName != null && !serviceName.isEmpty()) {
if (componentName != null && !componentName.isEmpty()) {
- Map<String, ServiceComponentHost> componentHosts =
- cluster.getService(serviceName)
- .getServiceComponent(componentName).getServiceComponentHosts();
+ Service service = cluster.getService(serviceName);
+ ServiceComponent component = service.getServiceComponent(componentName);
+ StackId stackId = component.getDesiredStackId();
+
+ Map<String, ServiceComponentHost> componentHosts = component.getServiceComponentHosts();
candidateHosts.addAll(componentHosts.keySet());
+
try {
componentInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
stackId.getStackVersion(), serviceName, componentName);
@@ -299,8 +306,7 @@ public class AmbariActionExecutionHelper {
}
} else {
for (String component : cluster.getService(serviceName).getServiceComponents().keySet()) {
- Map<String, ServiceComponentHost> componentHosts =
- cluster.getService(serviceName)
+ Map<String, ServiceComponentHost> componentHosts = cluster.getService(serviceName)
.getServiceComponent(component).getServiceComponentHosts();
candidateHosts.addAll(componentHosts.keySet());
}
@@ -325,12 +331,9 @@ public class AmbariActionExecutionHelper {
);
if (! ignoredHosts.isEmpty()) {
- LOG.debug("Hosts to ignore: {}.", StringUtils.join(ignoredHosts, ", "));
- LOG.debug("Ignoring action for hosts due to maintenance state." +
- "Ignored hosts =" + ignoredHosts + ", component="
- + componentName + ", service=" + serviceName
- + ", cluster=" + cluster.getClusterName() + ", " +
- "actionName=" + actionContext.getActionName());
+ LOG.debug("Hosts to ignore: {}.", ignoredHosts);
+ LOG.debug("Ignoring action for hosts due to maintenance state.Ignored hosts ={}, component={}, service={}, cluster={}, actionName={}",
+ ignoredHosts, componentName, serviceName, cluster.getClusterName(), actionContext.getActionName());
}
}
@@ -454,12 +457,15 @@ public class AmbariActionExecutionHelper {
for (Map.Entry<String, String> dbConnectorName : configs.getDatabaseConnectorNames().entrySet()) {
hostLevelParams.put(dbConnectorName.getKey(), dbConnectorName.getValue());
}
-
for (Map.Entry<String, String> previousDBConnectorName : configs.getPreviousDatabaseConnectorNames().entrySet()) {
hostLevelParams.put(previousDBConnectorName.getKey(), previousDBConnectorName.getValue());
}
- addRepoInfoToHostLevelParams(cluster, actionContext, hostLevelParams, hostName);
+ if (StringUtils.isNotBlank(serviceName)) {
+ Service service = cluster.getService(serviceName);
+ addRepoInfoToHostLevelParams(service.getDesiredRepositoryVersion(), hostLevelParams, hostName);
+ }
+
Map<String, String> roleParams = execCmd.getRoleParams();
if (roleParams == null) {
@@ -489,6 +495,8 @@ public class AmbariActionExecutionHelper {
execCmd.getLocalComponents().add(sch.getServiceComponentName());
}
}
+
+ actionContext.visitAll(execCmd);
}
}
@@ -519,47 +527,35 @@ public class AmbariActionExecutionHelper {
*
* */
- private void addRepoInfoToHostLevelParams(Cluster cluster, ActionExecutionContext actionContext,
+ private void addRepoInfoToHostLevelParams(RepositoryVersionEntity repositoryVersion,
Map<String, String> hostLevelParams, String hostName) throws AmbariException {
- if (null == cluster) {
+ if (null == repositoryVersion) {
return;
}
JsonObject rootJsonObject = new JsonObject();
JsonArray repositories = new JsonArray();
- ClusterVersionEntity clusterVersionEntity = clusterVersionDAO.findByClusterAndStateCurrent(
- cluster.getClusterName());
-
- if (clusterVersionEntity != null && clusterVersionEntity.getRepositoryVersion() != null) {
- String hostOsFamily = clusters.getHost(hostName).getOsFamily();
- for (OperatingSystemEntity operatingSystemEntity : clusterVersionEntity.getRepositoryVersion().getOperatingSystems()) {
- // ostype in OperatingSystemEntity it's os family. That should be fixed
- // in OperatingSystemEntity.
- if (operatingSystemEntity.getOsType().equals(hostOsFamily)) {
- for (RepositoryEntity repositoryEntity : operatingSystemEntity.getRepositories()) {
- JsonObject repositoryInfo = new JsonObject();
- repositoryInfo.addProperty("base_url", repositoryEntity.getBaseUrl());
- repositoryInfo.addProperty("repo_name", repositoryEntity.getName());
- repositoryInfo.addProperty("repo_id", repositoryEntity.getRepositoryId());
-
- repositories.add(repositoryInfo);
- }
- rootJsonObject.add("repositories", repositories);
+
+ String hostOsFamily = clusters.getHost(hostName).getOsFamily();
+ for (OperatingSystemEntity operatingSystemEntity : repositoryVersion.getOperatingSystems()) {
+ // ostype in OperatingSystemEntity it's os family. That should be fixed
+ // in OperatingSystemEntity.
+ if (operatingSystemEntity.getOsType().equals(hostOsFamily)) {
+ for (RepositoryEntity repositoryEntity : operatingSystemEntity.getRepositories()) {
+ JsonObject repositoryInfo = new JsonObject();
+ repositoryInfo.addProperty("base_url", repositoryEntity.getBaseUrl());
+ repositoryInfo.addProperty("repo_name", repositoryEntity.getName());
+ repositoryInfo.addProperty("repo_id", repositoryEntity.getRepositoryId());
+
+ repositories.add(repositoryInfo);
}
+ rootJsonObject.add("repositories", repositories);
}
}
hostLevelParams.put(REPO_INFO, rootJsonObject.toString());
- // set the host level params if not already set by whoever is creating this command
- if (!hostLevelParams.containsKey(STACK_NAME) || !hostLevelParams.containsKey(STACK_VERSION)) {
- // see if the action context has a stack ID set to use, otherwise use the
- // cluster's current stack ID
- StackId stackId = actionContext.getStackId() != null ? actionContext.getStackId()
- : cluster.getCurrentStackVersion();
-
- hostLevelParams.put(STACK_NAME, stackId.getStackName());
- hostLevelParams.put(STACK_VERSION, stackId.getStackVersion());
- }
+ hostLevelParams.put(STACK_NAME, repositoryVersion.getStackName());
+ hostLevelParams.put(STACK_VERSION, repositoryVersion.getStackVersion());
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
index 9b19ade..6360a04 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -29,11 +29,7 @@ import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.DB_NAME;
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.GROUP_LIST;
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.HOOKS_FOLDER;
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.HOST_SYS_PREPPED;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.JAVA_HOME;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.JAVA_VERSION;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.JCE_NAME;
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.JDK_LOCATION;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.JDK_NAME;
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.MYSQL_JDBC_URL;
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.NOT_MANAGED_HDFS_PATH_LIST;
import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.ORACLE_JDBC_URL;
@@ -58,6 +54,8 @@ import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
+import org.apache.ambari.annotations.Experimental;
+import org.apache.ambari.annotations.ExperimentalFeature;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.Role;
import org.apache.ambari.server.RoleCommand;
@@ -65,6 +63,7 @@ import org.apache.ambari.server.actionmanager.HostRoleCommand;
import org.apache.ambari.server.actionmanager.HostRoleStatus;
import org.apache.ambari.server.actionmanager.Stage;
import org.apache.ambari.server.agent.AgentCommand.AgentCommandType;
+import org.apache.ambari.server.agent.CommandRepository;
import org.apache.ambari.server.agent.ExecutionCommand;
import org.apache.ambari.server.agent.ExecutionCommand.KeyNames;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
@@ -73,9 +72,7 @@ import org.apache.ambari.server.controller.internal.RequestOperationLevel;
import org.apache.ambari.server.controller.internal.RequestResourceFilter;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.metadata.ActionMetadata;
-import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
-import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
import org.apache.ambari.server.orm.entities.OperatingSystemEntity;
import org.apache.ambari.server.orm.entities.RepositoryEntity;
import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
@@ -83,6 +80,7 @@ import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.CommandScriptDefinition;
import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.Config;
import org.apache.ambari.server.state.ConfigHelper;
import org.apache.ambari.server.state.CustomCommandDefinition;
import org.apache.ambari.server.state.DesiredConfig;
@@ -92,7 +90,6 @@ import org.apache.ambari.server.state.HostState;
import org.apache.ambari.server.state.MaintenanceState;
import org.apache.ambari.server.state.PropertyInfo.PropertyType;
import org.apache.ambari.server.state.RepositoryInfo;
-import org.apache.ambari.server.state.RepositoryVersionState;
import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentHost;
@@ -108,6 +105,7 @@ import org.apache.commons.lang.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Function;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
@@ -143,6 +141,8 @@ public class AmbariCustomCommandExecutionHelper {
private final static String ALIGN_MAINTENANCE_STATE = "align_maintenance_state";
+ public final static int MIN_STRICT_SERVICE_CHECK_TIMEOUT = 120;
+
@Inject
private ActionMetadata actionMetadata;
@@ -171,9 +171,6 @@ public class AmbariCustomCommandExecutionHelper {
private OsFamily os_family;
@Inject
- private ClusterVersionDAO clusterVersionDAO;
-
- @Inject
private HostRoleCommandDAO hostRoleCommandDAO;
private Map<String, Map<String, Map<String, String>>> configCredentialsForService = new HashMap<>();
@@ -195,12 +192,15 @@ public class AmbariCustomCommandExecutionHelper {
String serviceName, String componentName, String commandName)
throws AmbariException {
- Cluster cluster = clusters.getCluster(clusterName);
- StackId stackId = cluster.getDesiredStackVersion();
-
if (componentName == null) {
return false;
}
+
+ Cluster cluster = clusters.getCluster(clusterName);
+ Service service = cluster.getService(serviceName);
+ ServiceComponent component = service.getServiceComponent(componentName);
+ StackId stackId = component.getDesiredStackId();
+
ComponentInfo componentInfo = ambariMetaInfo.getComponent(
stackId.getStackName(), stackId.getStackVersion(),
serviceName, componentName);
@@ -267,8 +267,8 @@ public class AmbariCustomCommandExecutionHelper {
* @throws AmbariException
*/
private void addCustomCommandAction(final ActionExecutionContext actionExecutionContext,
- final RequestResourceFilter resourceFilter, Stage stage,
- Map<String, String> additionalCommandParams, String commandDetail) throws AmbariException {
+ final RequestResourceFilter resourceFilter, Stage stage, Map<String, String> additionalCommandParams,
+ String commandDetail, Map<String, String> requestParams) throws AmbariException {
final String serviceName = resourceFilter.getServiceName();
final String componentName = resourceFilter.getComponentName();
final String commandName = actionExecutionContext.getActionName();
@@ -320,10 +320,12 @@ public class AmbariCustomCommandExecutionHelper {
throw new AmbariException(message);
}
- StackId stackId = cluster.getDesiredStackVersion();
+ Service service = cluster.getService(serviceName);
+ StackId stackId = service.getDesiredStackId();
+
AmbariMetaInfo ambariMetaInfo = managementController.getAmbariMetaInfo();
- ServiceInfo serviceInfo = ambariMetaInfo.getService(
- stackId.getStackName(), stackId.getStackVersion(), serviceName);
+ ServiceInfo serviceInfo = ambariMetaInfo.getService(service);
+ StackInfo stackInfo = ambariMetaInfo.getStack(stackId);
CustomCommandDefinition customCommandDefinition = null;
ComponentInfo ci = serviceInfo.getComponentByName(componentName);
@@ -376,16 +378,21 @@ public class AmbariCustomCommandExecutionHelper {
execCmd.setCommandType(AgentCommandType.BACKGROUND_EXECUTION_COMMAND);
}
+ execCmd.setComponentVersions(cluster);
+
execCmd.setConfigurations(configurations);
execCmd.setConfigurationAttributes(configurationAttributes);
execCmd.setConfigurationTags(configTags);
- execCmd.setAvailableServicesFromServiceInfoMap(ambariMetaInfo.getServices(stackId.getStackName(), stackId.getStackVersion()));
-
// Get the value of credential store enabled from the DB
Service clusterService = cluster.getService(serviceName);
execCmd.setCredentialStoreEnabled(String.valueOf(clusterService.isCredentialStoreEnabled()));
+ ServiceComponent component = null;
+ if (StringUtils.isNotBlank(componentName)) {
+ component = clusterService.getServiceComponent(componentName);
+ }
+
// Get the map of service config type to password properties for the service
Map<String, Map<String, String>> configCredentials;
configCredentials = configCredentialsForService.get(clusterService.getName());
@@ -401,7 +408,7 @@ public class AmbariCustomCommandExecutionHelper {
hostLevelParams.put(CUSTOM_COMMAND, commandName);
// Set parameters required for re-installing clients on restart
- hostLevelParams.put(REPO_INFO, getRepoInfo(cluster, host));
+ hostLevelParams.put(REPO_INFO, getRepoInfo(cluster, component, host));
hostLevelParams.put(STACK_NAME, stackId.getStackName());
hostLevelParams.put(STACK_VERSION, stackId.getStackVersion());
@@ -466,7 +473,22 @@ public class AmbariCustomCommandExecutionHelper {
commandTimeout = Math.max(60, commandTimeout);
}
+ if (requestParams != null && requestParams.containsKey("context")) {
+ String requestContext = requestParams.get("context");
+ if (StringUtils.isNotEmpty(requestContext) && requestContext.toLowerCase().contains("rolling-restart")) {
+ Config clusterEnvConfig = cluster.getDesiredConfigByType("cluster-env");
+ if (clusterEnvConfig != null) {
+ String componentRollingRestartTimeout = clusterEnvConfig.getProperties().get("namenode_rolling_restart_timeout");
+ if (StringUtils.isNotEmpty(componentRollingRestartTimeout)) {
+ commandTimeout = Integer.parseInt(componentRollingRestartTimeout);
+ }
+ }
+ }
+ }
+
commandParams.put(COMMAND_TIMEOUT, "" + commandTimeout);
+ commandParams.put(SERVICE_PACKAGE_FOLDER, serviceInfo.getServicePackageFolder());
+ commandParams.put(HOOKS_FOLDER, stackInfo.getStackHooksFolder());
Map<String, String> roleParams = execCmd.getRoleParams();
if (roleParams == null) {
@@ -485,6 +507,8 @@ public class AmbariCustomCommandExecutionHelper {
execCmd.setCommandParams(commandParams);
execCmd.setRoleParams(roleParams);
+ execCmd.setRepositoryFile(getCommandRepository(cluster, component, host));
+
// perform any server side command related logic - eg - set desired states on restart
applyCustomCommandBackendLogic(cluster, serviceName, componentName, commandName, hostName);
}
@@ -677,7 +701,13 @@ public class AmbariCustomCommandExecutionHelper {
String clusterName = stage.getClusterName();
Cluster cluster = clusters.getCluster(clusterName);
- StackId stackId = cluster.getDesiredStackVersion();
+ Service service = cluster.getService(serviceName);
+ ServiceComponent component = null;
+ if (null != componentName) {
+ component = service.getServiceComponent(componentName);
+ }
+ StackId stackId = (null != component) ? component.getDesiredStackId() : service.getDesiredStackId();
+
AmbariMetaInfo ambariMetaInfo = managementController.getAmbariMetaInfo();
ServiceInfo serviceInfo = ambariMetaInfo.getService(stackId.getStackName(),
stackId.getStackVersion(), serviceName);
@@ -770,6 +800,12 @@ public class AmbariCustomCommandExecutionHelper {
}
commandParams.put(COMMAND_TIMEOUT, commandTimeout);
+ String checkType = configHelper.getValueFromDesiredConfigurations(cluster, ConfigHelper.CLUSTER_ENV, ConfigHelper.SERVICE_CHECK_TYPE);
+ if (ConfigHelper.SERVICE_CHECK_MINIMAL.equals(checkType)) {
+ int actualTimeout = Integer.parseInt(commandParams.get(COMMAND_TIMEOUT)) / 2;
+ actualTimeout = actualTimeout < MIN_STRICT_SERVICE_CHECK_TIMEOUT ? MIN_STRICT_SERVICE_CHECK_TIMEOUT : actualTimeout;
+ commandParams.put(COMMAND_TIMEOUT, Integer.toString(actualTimeout));
+ }
commandParams.put(SERVICE_PACKAGE_FOLDER, serviceInfo.getServicePackageFolder());
commandParams.put(HOOKS_FOLDER, stackInfo.getStackHooksFolder());
@@ -822,7 +858,7 @@ public class AmbariCustomCommandExecutionHelper {
cloneSet.retainAll(includedHosts);
if (cloneSet.size() > 0) {
throw new AmbariException("Same host cannot be specified for inclusion " +
- "as well as exclusion. Hosts: " + cloneSet.toString());
+ "as well as exclusion. Hosts: " + cloneSet);
}
Service service = cluster.getService(serviceName);
@@ -1009,7 +1045,7 @@ public class AmbariCustomCommandExecutionHelper {
if (!serviceName.equals(Service.Type.HBASE.name()) || hostName.equals(primaryCandidate)) {
commandParams.put(UPDATE_EXCLUDE_FILE_ONLY, "false");
- addCustomCommandAction(commandContext, commandFilter, stage, commandParams, commandDetail.toString());
+ addCustomCommandAction(commandContext, commandFilter, stage, commandParams, commandDetail.toString(), null);
}
}
}
@@ -1082,10 +1118,8 @@ public class AmbariCustomCommandExecutionHelper {
List<RequestResourceFilter> resourceFilters = actionExecutionContext.getResourceFilters();
for (RequestResourceFilter resourceFilter : resourceFilters) {
- LOG.debug("Received a command execution request"
- + ", clusterName=" + actionExecutionContext.getClusterName()
- + ", serviceName=" + resourceFilter.getServiceName()
- + ", request=" + actionExecutionContext.toString());
+ LOG.debug("Received a command execution request, clusterName={}, serviceName={}, request={}",
+ actionExecutionContext.getClusterName(), resourceFilter.getServiceName(), actionExecutionContext);
String actionName = actionExecutionContext.getActionName();
if (actionName.contains(SERVICE_CHECK_COMMAND_NAME)) {
@@ -1136,7 +1170,7 @@ public class AmbariCustomCommandExecutionHelper {
}
}
- addCustomCommandAction(actionExecutionContext, resourceFilter, stage, extraParams, commandDetail);
+ addCustomCommandAction(actionExecutionContext, resourceFilter, stage, extraParams, commandDetail, requestParams);
} else {
throw new AmbariException("Unsupported action " + actionName);
}
@@ -1151,106 +1185,208 @@ public class AmbariCustomCommandExecutionHelper {
*
* @return the repo info
*
+ * @deprecated use {@link #getCommandRepository(Cluster, ServiceComponent, Host)} instead.
* @throws AmbariException if the repository information can not be obtained
*/
- public String getRepoInfo(Cluster cluster, Host host) throws AmbariException {
+ @Deprecated
+ public String getRepoInfo(Cluster cluster, ServiceComponent component, Host host) throws AmbariException {
+
+ Function<List<RepositoryInfo>, JsonArray> function = new Function<List<RepositoryInfo>, JsonArray>() {
+ @Override
+ public JsonArray apply(List<RepositoryInfo> input) {
+ return null == input ? null : (JsonArray) gson.toJsonTree(input);
+ }
+ };
+
+ final JsonArray gsonList = getBaseUrls(cluster, component, host, function);
+
+ if (null == gsonList) {
+ return "";
+ }
+
+ BaseUrlUpdater<JsonArray> updater = new BaseUrlUpdater<JsonArray>(gsonList) {
+ @Override
+ public JsonArray apply(final RepositoryVersionEntity rve) {
+
+ JsonArray result = new JsonArray();
+
+ for (JsonElement e : gsonList) {
+ JsonObject obj = e.getAsJsonObject();
+
+ String repoId = obj.has("repoId") ? obj.get("repoId").getAsString() : null;
+ String repoName = obj.has("repoName") ? obj.get("repoName").getAsString() : null;
+ String baseUrl = obj.has("baseUrl") ? obj.get("baseUrl").getAsString() : null;
+ String osType = obj.has("osType") ? obj.get("osType").getAsString() : null;
+
+ if (null == repoId || null == baseUrl || null == osType || null == repoName) {
+ continue;
+ }
+
+ for (OperatingSystemEntity ose : rve.getOperatingSystems()) {
+ if (ose.getOsType().equals(osType) && ose.isAmbariManagedRepos()) {
+ for (RepositoryEntity re : ose.getRepositories()) {
+ if (re.getName().equals(repoName) &&
+ !re.getBaseUrl().equals(baseUrl)) {
+ obj.addProperty("baseUrl", re.getBaseUrl());
+ }
+ }
+ result.add(e);
+ }
+ }
+ }
+
+ return result;
+ }
+ };
+
+ return updateBaseUrls(cluster, component, updater).toString();
+ }
+
+ /**
+ * Builds repository information for inclusion in a command. This replaces escaping json on
+ * a command.
+ *
+ * @param cluster the cluster
+ * @param host the host
+ * @return the command repository
+ * @throws AmbariException
+ */
+ @Experimental(feature=ExperimentalFeature.PATCH_UPGRADES)
+ public CommandRepository getCommandRepository(final Cluster cluster, ServiceComponent component, Host host) throws AmbariException {
+
+ Function<List<RepositoryInfo>, List<RepositoryInfo>> function = new Function<List<RepositoryInfo>, List<RepositoryInfo>>() {
+ @Override
+ public List<RepositoryInfo> apply(List<RepositoryInfo> input) {
+ // !!! just return what is given
+ return input;
+ }
+ };
+
+ final List<RepositoryInfo> repoInfos = getBaseUrls(cluster, component, host, function);
+
+ if (null == repoInfos) {
+ return null;
+ }
+
+ final CommandRepository command = new CommandRepository();
+ StackId stackId = component.getDesiredStackId();
+ command.setRepositories(repoInfos);
+ command.setStackName(stackId.getStackName());
+
+ final BaseUrlUpdater<Void> updater = new BaseUrlUpdater<Void>(null) {
+ @Override
+ public Void apply(RepositoryVersionEntity rve) {
+
+ command.setRepositoryVersionId(rve.getId());
+ command.setRepositoryVersion(rve.getVersion());
+ command.setStackName(rve.getStackName());
+ command.setUniqueSuffix(String.format("-repo-%s", rve.getId()));
+
+ for (CommandRepository.Repository commandRepo : command.getRepositories()) {
+ String osType = commandRepo.getOsType();
+ String repoName = commandRepo.getRepoName();
+ String baseUrl = commandRepo.getBaseUrl();
+
+ for (OperatingSystemEntity ose : rve.getOperatingSystems()) {
+ if (ose.getOsType().equals(osType) && ose.isAmbariManagedRepos()) {
+ for (RepositoryEntity re : ose.getRepositories()) {
+ if (re.getName().equals(repoName) &&
+ !re.getBaseUrl().equals(baseUrl)) {
+ commandRepo.setBaseUrl(re.getBaseUrl());
+ }
+ }
+ }
+ }
+ }
- return getRepoInfo(cluster, host.getOsType(), host.getOsFamily(), host.getHostName());
+ return null;
+ }
+ };
+
+ updateBaseUrls(cluster, component, updater);
+
+ return command;
}
- public String getRepoInfo(Cluster cluster, String hostOSType, String hostOSFamily, String hostName) throws AmbariException {
+ /**
+ * Executed by two different representations of repos. When we are comfortable with the new
+ * implementation, this may be removed and called inline in {@link #getCommandRepository(Cluster, ServiceComponent, Host)}
+ *
+ * @param cluster the cluster to isolate the stack
+ * @param component the component
+ * @param host used to resolve the family for the repositories
+ * @param function function that will transform the supplied repositories for specific use.
+ * @return <T> the type as defined by the supplied {@code function}.
+ * @throws AmbariException
+ */
+ @Experimental(feature = ExperimentalFeature.PATCH_UPGRADES)
+ private <T> T getBaseUrls(Cluster cluster, ServiceComponent component, Host host,
+ Function<List<RepositoryInfo>, T> function) throws AmbariException {
+
+ String hostOsType = host.getOsType();
+ String hostOsFamily = host.getOsFamily();
+ String hostName = host.getHostName();
- StackId stackId = cluster.getDesiredStackVersion();
+ StackId stackId = component.getDesiredStackId();
Map<String, List<RepositoryInfo>> repos = ambariMetaInfo.getRepository(
stackId.getStackName(), stackId.getStackVersion());
- String family = os_family.find(hostOSType);
+ String family = os_family.find(hostOsType);
if (null == family) {
- family = hostOSFamily;
+ family = hostOsFamily;
}
- JsonElement gsonList = null;
+ final List<RepositoryInfo> repoInfos;
// !!! check for the most specific first
- if (repos.containsKey(hostOSType)) {
- gsonList = gson.toJsonTree(repos.get(hostOSType));
+ if (repos.containsKey(hostOsType)) {
+ repoInfos = repos.get(hostOsType);
} else if (null != family && repos.containsKey(family)) {
- gsonList = gson.toJsonTree(repos.get(family));
+ repoInfos = repos.get(family);
} else {
+ repoInfos = null;
LOG.warn("Could not retrieve repo information for host"
+ ", hostname=" + hostName
+ ", clusterName=" + cluster.getClusterName()
+ ", stackInfo=" + stackId.getStackId());
}
- if (null != gsonList) {
- gsonList = updateBaseUrls(cluster, JsonArray.class.cast(gsonList));
- return gsonList.toString();
- } else {
- return "";
- }
+ // leave it to function implementation to handle null.
+ return function.apply(repoInfos);
}
/**
* Checks repo URLs against the current version for the cluster and makes
* adjustments to the Base URL when the current is different.
- * @param cluster the cluster to load the current version
- * @param jsonArray the array containing stack repo data
+ *
+ * @param <T> the result after appling the repository version, if found.
*/
- private JsonArray updateBaseUrls(Cluster cluster, JsonArray jsonArray) throws AmbariException {
- ClusterVersionEntity cve = cluster.getCurrentClusterVersion();
-
- if (null == cve) {
- List<ClusterVersionEntity> list = clusterVersionDAO.findByClusterAndState(cluster.getClusterName(),
- RepositoryVersionState.INIT);
+ @Experimental(feature = ExperimentalFeature.PATCH_UPGRADES)
+ private <T> T updateBaseUrls(Cluster cluster, ServiceComponent component, BaseUrlUpdater<T> function) throws AmbariException {
- if (!list.isEmpty()) {
- if (list.size() > 1) {
- throw new AmbariException(String.format("The cluster can only be initialized by one version: %s found",
- list.size()));
- } else {
- cve = list.get(0);
- }
- }
- }
+ RepositoryVersionEntity repositoryEntity = null;
- if (null == cve || null == cve.getRepositoryVersion()) {
- LOG.info("Cluster {} has no specific Repository Versions. Using stack-defined values", cluster.getClusterName());
- return jsonArray;
+ // !!! try to find the component repo first
+ if (null != component) {
+ repositoryEntity = component.getDesiredRepositoryVersion();
+ } else {
+ LOG.info("Service component not passed in, attempt to resolve the repository for cluster {}",
+ cluster.getClusterName());
}
- RepositoryVersionEntity rve = cve.getRepositoryVersion();
+ if (null == repositoryEntity && null != component) {
+ Service service = cluster.getService(component.getServiceName());
- JsonArray result = new JsonArray();
-
- for (JsonElement e : jsonArray) {
- JsonObject obj = e.getAsJsonObject();
-
- String repoId = obj.has("repoId") ? obj.get("repoId").getAsString() : null;
- String repoName = obj.has("repoName") ? obj.get("repoName").getAsString() : null;
- String baseUrl = obj.has("baseUrl") ? obj.get("baseUrl").getAsString() : null;
- String osType = obj.has("osType") ? obj.get("osType").getAsString() : null;
-
- if (null == repoId || null == baseUrl || null == osType || null == repoName) {
- continue;
- }
+ repositoryEntity = service.getDesiredRepositoryVersion();
+ }
- for (OperatingSystemEntity ose : rve.getOperatingSystems()) {
- if (ose.getOsType().equals(osType) && ose.isAmbariManagedRepos()) {
- for (RepositoryEntity re : ose.getRepositories()) {
- if (re.getName().equals(repoName) &&
- re.getRepositoryId().equals(repoId) &&
- !re.getBaseUrl().equals(baseUrl)) {
- obj.addProperty("baseUrl", re.getBaseUrl());
- }
- }
- result.add(e);
- }
- }
+ if (null == repositoryEntity) {
+ LOG.info("Cluster {} has no specific Repository Versions. Using stack-defined values", cluster.getClusterName());
+ return function.getDefault();
}
- return result;
+ return function.apply(repositoryEntity);
}
@@ -1259,30 +1395,40 @@ public class AmbariCustomCommandExecutionHelper {
*
* @param actionExecContext the context
* @param cluster the cluster for the command
- * @param stackId the effective stack id to use.
*
- * @return a wrapper of the imporant JSON structures to add to a stage
+ * @return a wrapper of the important JSON structures to add to a stage
*/
public ExecuteCommandJson getCommandJson(ActionExecutionContext actionExecContext,
- Cluster cluster, StackId stackId) throws AmbariException {
+ Cluster cluster, RepositoryVersionEntity repositoryVersion) throws AmbariException {
Map<String, String> commandParamsStage = StageUtils.getCommandParamsStage(actionExecContext);
Map<String, String> hostParamsStage = new HashMap<>();
Map<String, Set<String>> clusterHostInfo;
String clusterHostInfoJson = "{}";
+ StackId stackId = null;
+ if (null != repositoryVersion) {
+ stackId = repositoryVersion.getStackId();
+ }
+
if (null != cluster) {
- clusterHostInfo = StageUtils.getClusterHostInfo(
- cluster);
+ clusterHostInfo = StageUtils.getClusterHostInfo(cluster);
+
// Important, because this runs during Stack Uprade, it needs to use the effective Stack Id.
- hostParamsStage = createDefaultHostParams(cluster, stackId);
+ hostParamsStage = createDefaultHostParams(cluster, repositoryVersion);
+
String componentName = null;
String serviceName = null;
if (actionExecContext.getOperationLevel() != null) {
componentName = actionExecContext.getOperationLevel().getHostComponentName();
serviceName = actionExecContext.getOperationLevel().getServiceName();
}
- if (serviceName != null && componentName != null) {
+
+ if (serviceName != null && componentName != null && null != stackId) {
+ Service service = cluster.getService(serviceName);
+ ServiceComponent component = service.getServiceComponent(componentName);
+ stackId = component.getDesiredStackId();
+
ComponentInfo componentInfo = ambariMetaInfo.getComponent(
stackId.getStackName(), stackId.getStackVersion(),
serviceName, componentName);
@@ -1294,17 +1440,22 @@ public class AmbariCustomCommandExecutionHelper {
String clientsToUpdateConfigs = gson.toJson(clientsToUpdateConfigsList);
hostParamsStage.put(CLIENTS_TO_UPDATE_CONFIGS, clientsToUpdateConfigs);
}
+
clusterHostInfoJson = StageUtils.getGson().toJson(clusterHostInfo);
//Propogate HCFS service type info to command params
- Map<String, ServiceInfo> serviceInfos = ambariMetaInfo.getServices(stackId.getStackName(), stackId.getStackVersion());
- for (ServiceInfo serviceInfoInstance : serviceInfos.values()) {
- if (serviceInfoInstance.getServiceType() != null) {
- LOG.debug("Adding {} to command parameters for {}", serviceInfoInstance.getServiceType(),
- serviceInfoInstance.getName());
-
- commandParamsStage.put("dfs_type", serviceInfoInstance.getServiceType());
- break;
+ if (null != stackId) {
+ Map<String, ServiceInfo> serviceInfos = ambariMetaInfo.getServices(stackId.getStackName(),
+ stackId.getStackVersion());
+
+ for (ServiceInfo serviceInfoInstance : serviceInfos.values()) {
+ if (serviceInfoInstance.getServiceType() != null) {
+ LOG.debug("Adding {} to command parameters for {}",
+ serviceInfoInstance.getServiceType(), serviceInfoInstance.getName());
+
+ commandParamsStage.put("dfs_type", serviceInfoInstance.getServiceType());
+ break;
+ }
}
}
}
@@ -1316,18 +1467,14 @@ public class AmbariCustomCommandExecutionHelper {
hostParamsStageJson);
}
- Map<String, String> createDefaultHostParams(Cluster cluster) throws AmbariException {
- StackId stackId = cluster.getDesiredStackVersion();
- return createDefaultHostParams(cluster, stackId);
+ Map<String, String> createDefaultHostParams(Cluster cluster, RepositoryVersionEntity repositoryVersion) throws AmbariException {
+ return createDefaultHostParams(cluster, repositoryVersion.getStackId());
}
- Map<String, String> createDefaultHostParams(Cluster cluster, StackId stackId) throws AmbariException{
+ Map<String, String> createDefaultHostParams(Cluster cluster, StackId stackId) throws AmbariException {
+
TreeMap<String, String> hostLevelParams = new TreeMap<>();
hostLevelParams.put(JDK_LOCATION, managementController.getJdkResourceUrl());
- hostLevelParams.put(JAVA_HOME, managementController.getJavaHome());
- hostLevelParams.put(JAVA_VERSION, String.valueOf(configs.getJavaVersion()));
- hostLevelParams.put(JDK_NAME, managementController.getJDKName());
- hostLevelParams.put(JCE_NAME, managementController.getJCEName());
hostLevelParams.put(STACK_NAME, stackId.getStackName());
hostLevelParams.put(STACK_VERSION, stackId.getStackVersion());
hostLevelParams.put(DB_NAME, managementController.getServerDB());
@@ -1344,24 +1491,14 @@ public class AmbariCustomCommandExecutionHelper {
String notManagedHdfsPathList = gson.toJson(notManagedHdfsPathSet);
hostLevelParams.put(NOT_MANAGED_HDFS_PATH_LIST, notManagedHdfsPathList);
- ClusterVersionEntity clusterVersionEntity = clusterVersionDAO.findByClusterAndStateCurrent(cluster.getClusterName());
- if (clusterVersionEntity == null) {
- List<ClusterVersionEntity> clusterVersionEntityList = clusterVersionDAO
- .findByClusterAndState(cluster.getClusterName(), RepositoryVersionState.INSTALLING);
- if (!clusterVersionEntityList.isEmpty()) {
- clusterVersionEntity = clusterVersionEntityList.iterator().next();
- }
- }
for (Map.Entry<String, String> dbConnectorName : configs.getDatabaseConnectorNames().entrySet()) {
hostLevelParams.put(dbConnectorName.getKey(), dbConnectorName.getValue());
}
+
for (Map.Entry<String, String> previousDBConnectorName : configs.getPreviousDatabaseConnectorNames().entrySet()) {
hostLevelParams.put(previousDBConnectorName.getKey(), previousDBConnectorName.getValue());
}
- if (clusterVersionEntity != null) {
- hostLevelParams.put("current_version", clusterVersionEntity.getRepositoryVersion().getVersion());
- }
return hostLevelParams;
}
@@ -1377,9 +1514,18 @@ public class AmbariCustomCommandExecutionHelper {
*/
public boolean isTopologyRefreshRequired(String actionName, String clusterName, String serviceName)
throws AmbariException {
+
if (actionName.equals(START_COMMAND_NAME) || actionName.equals(RESTART_COMMAND_NAME)) {
Cluster cluster = clusters.getCluster(clusterName);
- StackId stackId = cluster.getDesiredStackVersion();
+ StackId stackId = null;
+ try {
+ Service service = cluster.getService(serviceName);
+ stackId = service.getDesiredStackId();
+ } catch (AmbariException e) {
+ LOG.debug("Could not load service {}, skipping topology check", serviceName);
+ stackId = cluster.getDesiredStackVersion();
+ }
+
AmbariMetaInfo ambariMetaInfo = managementController.getAmbariMetaInfo();
@@ -1409,7 +1555,7 @@ public class AmbariCustomCommandExecutionHelper {
return service.getServiceComponent(resourceFilter.getComponentName());
} catch (Exception e) {
- LOG.debug(String.format( "Unknown error appears during getting service component: %s", e.getMessage()));
+ LOG.debug("Unknown error appears during getting service component: {}", e.getMessage());
}
return null;
}
@@ -1470,4 +1616,22 @@ public class AmbariCustomCommandExecutionHelper {
hosts.removeAll(removedHosts);
return removedHosts;
}
+
+ /**
+ * Class that is used to update base urls. There are two implementations of this - when we no
+ * longer are sure the deprecated repo info can be removed, so too can this class.
+ */
+ @Experimental(feature=ExperimentalFeature.PATCH_UPGRADES)
+ abstract static class BaseUrlUpdater<T> implements Function<RepositoryVersionEntity, T> {
+ private T m_default;
+
+ private BaseUrlUpdater(T defaultValue) {
+ m_default = defaultValue;
+ }
+
+ private T getDefault() {
+ return m_default;
+ }
+
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 82171f6..3ea9030 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -111,7 +111,6 @@ import org.apache.ambari.server.metadata.ActionMetadata;
import org.apache.ambari.server.metadata.RoleCommandOrder;
import org.apache.ambari.server.metadata.RoleCommandOrderProvider;
import org.apache.ambari.server.orm.dao.ClusterDAO;
-import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
import org.apache.ambari.server.orm.dao.ExtensionDAO;
import org.apache.ambari.server.orm.dao.ExtensionLinkDAO;
import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
@@ -120,7 +119,6 @@ import org.apache.ambari.server.orm.dao.StackDAO;
import org.apache.ambari.server.orm.dao.WidgetDAO;
import org.apache.ambari.server.orm.dao.WidgetLayoutDAO;
import org.apache.ambari.server.orm.entities.ClusterEntity;
-import org.apache.ambari.server.orm.entities.ClusterVersionEntity;
import org.apache.ambari.server.orm.entities.ExtensionEntity;
import org.apache.ambari.server.orm.entities.ExtensionLinkEntity;
import org.apache.ambari.server.orm.entities.HostEntity;
@@ -172,7 +170,6 @@ import org.apache.ambari.server.state.PropertyDependencyInfo;
import org.apache.ambari.server.state.PropertyInfo;
import org.apache.ambari.server.state.PropertyInfo.PropertyType;
import org.apache.ambari.server.state.RepositoryInfo;
-import org.apache.ambari.server.state.RepositoryVersionState;
import org.apache.ambari.server.state.SecurityType;
import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.ServiceComponent;
@@ -308,8 +305,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
@Inject
private CredentialStoreService credentialStoreService;
@Inject
- private ClusterVersionDAO clusterVersionDAO;
- @Inject
private SettingDAO settingDAO;
private MaintenanceStateHelper maintenanceStateHelper;
@@ -502,17 +497,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
// Create cluster widgets and layouts
initializeWidgetsAndLayouts(c, null);
-
- if (null != versionEntity) {
- ClusterVersionDAO clusterVersionDAO = injector.getInstance(ClusterVersionDAO.class);
-
- ClusterVersionEntity clusterVersion = clusterVersionDAO.findByClusterAndStackAndVersion(request.getClusterName(), stackId,
- request.getRepositoryVersion());
-
- if (null == clusterVersion) {
- c.createClusterVersion(stackId, versionEntity.getVersion(), getAuthName(), RepositoryVersionState.INIT);
- }
- }
}
@Override
@@ -704,8 +688,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
sch.setDesiredState(state);
}
- sch.setDesiredStackVersion(sc.getDesiredStackVersion());
-
schMap.put(cluster, sch);
}
@@ -1048,7 +1030,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
private Stage createNewStage(long id, Cluster cluster, long requestId,
- String requestContext,
+ String requestContext, String clusterHostInfo,
String commandParamsStage, String hostParamsStage) {
String logDir = BASE_LOG_DIR + File.pathSeparator + requestId;
Stage stage =
@@ -2194,7 +2176,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
changedComponentCount.get(serviceName).keySet()) {
ServiceComponent sc = cluster.getService(serviceName).
getServiceComponent(componentName);
- StackId stackId = sc.getDesiredStackVersion();
+ StackId stackId = sc.getDesiredStackId();
ComponentInfo compInfo = ambariMetaInfo.getComponent(
stackId.getStackName(), stackId.getStackVersion(), serviceName,
componentName);
@@ -2317,7 +2299,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
Map<String, String> commandParamsInp,
ServiceComponentHostEvent event,
boolean skipFailure,
- ClusterVersionEntity effectiveClusterVersion,
+ RepositoryVersionEntity repoVersion,
boolean isUpgradeSuspended,
DatabaseType databaseType,
Map<String, DesiredConfig> clusterDesiredConfigs
@@ -2356,6 +2338,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
Service clusterService = cluster.getService(serviceName);
execCmd.setCredentialStoreEnabled(String.valueOf(clusterService.isCredentialStoreEnabled()));
+ ServiceComponent component = clusterService.getServiceComponent(componentName);
+
// Get the map of service config type to password properties for the service
Map<String, Map<String, String>> configCredentials;
configCredentials = configCredentialsForService.get(clusterService.getName());
@@ -2438,9 +2422,10 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
commandParams.put(MAX_DURATION_OF_RETRIES, Integer.toString(retryMaxTime));
commandParams.put(COMMAND_RETRY_ENABLED, Boolean.toString(retryEnabled));
- if (effectiveClusterVersion != null) {
- commandParams.put(VERSION, effectiveClusterVersion.getRepositoryVersion().getVersion());
+ if (repoVersion != null) {
+ commandParams.put(VERSION, repoVersion.getVersion());
}
+
if (script.getTimeout() > 0) {
scriptCommandTimeout = String.valueOf(script.getTimeout());
}
@@ -2478,7 +2463,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
commandParams.put(ExecutionCommand.KeyNames.REFRESH_TOPOLOGY, "True");
}
- String repoInfo = customCommandExecutionHelper.getRepoInfo(cluster, hostEntity.getOsType(), osFamily , hostname);
+ String repoInfo = customCommandExecutionHelper.getRepoInfo(cluster, component, host);
if (LOG.isDebugEnabled()) {
LOG.debug("Sending repo information to agent"
+ ", hostname=" + scHost.getHostName()
@@ -2491,20 +2476,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
hostParams.put(REPO_INFO, repoInfo);
hostParams.putAll(getRcaParameters());
- // use the effective cluster version here since this command might happen
- // in the context of an upgrade and we should send the repo ID which matches
- // the version being send down
- RepositoryVersionEntity repoVersion = null;
- if (null != effectiveClusterVersion) {
- repoVersion = effectiveClusterVersion.getRepositoryVersion();
- } else {
- List<ClusterVersionEntity> list = clusterVersionDAO.findByClusterAndState(cluster.getClusterName(),
- RepositoryVersionState.INIT);
- if (1 == list.size()) {
- repoVersion = list.get(0).getRepositoryVersion();
- }
- }
-
if (null != repoVersion) {
try {
VersionDefinitionXml xml = repoVersion.getRepositoryXml();
@@ -2593,8 +2564,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
execCmd.setRoleParams(roleParams);
execCmd.setCommandParams(commandParams);
- execCmd.setAvailableServicesFromServiceInfoMap(ambariMetaInfo.getServices(stackId.getStackName(), stackId.getStackVersion()));
-
+ execCmd.setRepositoryFile(customCommandExecutionHelper.getCommandRepository(cluster, component, host));
+ hostParams.put(KeyNames.CURRENT_VERSION, repoVersion.getVersion());
if ((execCmd != null) && (execCmd.getConfigurationTags().containsKey("cluster-env"))) {
LOG.debug("AmbariManagementControllerImpl.createHostAction: created ExecutionCommand for host {}, role {}, roleCommand {}, and command ID {}, with cluster-env tags {}",
@@ -2725,9 +2696,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
return requestStages;
}
- // caching effective cluster version
- ClusterVersionEntity effectiveClusterVersion = cluster.getEffectiveClusterVersion();
-
// caching upgrade suspended
boolean isUpgradeSuspended = cluster.isUpgradeSuspended();
@@ -2753,11 +2721,10 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
Map<String, Set<String>> clusterHostInfo = StageUtils.getClusterHostInfo(cluster);
String clusterHostInfoJson = StageUtils.getGson().toJson(clusterHostInfo);
- String hostParamsJson = StageUtils.getGson().toJson(
- customCommandExecutionHelper.createDefaultHostParams(cluster));
Stage stage = createNewStage(requestStages.getLastStageId(), cluster,
- requestStages.getId(), requestProperties.get(REQUEST_CONTEXT_PROPERTY),"{}", hostParamsJson);
+ requestStages.getId(), requestProperties.get(REQUEST_CONTEXT_PROPERTY),
+ clusterHostInfoJson, "{}", null);
boolean skipFailure = false;
if (requestProperties.containsKey(Setting.SETTING_NAME_SKIP_FAILURE) && requestProperties.get(Setting.SETTING_NAME_SKIP_FAILURE).equalsIgnoreCase("true")) {
skipFailure = true;
@@ -2867,6 +2834,16 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
for (ServiceComponentHost scHost :
changedScHosts.get(compName).get(newState)) {
+ Service service = cluster.getService(scHost.getServiceName());
+ ServiceComponent serviceComponent = service.getServiceComponent(compName);
+
+ if (StringUtils.isBlank(stage.getHostParamsStage())) {
+ RepositoryVersionEntity repositoryVersion = serviceComponent.getDesiredRepositoryVersion();
+ stage.setHostParamsStage(StageUtils.getGson().toJson(
+ customCommandExecutionHelper.createDefaultHostParams(cluster, repositoryVersion)));
+ }
+
+
// Do not create role command for hosts that are not responding
if (scHost.getHostState().equals(HostState.HEARTBEAT_LOST)) {
LOG.info("Command is not created for servicecomponenthost "
@@ -2905,7 +2882,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
event = new ServiceComponentHostInstallEvent(
scHost.getServiceComponentName(), scHost.getHostName(),
nowTimestamp,
- scHost.getDesiredStackVersion().getStackId());
+ scHost.getDesiredStackId().getStackId());
}
} else if (oldSchState == State.STARTED
// TODO: oldSchState == State.INSTALLED is always false, looks like a bug
@@ -2919,7 +2896,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
roleCommand = RoleCommand.UPGRADE;
event = new ServiceComponentHostUpgradeEvent(
scHost.getServiceComponentName(), scHost.getHostName(),
- nowTimestamp, scHost.getDesiredStackVersion().getStackId());
+ nowTimestamp, scHost.getDesiredStackId().getStackId());
} else {
throw new AmbariException("Invalid transition for"
+ " servicecomponenthost"
@@ -2933,7 +2910,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
break;
case STARTED:
- StackId stackId = scHost.getDesiredStackVersion();
+ StackId stackId = scHost.getDesiredStackId();
ComponentInfo compInfo = ambariMetaInfo.getComponent(
stackId.getStackName(), stackId.getStackVersion(), scHost.getServiceName(),
scHost.getServiceComponentName());
@@ -3074,8 +3051,11 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
LOG.error("Error transitioning ServiceComponentHost state to INSTALLED", e);
}
} else {
+ // !!! can never be null
+ RepositoryVersionEntity repoVersion = serviceComponent.getDesiredRepositoryVersion();
+
createHostAction(cluster, stage, scHost, configurations, configurationAttributes, configTags,
- roleCommand, requestParameters, event, skipFailure, effectiveClusterVersion, isUpgradeSuspended,
+ roleCommand, requestParameters, event, skipFailure, repoVersion, isUpgradeSuspended,
databaseType, clusterDesiredConfigs);
}
@@ -3200,23 +3180,30 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
RoleCommand roleCommand) throws AmbariException {
Map<String, Set<String>> clusterHostInfo = StageUtils.getClusterHostInfo(cluster);
String clusterHostInfoJson = StageUtils.getGson().toJson(clusterHostInfo);
- Map<String, String> hostParamsCmd = customCommandExecutionHelper.createDefaultHostParams(cluster);
- Stage stage = createNewStage(0, cluster,1, "","{}", "");
+ Map<String, String> hostParamsCmd = customCommandExecutionHelper.createDefaultHostParams(
+ cluster, scHost.getServiceComponent().getDesiredRepositoryVersion());
+
+ Stage stage = createNewStage(0, cluster, 1, "", clusterHostInfoJson, "{}", "");
Map<String, Map<String, String>> configTags = configHelper.getEffectiveDesiredTags(cluster, scHost.getHostName());
Map<String, Map<String, String>> configurations = configHelper.getEffectiveConfigProperties(cluster, configTags);
- Map<String, Map<String, Map<String, String>>>
- configurationAttributes =
- new TreeMap<>();
+ Map<String, Map<String, Map<String, String>>> configurationAttributes = new TreeMap<>();
+
+ RepositoryVersionEntity repoVersion = null;
+ if (null != scHost.getServiceComponent().getDesiredRepositoryVersion()) {
+ repoVersion = scHost.getServiceComponent().getDesiredRepositoryVersion();
+ } else {
+ Service service = cluster.getService(scHost.getServiceName());
+ repoVersion = service.getDesiredRepositoryVersion();
+ }
- ClusterVersionEntity effectiveClusterVersion = cluster.getEffectiveClusterVersion();
boolean isUpgradeSuspended = cluster.isUpgradeSuspended();
DatabaseType databaseType = configs.getDatabaseType();
Map<String, DesiredConfig> clusterDesiredConfigs = cluster.getDesiredConfigs();
createHostAction(cluster, stage, scHost, configurations, configurationAttributes, configTags,
- roleCommand, null, null, false, effectiveClusterVersion, isUpgradeSuspended, databaseType,
+ roleCommand, null, null, false, repoVersion, isUpgradeSuspended, databaseType,
clusterDesiredConfigs);
ExecutionCommand ec = stage.getExecutionCommands().get(scHost.getHostName()).get(0).getExecutionCommand();
@@ -3995,7 +3982,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
* that has client component is in maintenance state
*/
- StackId stackId = service.getDesiredStackVersion();
+ StackId stackId = service.getDesiredStackId();
ComponentInfo compInfo =
ambariMetaInfo.getService(stackId.getStackName(),
stackId.getStackVersion(), service.getName()).getClientComponent();
@@ -4136,11 +4123,58 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
actionManager,
actionRequest);
- StackId stackId = null;
- if (null != cluster) {
- stackId = cluster.getDesiredStackVersion();
+// StackId stackId = null;
+// if (null != cluster) {
+// stackId = cluster.getDesiredStackVersion();
+// }
+ RepositoryVersionEntity desiredRepositoryVersion = null;
+
+ RequestOperationLevel operationLevel = actionExecContext.getOperationLevel();
+ if (null != operationLevel && StringUtils.isNotBlank(operationLevel.getServiceName())) {
+ Service service = cluster.getService(operationLevel.getServiceName());
+ if (null != service) {
+ desiredRepositoryVersion = service.getDesiredRepositoryVersion();
+ }
+ }
+
+ if (null == desiredRepositoryVersion && CollectionUtils.isNotEmpty(actionExecContext.getResourceFilters())) {
+ Set<RepositoryVersionEntity> versions = new HashSet<>();
+
+ for (RequestResourceFilter filter : actionExecContext.getResourceFilters()) {
+ RepositoryVersionEntity repoVersion = null;
+
+ if (StringUtils.isNotBlank(filter.getServiceName())) {
+ Service service = cluster.getService(filter.getServiceName());
+
+ if (StringUtils.isNotBlank(filter.getComponentName())) {
+ ServiceComponent serviceComponent = service.getServiceComponent(filter.getComponentName());
+
+ repoVersion = serviceComponent.getDesiredRepositoryVersion();
+ }
+
+ if (null == repoVersion) {
+ repoVersion = service.getDesiredRepositoryVersion();
+ }
+ }
+
+ if (null != repoVersion) {
+ versions.add(repoVersion);
+ }
+ }
+
+ if (1 == versions.size()) {
+ desiredRepositoryVersion = versions.iterator().next();
+ } else if (versions.size() > 1) {
+ Set<String> errors = new HashSet<>();
+ for (RepositoryVersionEntity version : versions) {
+ errors.add(String.format("%s/%s", version.getStackId(), version.getVersion()));
+ }
+ throw new IllegalArgumentException(String.format("More than one repository is resolved with this Action: %s",
+ StringUtils.join(errors, ';')));
+ }
}
- ExecuteCommandJson jsons = customCommandExecutionHelper.getCommandJson(actionExecContext, cluster, stackId);
+
+ ExecuteCommandJson jsons = customCommandExecutionHelper.getCommandJson(actionExecContext, cluster, desiredRepositoryVersion);
String commandParamsForStage = jsons.getCommandParamsForStage();
Map<String, String> commandParamsStage = gson.fromJson(commandParamsForStage, new TypeToken<Map<String, String>>()
@@ -4169,7 +4203,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
commandParamsForStage = gson.toJson(commandParamsStage);
Stage stage = createNewStage(requestStageContainer.getLastStageId(), cluster, requestId, requestContext,
- commandParamsForStage, jsons.getHostParamsForStage());
+ jsons.getClusterHostInfo(), commandParamsForStage, jsons.getHostParamsForStage());
if (actionRequest.isCommand()) {
customCommandExecutionHelper.addExecutionCommandsToStage(actionExecContext, stage,
@@ -4503,7 +4537,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
if (rr.getRepositoryVersionId() != null) {
throw new AmbariException("Can't directly update repositories in repository_version, update the repository_version instead");
}
- ambariMetaInfo.updateRepoBaseURL(rr.getStackName(), rr.getStackVersion(), rr.getOsType(), rr.getRepoId(), rr.getBaseUrl());
}
}
}
@@ -4971,10 +5004,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
try {
Set<RootServiceComponentResponse> rootServiceComponents = getRootServiceComponents(request);
- for (RootServiceComponentResponse serviceComponentResponse : rootServiceComponents) {
- serviceComponentResponse.setServiceName(serviceName);
- }
-
response.addAll(rootServiceComponents);
} catch (AmbariException e) {
if (requests.size() == 1) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
index a616839..e19e121 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -19,26 +19,21 @@
package org.apache.ambari.server.controller;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
public class HostRequest {
private String hostname;
private String publicHostname;
private String clusterName; // CREATE/UPDATE
- private Map<String, String> hostAttributes; // CREATE/UPDATE
private String rackInfo;
private List<ConfigurationRequest> desiredConfigs; // UPDATE
private String maintenanceState; // UPDATE
private String blueprint;
- private String hostgroup;
- private String hostToClone;
+ private String hostGroup;
- public HostRequest(String hostname, String clusterName, Map<String, String> hostAttributes) {
+ public HostRequest(String hostname, String clusterName) {
this.hostname = hostname;
this.clusterName = clusterName;
- this.hostAttributes = hostAttributes;
}
public String getHostname() {
@@ -57,42 +52,34 @@ public class HostRequest {
this.clusterName = clusterName;
}
- public Map<String, String> getHostAttributes() {
- return hostAttributes;
- }
-
- public void setHostAttributes(Map<String, String> hostAttributes) {
- this.hostAttributes = hostAttributes;
- }
-
public String getRackInfo() {
return rackInfo;
}
-
+
public void setRackInfo(String info) {
rackInfo = info;
}
-
+
public String getPublicHostName() {
return publicHostname;
}
-
+
public void setPublicHostName(String name) {
publicHostname = name;
}
-
+
public void setDesiredConfigs(List<ConfigurationRequest> request) {
desiredConfigs = request;
}
-
+
public List<ConfigurationRequest> getDesiredConfigs() {
return desiredConfigs;
}
-
+
public void setMaintenanceState(String state) {
maintenanceState = state;
}
-
+
public String getMaintenanceState() {
return maintenanceState;
}
@@ -105,40 +92,16 @@ public class HostRequest {
return blueprint;
}
- public void setHostGroupName(String hostgroupName) {
- hostgroup = hostgroupName;
+ public void setHostGroupName(String hostGroupName) {
+ hostGroup = hostGroupName;
}
public String getHostGroupName() {
- return hostgroup;
- }
-
- public void setHostToClone(String hostname) {
- hostToClone = hostname;
- }
-
- public String getHostToClone() {
- return hostToClone;
+ return hostGroup;
}
+ @Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("{ hostname=").append(hostname).append(", clusterName=").append(clusterName);
- if (hostAttributes != null) {
- sb.append(", hostAttributes=[");
- int i = 0;
- for (Entry<String, String> attr : hostAttributes.entrySet()) {
- if (i != 0) {
- sb.append(",");
- }
- ++i;
- sb.append(attr.getKey());
- sb.append("=");
- sb.append(attr.getValue());
- }
- sb.append(']');
- }
- sb.append(" }");
- return sb.toString();
+ return "{ hostname=" + hostname + ", clusterName=" + clusterName + " }";
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
index 8032801..3218bbd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -22,14 +22,15 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import org.apache.ambari.server.agent.AgentEnv;
import org.apache.ambari.server.agent.DiskInfo;
import org.apache.ambari.server.agent.RecoveryReport;
import org.apache.ambari.server.state.AgentVersion;
-import org.apache.ambari.server.state.DesiredConfig;
import org.apache.ambari.server.state.HostConfig;
import org.apache.ambari.server.state.HostHealthStatus;
+import org.apache.ambari.server.state.HostState;
import org.apache.ambari.server.state.MaintenanceState;
public class HostResponse {
@@ -44,42 +45,28 @@ public class HostResponse {
private String ipv4;
/**
- * Host IP if ipv6 interface available
- */
- private String ipv6;
-
- /**
* Count of cores on Host
*/
- private int cpuCount;
-
+ private long cpuCount;
+
/**
* Count of physical cores on Host
*/
- private int phCpuCount;
-
-
+ private long phCpuCount;
+
/**
* Os Architecture
*/
private String osArch;
+ private String osFamily;
+
/**
* OS Type
*/
private String osType;
/**
- * OS Information
- */
- private String osInfo;
-
- /**
- * Amount of available memory for the Host
- */
- private long availableMemBytes;
-
- /**
* Amount of physical memory for the Host
*/
private long totalMemBytes;
@@ -93,7 +80,7 @@ public class HostResponse {
* Last heartbeat timestamp from the Host
*/
private long lastHeartbeatTime;
-
+
/**
* Last environment information
*/
@@ -133,18 +120,16 @@ public class HostResponse {
* Summary of node recovery
*/
private String recoverySummary = "DISABLED";
-
+
/**
* Public name.
*/
- private String publicHostname = null;
+ private String publicHostname;
/**
* Host State
*/
- private String hostState;
-
- private Map<String, DesiredConfig> desiredConfigs;
+ private HostState hostState;
/**
* Configs derived from Config groups
@@ -156,25 +141,22 @@ public class HostResponse {
*/
private String status;
- private MaintenanceState maintenanceState = null;
+ private MaintenanceState maintenanceState;
public HostResponse(String hostname, String clusterName,
- String ipv4, String ipv6, int cpuCount, int phCpuCount, String osArch, String osType,
- String osInfo, long availableMemBytes, long totalMemBytes,
+ String ipv4, int cpuCount, int phCpuCount, String osArch, String osType,
+ long totalMemBytes,
List<DiskInfo> disksInfo, long lastHeartbeatTime,
long lastRegistrationTime, String rackInfo,
Map<String, String> hostAttributes, AgentVersion agentVersion,
- HostHealthStatus healthStatus, String hostState, String status) {
+ HostHealthStatus healthStatus, HostState hostState, String status) {
this.hostname = hostname;
this.clusterName = clusterName;
this.ipv4 = ipv4;
- this.ipv6 = ipv6;
this.cpuCount = cpuCount;
this.phCpuCount = phCpuCount;
this.osArch = osArch;
this.osType = osType;
- this.osInfo = osInfo;
- this.availableMemBytes = availableMemBytes;
this.totalMemBytes = totalMemBytes;
this.disksInfo = disksInfo;
this.lastHeartbeatTime = lastHeartbeatTime;
@@ -183,37 +165,28 @@ public class HostResponse {
this.hostAttributes = hostAttributes;
this.agentVersion = agentVersion;
this.healthStatus = healthStatus;
- this.setHostState(hostState);
+ this.hostState = hostState;
this.status = status;
}
//todo: why are we passing in empty strings for host/cluster name instead of null?
public HostResponse(String hostname) {
- this(hostname, "", "", "",
- 0, 0, "", "",
- "", 0, 0, new ArrayList<DiskInfo>(),
+ this(hostname, "", "",
+ 0, 0, "", "",
+ 0, new ArrayList<DiskInfo>(),
0, 0, "",
new HashMap<String, String>(),
null, null, null, null);
}
- /**
- * @return the hostname
- */
public String getHostname() {
return hostname;
}
- /**
- * @param hostname the hostname to set
- */
public void setHostname(String hostname) {
this.hostname = hostname;
}
- /**
- * @return the clusterNames
- */
public String getClusterName() {
return clusterName;
}
@@ -225,299 +198,156 @@ public class HostResponse {
this.clusterName = clusterName;
}
- /**
- * @return the ipv4
- */
public String getIpv4() {
return ipv4;
}
- /**
- * @param ipv4 the ipv4 to set
- */
public void setIpv4(String ipv4) {
this.ipv4 = ipv4;
}
- /**
- * @return the ipv6
- */
- public String getIpv6() {
- return ipv6;
- }
-
- /**
- * @param ipv6 the ipv6 to set
- */
- public void setIpv6(String ipv6) {
- this.ipv6 = ipv6;
- }
-
- /**
- * @return the cpuCount
- */
- public int getCpuCount() {
+ public long getCpuCount() {
return cpuCount;
}
- /**
- * @param cpuCount the cpuCount to set
- */
- public void setCpuCount(int cpuCount) {
+ public void setCpuCount(long cpuCount) {
this.cpuCount = cpuCount;
}
- /**
- * @return the phCpuCount
- */
- public int getPhCpuCount() {
+ public long getPhCpuCount() {
return phCpuCount;
}
- /**
- * @param phCpuCount the physical cpu count to set
- */
- public void setPhCpuCount(int phCpuCount) {
+ public void setPhCpuCount(long phCpuCount) {
this.phCpuCount = phCpuCount;
}
-
-
- /**
- * @return the osArch
- */
public String getOsArch() {
return osArch;
}
- /**
- * @param osArch the osArch to set
- */
public void setOsArch(String osArch) {
this.osArch = osArch;
}
- /**
- * @return the osType
- */
- public String getOsType() {
- return osType;
- }
-
- /**
- * @param osType the osType to set
- */
- public void setOsType(String osType) {
- this.osType = osType;
+ public String getOsFamily() {
+ return osFamily;
}
- /**
- * @return the osInfo
- */
- public String getOsInfo() {
- return osInfo;
+ public void setOsFamily(String osFamily) {
+ this.osFamily = osFamily;
}
- /**
- * @param osInfo the osInfo to set
- */
- public void setOsInfo(String osInfo) {
- this.osInfo = osInfo;
- }
-
- /**
- * @return the availableMemBytes
- */
- public long getAvailableMemBytes() {
- return availableMemBytes;
+ public String getOsType() {
+ return osType;
}
- /**
- * @param availableMemBytes the availableMemBytes to set
- */
- public void setAvailableMemBytes(long availableMemBytes) {
- this.availableMemBytes = availableMemBytes;
+ public void setOsType(String osType) {
+ this.osType = osType;
}
- /**
- * @return the totalMemBytes
- */
public long getTotalMemBytes() {
return totalMemBytes;
}
- /**
- * @param totalMemBytes the totalMemBytes to set
- */
public void setTotalMemBytes(long totalMemBytes) {
this.totalMemBytes = totalMemBytes;
}
- /**
- * @return the disksInfo
- */
public List<DiskInfo> getDisksInfo() {
return disksInfo;
}
- /**
- * @param disksInfo the disksInfo to set
- */
public void setDisksInfo(List<DiskInfo> disksInfo) {
this.disksInfo = disksInfo;
}
- /**
- * @return the lastHeartbeatTime
- */
public long getLastHeartbeatTime() {
return lastHeartbeatTime;
}
- /**
- * @param lastHeartbeatTime the lastHeartbeatTime to set
- */
public void setLastHeartbeatTime(long lastHeartbeatTime) {
this.lastHeartbeatTime = lastHeartbeatTime;
}
- /**
- * @return the lastRegistrationTime
- */
public long getLastRegistrationTime() {
return lastRegistrationTime;
}
- /**
- * @param lastRegistrationTime the lastRegistrationTime to set
- */
public void setLastRegistrationTime(long lastRegistrationTime) {
this.lastRegistrationTime = lastRegistrationTime;
}
- /**
- * @return the rackInfo
- */
public String getRackInfo() {
return rackInfo;
}
- /**
- * @param rackInfo the rackInfo to set
- */
public void setRackInfo(String rackInfo) {
this.rackInfo = rackInfo;
}
- /**
- * @return the hostAttributes
- */
public Map<String, String> getHostAttributes() {
return hostAttributes;
}
- /**
- * @param hostAttributes the hostAttributes to set
- */
public void setHostAttributes(Map<String, String> hostAttributes) {
this.hostAttributes = hostAttributes;
}
- /**
- * @return the agentVersion
- */
public AgentVersion getAgentVersion() {
return agentVersion;
}
- /**
- * @param agentVersion the agentVersion to set
- */
public void setAgentVersion(AgentVersion agentVersion) {
this.agentVersion = agentVersion;
}
- /**
- * @return the healthStatus
- */
- public HostHealthStatus getHealthStatus() {
- return healthStatus;
+ public String getHealthReport() {
+ return healthStatus.getHealthReport();
}
- /**
- * @param healthStatus the healthStatus to set
- */
public void setHealthStatus(HostHealthStatus healthStatus) {
this.healthStatus = healthStatus;
}
-
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- HostResponse that = (HostResponse) o;
-
- if (hostname != null ?
- !hostname.equals(that.hostname) : that.hostname != null) {
- return false;
- }
+ HostResponse other = (HostResponse) o;
- return true;
+ return Objects.equals(hostname, other.hostname);
}
@Override
public int hashCode() {
- int result = hostname != null ? hostname.hashCode() : 0;
- return result;
+ return Objects.hashCode(hostname);
}
public String getPublicHostName() {
return publicHostname;
}
-
+
public void setPublicHostName(String name) {
publicHostname = name;
}
- /**
- * @return the hostState
- */
- public String getHostState() {
+ public HostState getHostState() {
return hostState;
}
- /**
- * @param hostState the hostState to set
- */
- public void setHostState(String hostState) {
+ public void setHostState(HostState hostState) {
this.hostState = hostState;
}
-
public AgentEnv getLastAgentEnv() {
return lastAgentEnv;
}
-
- /**
- * @param agentEnv
- */
+
public void setLastAgentEnv(AgentEnv agentEnv) {
lastAgentEnv = agentEnv;
}
-
- /**
- * @param desired
- */
- public void setDesiredConfigs(Map<String, DesiredConfig> desired) {
- desiredConfigs = desired;
- }
-
- public Map<String, DesiredConfig> getDesiredConfigs() {
- return desiredConfigs;
- }
public Map<String, HostConfig> getDesiredHostConfigs() {
return desiredHostConfigs;
@@ -535,23 +365,16 @@ public class HostResponse {
this.status = status;
}
- /**
- * @param state the maintenance state
- */
public void setMaintenanceState(MaintenanceState state) {
maintenanceState = state;
}
-
- /**
- * @return the maintenance state
- */
+
public MaintenanceState getMaintenanceState() {
return maintenanceState;
}
/**
* Get the recovery summary for the host
- * @return
*/
public String getRecoverySummary() {
return recoverySummary;
@@ -559,7 +382,6 @@ public class HostResponse {
/**
* Set the recovery summary for the host
- * @return
*/
public void setRecoverySummary(String recoverySummary) {
this.recoverySummary = recoverySummary;
@@ -567,7 +389,6 @@ public class HostResponse {
/**
* Get the detailed recovery report
- * @return
*/
public RecoveryReport getRecoveryReport() {
return recoveryReport;
@@ -575,9 +396,9 @@ public class HostResponse {
/**
* Set the detailed recovery report
- * @param recoveryReport
*/
public void setRecoveryReport(RecoveryReport recoveryReport) {
this.recoveryReport = recoveryReport;
}
+
}