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:53 UTC
[35/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/KerberosHelperImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
index 9c65aa6..3097a07 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
@@ -299,8 +299,8 @@ public class KerberosHelperImpl implements KerberosHelper {
public void configureServices(Cluster cluster, Map<String, Collection<String>> serviceFilter)
throws AmbariException, KerberosInvalidConfigurationException {
Map<String, Map<String, String>> existingConfigurations = calculateExistingConfigurations(cluster, null);
- Map<String, Set<String>> installedServices = new HashMap<String, Set<String>>();
- Set<String> previouslyExistingServices = new HashSet<String>();
+ Map<String, Set<String>> installedServices = new HashMap<>();
+ Set<String> previouslyExistingServices = new HashSet<>();
// Calculate the map of installed services to installed components
Map<String, Service> clusterServices = cluster.getServices();
@@ -308,7 +308,7 @@ public class KerberosHelperImpl implements KerberosHelper {
for (Service clusterService : clusterServices.values()) {
Set<String> installedComponents = installedServices.get(clusterService.getName());
if (installedComponents == null) {
- installedComponents = new HashSet<String>();
+ installedComponents = new HashSet<>();
installedServices.put(clusterService.getName(), installedComponents);
}
@@ -338,7 +338,7 @@ public class KerberosHelperImpl implements KerberosHelper {
existingConfigurations, installedServices, serviceFilter, previouslyExistingServices, true, true);
for (Map.Entry<String, Map<String, String>> entry : updates.entrySet()) {
- configHelper.updateConfigType(cluster, ambariManagementController, entry.getKey(), entry.getValue(), null,
+ configHelper.updateConfigType(cluster, cluster.getDesiredStackVersion(), ambariManagementController, entry.getKey(), entry.getValue(), null,
ambariManagementController.getAuthName(), "Enabling Kerberos for added components");
}
}
@@ -353,7 +353,7 @@ public class KerberosHelperImpl implements KerberosHelper {
boolean applyStackAdvisorUpdates)
throws KerberosInvalidConfigurationException, AmbariException {
- Map<String, Map<String, String>> kerberosConfigurations = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> kerberosConfigurations = new HashMap<>();
KerberosDetails kerberosDetails = getKerberosDetails(cluster, null);
KerberosDescriptor kerberosDescriptor = getKerberosDescriptor(cluster);
@@ -361,17 +361,17 @@ public class KerberosHelperImpl implements KerberosHelper {
Map<String, Map<String, String>> configurations = addAdditionalConfigurations(cluster,
deepCopy(existingConfigurations), null, kerberosDescriptorProperties);
- Map<String, Set<String>> propertiesToIgnore = new HashMap<String, Set<String>>();
+ Map<String, Set<String>> propertiesToIgnore = new HashMap<>();
// If Ambari is managing it own identities then add AMBARI to the set of installed servcie so
// that its Kerberos descriptor entries will be included.
if (createAmbariIdentities(existingConfigurations.get("kerberos-env"))) {
- installedServices = new HashMap<String, Set<String>>(installedServices);
+ installedServices = new HashMap<>(installedServices);
installedServices.put("AMBARI", Collections.singleton("AMBARI_SERVER"));
}
// Create the context to use for filtering Kerberos Identities based on the state of the cluster
- Map<String, Object> filterContext = new HashMap<String, Object>();
+ Map<String, Object> filterContext = new HashMap<>();
filterContext.put("configurations", configurations);
filterContext.put("services", installedServices.keySet());
@@ -459,7 +459,7 @@ public class KerberosHelperImpl implements KerberosHelper {
if ((properties != null) && !properties.isEmpty()) {
Set<String> propertyNames = propertiesToIgnore.get(configType);
if (propertyNames == null) {
- propertyNames = new HashSet<String>();
+ propertyNames = new HashSet<>();
propertiesToIgnore.put(configType, propertyNames);
}
propertyNames.addAll(properties.keySet());
@@ -479,7 +479,7 @@ public class KerberosHelperImpl implements KerberosHelper {
StackId stackVersion = cluster.getCurrentStackVersion();
- List<String> hostNames = new ArrayList<String>();
+ List<String> hostNames = new ArrayList<>();
Collection<Host> hosts = cluster.getHosts();
if (hosts != null) {
@@ -493,10 +493,10 @@ public class KerberosHelperImpl implements KerberosHelper {
// This could happen when enabling Kerberos while installing a cluster via Blueprints due to the
// way hosts are discovered during the install process.
if (!hostNames.isEmpty()) {
- Map<String, Map<String, Map<String, String>>> requestConfigurations = new HashMap<String, Map<String, Map<String, String>>>();
+ Map<String, Map<String, Map<String, String>>> requestConfigurations = new HashMap<>();
if (existingConfigurations != null) {
for (Map.Entry<String, Map<String, String>> configuration : existingConfigurations.entrySet()) {
- Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> properties = new HashMap<>();
String configType = configuration.getKey();
Map<String, String> configurationProperties = configuration.getValue();
@@ -505,7 +505,7 @@ public class KerberosHelperImpl implements KerberosHelper {
}
if ("cluster-env".equals(configType)) {
- configurationProperties = new HashMap<String, String>(configurationProperties);
+ configurationProperties = new HashMap<>(configurationProperties);
configurationProperties.put("security_enabled", (kerberosEnabled) ? "true" : "false");
}
@@ -523,15 +523,15 @@ public class KerberosHelperImpl implements KerberosHelper {
Map<String, Map<String, String>> requestConfiguration = requestConfigurations.get(configType);
if (requestConfiguration == null) {
- requestConfiguration = new HashMap<String, Map<String, String>>();
+ requestConfiguration = new HashMap<>();
requestConfigurations.put(configType, requestConfiguration);
}
Map<String, String> requestConfigurationProperties = requestConfiguration.get("properties");
if (requestConfigurationProperties == null) {
- requestConfigurationProperties = new HashMap<String, String>();
+ requestConfigurationProperties = new HashMap<>();
} else {
- requestConfigurationProperties = new HashMap<String, String>(requestConfigurationProperties);
+ requestConfigurationProperties = new HashMap<>(requestConfigurationProperties);
}
requestConfigurationProperties.putAll(configurationProperties);
@@ -541,7 +541,7 @@ public class KerberosHelperImpl implements KerberosHelper {
StackAdvisorRequest request = StackAdvisorRequest.StackAdvisorRequestBuilder
.forStack(stackVersion.getStackName(), stackVersion.getStackVersion())
- .forServices(new ArrayList<String>(services))
+ .forServices(new ArrayList<>(services))
.forHosts(hostNames)
.withComponentHostsMap(cluster.getServiceComponentHostMap(null, services))
.withConfigurations(requestConfigurations)
@@ -606,7 +606,7 @@ public class KerberosHelperImpl implements KerberosHelper {
configType, propertyName, recommendedValue);
if(kerberosConfigProperties == null) {
- kerberosConfigProperties = new HashMap<String, String>();
+ kerberosConfigProperties = new HashMap<>();
kerberosConfigurations.put(configType, kerberosConfigProperties);
}
@@ -657,13 +657,13 @@ public class KerberosHelperImpl implements KerberosHelper {
if (propertiesToRemove != null) {
Set<String> properties = propertiesToRemove.get(configType);
if (properties == null) {
- properties = new HashSet<String>();
+ properties = new HashSet<>();
propertiesToRemove.put(configType, properties);
}
properties.add(propertyName);
} else {
if (kerberosConfigProperties == null) {
- kerberosConfigProperties = new HashMap<String, String>();
+ kerberosConfigProperties = new HashMap<>();
kerberosConfigurations.put(configType, kerberosConfigProperties);
}
kerberosConfigProperties.put(propertyName, "");
@@ -701,7 +701,7 @@ public class KerberosHelperImpl implements KerberosHelper {
}
// Create the context to use for filtering Kerberos Identities based on the state of the cluster
- Map<String, Object> filterContext = new HashMap<String, Object>();
+ Map<String, Object> filterContext = new HashMap<>();
filterContext.put("configurations", configurations);
filterContext.put("services", services);
@@ -920,7 +920,7 @@ public class KerberosHelperImpl implements KerberosHelper {
if (kerberosDescriptor != null && processAuthToLocalRules) {
Set<String> authToLocalProperties;
- Set<String> authToLocalPropertiesToSet = new HashSet<String>();
+ Set<String> authToLocalPropertiesToSet = new HashSet<>();
// a flag to be used by the AuthToLocalBuilder marking whether the default realm rule should contain the //L option, indicating username case insensitive behaviour
// the 'kerberos-env' structure is expected to be available here as it was previously validated
@@ -930,7 +930,7 @@ public class KerberosHelperImpl implements KerberosHelper {
String additionalRealms = kerberosDescriptor.getProperty("additional_realms");
// Create the context to use for filtering Kerberos Identities based on the state of the cluster
- Map<String, Object> filterContext = new HashMap<String, Object>();
+ Map<String, Object> filterContext = new HashMap<>();
filterContext.put("configurations", existingConfigurations);
filterContext.put("services", installedServices.keySet());
@@ -1009,7 +1009,7 @@ public class KerberosHelperImpl implements KerberosHelper {
if (kerberosConfiguration != null) {
builder.addRules(kerberosConfiguration.get(propertyName));
} else {
- kerberosConfiguration = new HashMap<String, String>();
+ kerberosConfiguration = new HashMap<>();
kerberosConfigurations.put(configType, kerberosConfiguration);
}
@@ -1029,7 +1029,7 @@ public class KerberosHelperImpl implements KerberosHelper {
Collection<String> hostFilter, Collection<String> identityFilter,
Command<Boolean, ServiceComponentHost> shouldProcessCommand)
throws AmbariException {
- List<ServiceComponentHost> serviceComponentHostsToProcess = new ArrayList<ServiceComponentHost>();
+ List<ServiceComponentHost> serviceComponentHostsToProcess = new ArrayList<>();
Map<String, Service> services = cluster.getServices();
if ((services != null) && !services.isEmpty()) {
@@ -1083,7 +1083,7 @@ public class KerberosHelperImpl implements KerberosHelper {
@Override
public Set<String> getHostsWithValidKerberosClient(Cluster cluster)
throws AmbariException {
- Set<String> hostsWithValidKerberosClient = new HashSet<String>();
+ Set<String> hostsWithValidKerberosClient = new HashSet<>();
List<ServiceComponentHost> schKerberosClients = cluster.getServiceComponentHosts(Service.Type.KERBEROS.name(), Role.KERBEROS_CLIENT.name());
if (schKerberosClients != null) {
@@ -1130,7 +1130,7 @@ public class KerberosHelperImpl implements KerberosHelper {
}
if (evaluateWhenClauses) {
- Set<String> services = new HashSet<String>(cluster.getServices().keySet());
+ Set<String> services = new HashSet<>(cluster.getServices().keySet());
if(additionalServices != null) {
services.addAll(additionalServices);
@@ -1138,7 +1138,7 @@ public class KerberosHelperImpl implements KerberosHelper {
// Build the context needed to filter out Kerberos identities...
// This includes the current set of configurations for the cluster and the set of installed services
- Map<String, Object> context = new HashMap<String, Object>();
+ Map<String, Object> context = new HashMap<>();
context.put("configurations", calculateConfigurations(cluster, null, kerberosDescriptor.getProperties()));
context.put("services", services);
@@ -1183,7 +1183,7 @@ public class KerberosHelperImpl implements KerberosHelper {
if ((updates != null) && !updates.isEmpty()) {
if (configurations == null) {
- configurations = new HashMap<String, Map<String, String>>();
+ configurations = new HashMap<>();
}
for (Map.Entry<String, KerberosConfigurationDescriptor> entry : updates.entrySet()) {
@@ -1309,7 +1309,7 @@ public class KerberosHelperImpl implements KerberosHelper {
throw new AmbariException(String.format("The cluster object for the cluster name %s is not available", clusterName));
}
- Map<String, Collection<KerberosIdentityDescriptor>> activeIdentities = new HashMap<String, Collection<KerberosIdentityDescriptor>>();
+ Map<String, Collection<KerberosIdentityDescriptor>> activeIdentities = new HashMap<>();
// Only calculate the active identities if the kerberos-env configurtaion is available. Else
// important information like the realm will be missing (kerberos-env/realm)
@@ -1356,12 +1356,12 @@ public class KerberosHelperImpl implements KerberosHelper {
kerberosDescriptorProperties);
// Create the context to use for filtering Kerberos Identities based on the state of the cluster
- Map<String, Object> filterContext = new HashMap<String, Object>();
+ Map<String, Object> filterContext = new HashMap<>();
filterContext.put("configurations", configurations);
filterContext.put("services", existingServices);
- Map<String, KerberosIdentityDescriptor> hostActiveIdentities = new HashMap<String, KerberosIdentityDescriptor>();
+ Map<String, KerberosIdentityDescriptor> hostActiveIdentities = new HashMap<>();
List<KerberosIdentityDescriptor> identities = getActiveIdentities(cluster, hostname,
serviceName, componentName, kerberosDescriptor, filterContext);
@@ -1451,7 +1451,7 @@ public class KerberosHelperImpl implements KerberosHelper {
@Override
public List<KerberosIdentityDescriptor> getAmbariServerIdentities(KerberosDescriptor kerberosDescriptor) throws AmbariException {
- List<KerberosIdentityDescriptor> ambariIdentities = new ArrayList<KerberosIdentityDescriptor>();
+ List<KerberosIdentityDescriptor> ambariIdentities = new ArrayList<>();
KerberosServiceDescriptor ambariKerberosDescriptor = kerberosDescriptor.getService("AMBARI");
if (ambariKerberosDescriptor != null) {
@@ -1754,7 +1754,7 @@ public class KerberosHelperImpl implements KerberosHelper {
// Gather data needed to create stages and tasks...
Map<String, Set<String>> clusterHostInfo = StageUtils.getClusterHostInfo(cluster);
String clusterHostInfoJson = StageUtils.getGson().toJson(clusterHostInfo);
- Map<String, String> hostParams = customCommandExecutionHelper.createDefaultHostParams(cluster);
+ Map<String, String> hostParams = customCommandExecutionHelper.createDefaultHostParams(cluster, cluster.getDesiredStackVersion());
String hostParamsJson = StageUtils.getGson().toJson(hostParams);
String ambariServerHostname = StageUtils.getHostName();
ServiceComponentHostServerActionEvent event = new ServiceComponentHostServerActionEvent(
@@ -1844,7 +1844,7 @@ public class KerberosHelperImpl implements KerberosHelper {
throw new AmbariException("The properties map must not be null. It is needed to store data related to the service check identity");
}
- List<ServiceComponentHost> serviceComponentHostsToProcess = new ArrayList<ServiceComponentHost>();
+ List<ServiceComponentHost> serviceComponentHostsToProcess = new ArrayList<>();
KerberosDescriptor kerberosDescriptor = getKerberosDescriptor(cluster);
KerberosIdentityDataFileWriter kerberosIdentityDataFileWriter = null;
@@ -1954,7 +1954,7 @@ public class KerberosHelperImpl implements KerberosHelper {
// Gather data needed to create stages and tasks...
Map<String, Set<String>> clusterHostInfo = StageUtils.getClusterHostInfo(cluster);
String clusterHostInfoJson = StageUtils.getGson().toJson(clusterHostInfo);
- Map<String, String> hostParams = customCommandExecutionHelper.createDefaultHostParams(cluster);
+ Map<String, String> hostParams = customCommandExecutionHelper.createDefaultHostParams(cluster, cluster.getDesiredStackVersion());
String hostParamsJson = StageUtils.getGson().toJson(hostParams);
String ambariServerHostname = StageUtils.getHostName();
ServiceComponentHostServerActionEvent event = new ServiceComponentHostServerActionEvent(
@@ -2194,7 +2194,7 @@ public class KerberosHelperImpl implements KerberosHelper {
if (updates != null) {
Map<String, String> existingProperties = configurations.get(type);
if (existingProperties == null) {
- existingProperties = new HashMap<String, String>();
+ existingProperties = new HashMap<>();
configurations.put(type, existingProperties);
}
@@ -2311,8 +2311,8 @@ public class KerberosHelperImpl implements KerberosHelper {
*/
private List<String> createUniqueHostList(Collection<ServiceComponentHost> serviceComponentHosts, Set<HostState> allowedStates)
throws AmbariException {
- Set<String> hostNames = new HashSet<String>();
- Set<String> visitedHostNames = new HashSet<String>();
+ Set<String> hostNames = new HashSet<>();
+ Set<String> visitedHostNames = new HashSet<>();
if (serviceComponentHosts != null) {
for (ServiceComponentHost sch : serviceComponentHosts) {
@@ -2335,7 +2335,7 @@ public class KerberosHelperImpl implements KerberosHelper {
}
}
- return new ArrayList<String>(hostNames);
+ return new ArrayList<>(hostNames);
}
@Override
@@ -2373,7 +2373,7 @@ public class KerberosHelperImpl implements KerberosHelper {
@Override
public Map<String, Map<String, String>> getIdentityConfigurations(List<KerberosIdentityDescriptor> identityDescriptors) {
- Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> map = new HashMap<>();
if (identityDescriptors != null) {
for (KerberosIdentityDescriptor identityDescriptor : identityDescriptors) {
@@ -2410,7 +2410,7 @@ public class KerberosHelperImpl implements KerberosHelper {
Map<String, String> properties = map.get(type);
if (properties == null) {
- properties = new HashMap<String, String>();
+ properties = new HashMap<>();
map.put(type, properties);
}
@@ -2442,7 +2442,7 @@ public class KerberosHelperImpl implements KerberosHelper {
Map<String, Object> filterContext)
throws AmbariException {
- List<KerberosIdentityDescriptor> identities = new ArrayList<KerberosIdentityDescriptor>();
+ List<KerberosIdentityDescriptor> identities = new ArrayList<>();
List<ServiceComponentHost> serviceComponentHosts = cluster.getServiceComponentHosts(hostname);
@@ -2490,7 +2490,7 @@ public class KerberosHelperImpl implements KerberosHelper {
// Configurations from the tag is always expanded and then over-written by the actual
// global:version1:{a1:A1,b1:B1,d1:D1} + global:{a1:A2,c1:C1,DELETED_d1:x} ==>
// global:{a1:A2,b1:B1,c1:C1}
- Map<String, Map<String, String>> configurations = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> configurations = new HashMap<>();
Map<String, Map<String, String>> configurationTags = ambariManagementController.findConfigurationTagsWithOverrides(cluster, hostname);
Map<String, Map<String, String>> configProperties = configHelper.getEffectiveConfigProperties(cluster, configurationTags);
@@ -2503,7 +2503,7 @@ public class KerberosHelperImpl implements KerberosHelper {
Map<String, String> configuration = configurations.get(type);
if (configuration == null) {
- configuration = new HashMap<String, String>(allLevelMergedConfig);
+ configuration = new HashMap<>(allLevelMergedConfig);
} else {
Map<String, String> mergedConfig = configHelper.getMergedConfig(allLevelMergedConfig, configuration);
configuration.clear();
@@ -2536,7 +2536,7 @@ public class KerberosHelperImpl implements KerberosHelper {
// and will also contain a value for the current host
Map<String, String> generalProperties = configurations.get("");
if (generalProperties == null) {
- generalProperties = new HashMap<String, String>();
+ generalProperties = new HashMap<>();
configurations.put("", generalProperties);
}
@@ -2563,7 +2563,7 @@ public class KerberosHelperImpl implements KerberosHelper {
Map<String, Set<String>> clusterHostInfo = StageUtils.getClusterHostInfo(cluster);
if (clusterHostInfo != null) {
- Map<String, String> componentHosts = new HashMap<String, String>();
+ Map<String, String> componentHosts = new HashMap<>();
clusterHostInfo = StageUtils.substituteHostIndexes(clusterHostInfo);
@@ -2588,11 +2588,11 @@ public class KerberosHelperImpl implements KerberosHelper {
if (map == null) {
return null;
} else {
- Map<String, Map<String, String>> copy = new HashMap<String, Map<String, String>>();
+ Map<String, Map<String, String>> copy = new HashMap<>();
for (Map.Entry<String, Map<String, String>> entry : map.entrySet()) {
Map<String, String> innerMap = entry.getValue();
- copy.put(entry.getKey(), (innerMap == null) ? null : new HashMap<String, String>(innerMap));
+ copy.put(entry.getKey(), (innerMap == null) ? null : new HashMap<>(innerMap));
}
return copy;
@@ -2607,7 +2607,7 @@ public class KerberosHelperImpl implements KerberosHelper {
*/
private KerberosDescriptor getKerberosDescriptorUpdates(Cluster cluster) throws AmbariException {
// find instance using name and foreign keys
- TreeMap<String, String> foreignKeys = new TreeMap<String, String>();
+ TreeMap<String, String> foreignKeys = new TreeMap<>();
foreignKeys.put("cluster", String.valueOf(cluster.getClusterId()));
ArtifactEntity entity = artifactDAO.findByNameAndForeignKeys("kerberos_descriptor", foreignKeys);
@@ -2660,7 +2660,7 @@ public class KerberosHelperImpl implements KerberosHelper {
for (KerberosIdentityDescriptor identity : identities) {
if (!identity.shouldInclude(context)) {
if (set == null) {
- set = new HashSet<String>();
+ set = new HashSet<>();
identitiesToRemove.put(currentPath, set);
}
@@ -2959,12 +2959,12 @@ public class KerberosHelperImpl implements KerberosHelper {
hostParamsJson);
Collection<ServiceComponentHost> filteredComponents = filterServiceComponentHostsForHosts(
- new ArrayList<ServiceComponentHost>(serviceComponentHosts), hostsWithValidKerberosClient);
+ new ArrayList<>(serviceComponentHosts), hostsWithValidKerberosClient);
if (!filteredComponents.isEmpty()) {
List<String> hostsToUpdate = createUniqueHostList(filteredComponents, Collections.singleton(HostState.HEALTHY));
- Map<String, String> requestParams = new HashMap<String, String>();
- List<RequestResourceFilter> requestResourceFilters = new ArrayList<RequestResourceFilter>();
+ Map<String, String> requestParams = new HashMap<>();
+ List<RequestResourceFilter> requestResourceFilters = new ArrayList<>();
RequestResourceFilter reqResFilter = new RequestResourceFilter(Service.Type.KERBEROS.name(), Role.KERBEROS_CLIENT.name(), hostsToUpdate);
requestResourceFilters.add(reqResFilter);
@@ -3100,14 +3100,14 @@ public class KerberosHelperImpl implements KerberosHelper {
hostParamsJson);
Collection<ServiceComponentHost> filteredComponents = filterServiceComponentHostsForHosts(
- new ArrayList<ServiceComponentHost>(serviceComponentHosts), hostsWithValidKerberosClient);
+ new ArrayList<>(serviceComponentHosts), hostsWithValidKerberosClient);
if (!filteredComponents.isEmpty()) {
List<String> hostsToUpdate = createUniqueHostList(filteredComponents, Collections.singleton(HostState.HEALTHY));
if (!hostsToUpdate.isEmpty()) {
- Map<String, String> requestParams = new HashMap<String, String>();
- List<RequestResourceFilter> requestResourceFilters = new ArrayList<RequestResourceFilter>();
+ Map<String, String> requestParams = new HashMap<>();
+ List<RequestResourceFilter> requestResourceFilters = new ArrayList<>();
RequestResourceFilter reqResFilter = new RequestResourceFilter("KERBEROS", "KERBEROS_CLIENT", hostsToUpdate);
requestResourceFilters.add(reqResFilter);
@@ -3160,7 +3160,7 @@ public class KerberosHelperImpl implements KerberosHelper {
throws AmbariException {
// Add the finalize stage...
- Map<String, String> commandParameters = new HashMap<String, String>();
+ Map<String, String> commandParameters = new HashMap<>();
commandParameters.put(KerberosServerAction.DEFAULT_REALM, kerberosDetails.getDefaultRealm());
commandParameters.put(KerberosServerAction.KDC_TYPE, kerberosDetails.getKdcType().name());
commandParameters.put(KerberosServerAction.AUTHENTICATED_USER_NAME, ambariManagementController.getAuthName());
@@ -3274,7 +3274,7 @@ public class KerberosHelperImpl implements KerberosHelper {
actionManager);
}
- Map<String, String> commandParameters = new HashMap<String, String>();
+ Map<String, String> commandParameters = new HashMap<>();
commandParameters.put(KerberosServerAction.AUTHENTICATED_USER_NAME, ambariManagementController.getAuthName());
commandParameters.put(KerberosServerAction.UPDATE_CONFIGURATION_NOTE, "Enabling Kerberos");
commandParameters.put(KerberosServerAction.UPDATE_CONFIGURATIONS, "true");
@@ -3392,7 +3392,7 @@ public class KerberosHelperImpl implements KerberosHelper {
actionManager);
}
- Map<String, String> commandParameters = new HashMap<String, String>();
+ Map<String, String> commandParameters = new HashMap<>();
commandParameters.put(KerberosServerAction.AUTHENTICATED_USER_NAME, ambariManagementController.getAuthName());
commandParameters.put(KerberosServerAction.UPDATE_CONFIGURATION_NOTE, "Disabling Kerberos");
commandParameters.put(KerberosServerAction.UPDATE_CONFIGURATIONS, "true");
@@ -3546,7 +3546,7 @@ public class KerberosHelperImpl implements KerberosHelper {
}
- Map<String, String> commandParameters = new HashMap<String, String>();
+ Map<String, String> commandParameters = new HashMap<>();
commandParameters.put(KerberosServerAction.AUTHENTICATED_USER_NAME, ambariManagementController.getAuthName());
commandParameters.put(KerberosServerAction.DEFAULT_REALM, kerberosDetails.getDefaultRealm());
if (dataDirectory != null) {
@@ -3669,7 +3669,7 @@ public class KerberosHelperImpl implements KerberosHelper {
// 2) delete principals
// 3) delete keytab files
- Map<String, String> commandParameters = new HashMap<String, String>();
+ Map<String, String> commandParameters = new HashMap<>();
commandParameters.put(KerberosServerAction.AUTHENTICATED_USER_NAME, ambariManagementController.getAuthName());
commandParameters.put(KerberosServerAction.DEFAULT_REALM, kerberosDetails.getDefaultRealm());
if (dataDirectory != null) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/ambari-server/src/main/java/org/apache/ambari/server/controller/PrereqCheckRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/PrereqCheckRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/PrereqCheckRequest.java
index 8584ef6..f80c16a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/PrereqCheckRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/PrereqCheckRequest.java
@@ -38,8 +38,8 @@ public class PrereqCheckRequest {
private UpgradeType m_upgradeType;
- private Map<CheckDescription, PrereqCheckStatus> m_results =
- new HashMap<CheckDescription, PrereqCheckStatus>();
+ private Map<CheckDescription, PrereqCheckStatus> m_results = new HashMap<>();
+ private boolean m_revert = false;
public PrereqCheckRequest(String clusterName, UpgradeType upgradeType) {
@@ -132,11 +132,30 @@ public class PrereqCheckRequest {
* Gets the prerequisite check config
* @return the prereqCheckConfig
*/
- public PrerequisiteCheckConfig getPrerequisiteCheckConfig() { return m_prereqCheckConfig; }
+ public PrerequisiteCheckConfig getPrerequisiteCheckConfig() {
+ return m_prereqCheckConfig;
+ }
/**
* Sets the prerequisite check config obtained from the upgrade pack
* @param prereqCheckConfig The prereqCheckConfig
*/
- public void setPrerequisiteCheckConfig(PrerequisiteCheckConfig prereqCheckConfig) { m_prereqCheckConfig = prereqCheckConfig;}
+ public void setPrerequisiteCheckConfig(PrerequisiteCheckConfig prereqCheckConfig) {
+ m_prereqCheckConfig = prereqCheckConfig;
+ }
+
+ /**
+ * @param revert
+ * {@code true} if the check is for a patch reversion
+ */
+ public void setRevert(boolean revert) {
+ m_revert = revert;
+ }
+
+ /**
+ * @return if the check is for a patch reversion
+ */
+ public boolean isRevert() {
+ return m_revert;
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceComponentResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceComponentResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceComponentResponse.java
index 4845c78..f9274be 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceComponentResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceComponentResponse.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
@@ -15,34 +15,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.ambari.server.controller;
import java.util.Map;
+import java.util.Objects;
public class RootServiceComponentResponse {
- private String serviceName;
- private String componentName;
- private Map<String, String> properties;
- private String componentVersion;
+ private final String serviceName;
+ private final String componentName;
+ private final Map<String, String> properties;
+ private final String componentVersion;
+ private final long serverClock = System.currentTimeMillis() / 1000L;
- public RootServiceComponentResponse(String componentName, String componentVersion, Map<String, String> properties) {
+ public RootServiceComponentResponse(String serviceName, String componentName, String componentVersion, Map<String, String> properties) {
+ this.serviceName = serviceName;
this.componentName = componentName;
- this.setComponentVersion(componentVersion);
- this.setProperties(properties);
-
+ this.componentVersion = componentVersion;
+ this.properties = properties;
}
public String getServiceName() {
return serviceName;
}
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
public String getComponentName() {
return componentName;
}
@@ -51,35 +47,30 @@ public class RootServiceComponentResponse {
return properties;
}
- public void setProperties(Map<String, String> properties) {
- this.properties = properties;
- }
-
public String getComponentVersion() {
return componentVersion;
}
- public void setComponentVersion(String componentVersion) {
- this.componentVersion = componentVersion;
+ public long getServerClock() {
+ return serverClock;
}
-
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- RootServiceComponentResponse that = (RootServiceComponentResponse) o;
-
- return !(componentName != null ? !componentName.equals(that.componentName) : that.componentName != null) &&
- !(componentVersion != null ? !componentVersion.equals(that.componentVersion) : that.componentVersion != null) &&
- !(properties != null ? !properties.equals(that.properties) : that.properties != null);
+ RootServiceComponentResponse other = (RootServiceComponentResponse) o;
+ return Objects.equals(serviceName, other.serviceName) &&
+ Objects.equals(componentName, other.componentName) &&
+ Objects.equals(componentVersion, other.componentVersion) &&
+ Objects.equals(properties, other.properties);
}
@Override
public int hashCode() {
- int result = 31 + (componentName != null ? componentName.hashCode() : 0);
- result += (componentVersion != null ? componentVersion.hashCode() : 0);
- return result;
+ return Objects.hash(serviceName, componentName, componentVersion);
}
+
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceHostComponentResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceHostComponentResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceHostComponentResponse.java
index 6cbc30c..725c2aa 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceHostComponentResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceHostComponentResponse.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,20 +19,21 @@
package org.apache.ambari.server.controller;
import java.util.Map;
+import java.util.Objects;
public class RootServiceHostComponentResponse {
- private String serviceName;
- private String hostName;
- private String componentName;
- private String componentState;
- private String componentVersion;
- private Map<String, String> properties;
+ private final String serviceName;
+ private final String hostName;
+ private final String componentName;
+ private final String componentState;
+ private final String componentVersion;
+ private final Map<String, String> properties;
-
- public RootServiceHostComponentResponse(String hostName, String componentName, String componentState,
+ public RootServiceHostComponentResponse(String serviceName, String hostName, String componentName, String componentState,
String componentVersion,
Map<String, String> properties) {
+ this.serviceName = serviceName;
this.hostName = hostName;
this.componentName = componentName;
this.componentState = componentState;
@@ -44,10 +45,6 @@ public class RootServiceHostComponentResponse {
return serviceName;
}
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
public String getHostName() {
return hostName;
}
@@ -56,47 +53,36 @@ public class RootServiceHostComponentResponse {
return componentName;
}
- public void setComponentName(String componentName) {
- this.componentName = componentName;
+ public String getComponentState() {
+ return componentState;
+ }
+
+ public String getComponentVersion() {
+ return componentVersion;
}
public Map<String, String> getProperties() {
return properties;
}
- public void setProperties(Map<String, String> properties) {
- this.properties = properties;
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- RootServiceHostComponentResponse that = (RootServiceHostComponentResponse) o;
-
- return !(hostName != null ? !hostName.equals(that.hostName) : that.hostName != null) &&
- !(componentName != null ? !componentName.equals(that.componentName) : that.componentName != null) &&
- !(componentState != null ? !componentState.equals(that.componentState) : that.componentState != null) &&
- !(componentVersion != null ? !componentVersion.equals(that.componentVersion) : that.componentVersion != null) &&
- !(properties != null ? !properties.equals(that.properties) : that.properties != null);
+ RootServiceHostComponentResponse other = (RootServiceHostComponentResponse) o;
+ return Objects.equals(serviceName, other.serviceName) &&
+ Objects.equals(hostName, other.hostName) &&
+ Objects.equals(componentName, other.componentName) &&
+ Objects.equals(componentState, other.componentState) &&
+ Objects.equals(componentVersion, other.componentVersion) &&
+ Objects.equals(properties, other.properties);
}
@Override
public int hashCode() {
- int result = 31 + (hostName != null ? hostName.hashCode() : 0);
- result = result + (componentName != null ? componentName.hashCode() : 0);
- result = result + (componentState != null ? componentState.hashCode() : 0);
- result = result + (componentVersion != null ? componentVersion.hashCode() : 0);
- return result;
+ return Objects.hash(serviceName, hostName, componentName, componentVersion, componentState);
}
- public String getComponentState() {
- return componentState;
- }
-
- public String getComponentVersion() {
- return componentVersion;
- }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceResponseFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceResponseFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceResponseFactory.java
index 6bb68b6..c207e2b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceResponseFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RootServiceResponseFactory.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
@@ -18,13 +18,13 @@
package org.apache.ambari.server.controller;
+import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.JDK_LOCATION;
+
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.JDK_LOCATION;
-
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.ObjectNotFoundException;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
@@ -43,21 +43,21 @@ public class RootServiceResponseFactory extends
public static final String NOT_APPLICABLE = "NOT_APPLICABLE";
@Inject
private Configuration configs;
-
+
@Inject
private AmbariMetaInfo ambariMetaInfo;
@Inject
private AmbariManagementController managementController;
-
-
+
+
@Override
public Set<RootServiceResponse> getRootServices(RootServiceRequest request) throws ObjectNotFoundException {
-
+
Set<RootServiceResponse> response;
-
+
String serviceName = null;
-
+
if (request != null)
serviceName = request.getServiceName();
@@ -69,22 +69,22 @@ public class RootServiceResponseFactory extends
catch (IllegalArgumentException ex) {
throw new ObjectNotFoundException("Root service name: " + serviceName);
}
-
+
response = Collections.singleton(new RootServiceResponse(service.toString()));
} else {
- response = new HashSet<RootServiceResponse>();
-
- for (Services service: Services.values())
+ response = new HashSet<>();
+
+ for (Services service: Services.values())
response.add(new RootServiceResponse(service.toString()));
- }
+ }
return response;
}
-
+
@Override
public Set<RootServiceComponentResponse> getRootServiceComponents(
RootServiceComponentRequest request) throws ObjectNotFoundException {
- Set<RootServiceComponentResponse> response = new HashSet<RootServiceComponentResponse>();
-
+ Set<RootServiceComponentResponse> response = new HashSet<>();
+
String serviceName = request.getServiceName();
String componentName = request.getComponentName();
Services service;
@@ -98,7 +98,7 @@ public class RootServiceResponseFactory extends
catch (NullPointerException np) {
throw new ObjectNotFoundException("Root service name: null");
}
-
+
if (componentName != null) {
Components component;
try {
@@ -109,13 +109,13 @@ public class RootServiceResponseFactory extends
catch (IllegalArgumentException ex) {
throw new ObjectNotFoundException("Component name: " + componentName);
}
- response = Collections.singleton(new RootServiceComponentResponse(component.toString(),
+ response = Collections.singleton(new RootServiceComponentResponse(serviceName, component.toString(),
getComponentVersion(componentName, null),
getComponentProperties(componentName)));
} else {
-
- for (Components component: service.getComponents())
- response.add(new RootServiceComponentResponse(component.toString(),
+
+ for (Components component: service.getComponents())
+ response.add(new RootServiceComponentResponse(serviceName, component.toString(),
getComponentVersion(component.name(), null),
getComponentProperties(component.name())));
}
@@ -125,14 +125,14 @@ public class RootServiceResponseFactory extends
private String getComponentVersion(String componentName, HostResponse host) {
Components component = Components.valueOf(componentName);
String componentVersion;
-
+
switch (component) {
case AMBARI_SERVER:
componentVersion = ambariMetaInfo.getServerVersion();
break;
case AMBARI_AGENT:
//Could be defined on level of host component
-
+
if (host == null)
componentVersion = NOT_APPLICABLE;
else
@@ -142,18 +142,18 @@ public class RootServiceResponseFactory extends
default:
componentVersion = null;
}
-
+
return componentVersion;
}
-
+
private Map<String, String> getComponentProperties(String componentName){
-
+
Map<String, String> response;
Components component = null;
if (componentName != null) {
component = Components.valueOf(componentName);
-
+
switch (component) {
case AMBARI_SERVER:
response = configs.getAmbariProperties();
@@ -171,7 +171,7 @@ public class RootServiceResponseFactory extends
return response;
}
-
+
public enum Services {
AMBARI(Components.values());
private Components[] components;
@@ -184,25 +184,26 @@ public class RootServiceResponseFactory extends
return components;
}
}
-
+
public enum Components {
AMBARI_SERVER, AMBARI_AGENT
}
@Override
public Set<RootServiceHostComponentResponse> getRootServiceHostComponent(RootServiceHostComponentRequest request, Set<HostResponse> hosts) throws AmbariException {
- Set<RootServiceHostComponentResponse> response = new HashSet<RootServiceHostComponentResponse>();
+ Set<RootServiceHostComponentResponse> response = new HashSet<>();
- Set<RootServiceComponentResponse> rootServiceComponents =
- getRootServiceComponents(new RootServiceComponentRequest(request.getServiceName(), request.getComponentName()));
+ String serviceName = request.getServiceName();
+ Set<RootServiceComponentResponse> rootServiceComponents =
+ getRootServiceComponents(new RootServiceComponentRequest(serviceName, request.getComponentName()));
//Cartesian product with hosts and components
for (RootServiceComponentResponse component : rootServiceComponents) {
-
- Set<HostResponse> filteredHosts = new HashSet<HostResponse>(hosts);
-
+
+ Set<HostResponse> filteredHosts = new HashSet<>(hosts);
+
//Make some filtering of hosts if need
- if (component.getComponentName().equals(Components.AMBARI_SERVER.name()))
+ if (component.getComponentName().equals(Components.AMBARI_SERVER.name())) {
CollectionUtils.filter(filteredHosts, new Predicate() {
@Override
public boolean evaluate(Object arg0) {
@@ -210,18 +211,20 @@ public class RootServiceResponseFactory extends
return hostResponse.getHostname().equals(StageUtils.getHostName());
}
});
-
+ }
+
for (HostResponse host : filteredHosts) {
-
- if (component.getComponentName().equals(Components.AMBARI_SERVER.name()))
- response.add(new RootServiceHostComponentResponse(host.getHostname(), component.getComponentName(),
- RUNNING_STATE, getComponentVersion(component.getComponentName(), host), component.getProperties()));
- else
- response.add(new RootServiceHostComponentResponse(host.getHostname(), component.getComponentName(),
- host.getHostState(), getComponentVersion(component.getComponentName(), host), component.getProperties()));
+ String state;
+ if (component.getComponentName().equals(Components.AMBARI_SERVER.name())) {
+ state = RUNNING_STATE;
+ } else {
+ state = host.getHostState().toString();
+ }
+ String componentVersion = getComponentVersion(component.getComponentName(), host);
+ response.add(new RootServiceHostComponentResponse(serviceName, host.getHostname(), component.getComponentName(), state, componentVersion, component.getProperties()));
}
}
-
+
return response;
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
index f6993f8..7b75e06 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
@@ -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
@@ -35,21 +35,19 @@ public class ServiceComponentHostResponse {
// type -> desired config
private Map<String, HostConfig> actualConfigs;
private String liveState;
- private String stackVersion;
+ private String version;
private String desiredStackVersion;
+ private String desiredRepositoryVersion;
private String desiredState;
private boolean staleConfig = false;
private String adminState = null;
private String maintenanceState = null;
private UpgradeState upgradeState = UpgradeState.NONE;
-
- public ServiceComponentHostResponse(String clusterName, String serviceName,
- String componentName, String displayName,
- String hostname, String publicHostname,
- String liveState, String stackVersion,
- String desiredState, String desiredStackVersion,
- HostComponentAdminState adminState) {
+ public ServiceComponentHostResponse(String clusterName, String serviceName, String componentName,
+ String displayName, String hostname, String publicHostname, String liveState, String version,
+ String desiredState, String desiredStackVersion, String desiredRepositoryVersion,
+ HostComponentAdminState adminState) {
this.clusterName = clusterName;
this.serviceName = serviceName;
this.componentName = componentName;
@@ -57,9 +55,10 @@ public class ServiceComponentHostResponse {
this.hostname = hostname;
this.publicHostname = publicHostname;
this.liveState = liveState;
- this.stackVersion = stackVersion;
+ this.version = version;
this.desiredState = desiredState;
this.desiredStackVersion = desiredStackVersion;
+ this.desiredRepositoryVersion = desiredRepositoryVersion;
if (adminState != null) {
this.adminState = adminState.name();
}
@@ -143,17 +142,10 @@ public class ServiceComponentHostResponse {
}
/**
- * @return the stackVersion
- */
- public String getStackVersion() {
- return stackVersion;
- }
-
- /**
- * @param stackVersion the stackVersion to set
+ * @return the version
*/
- public void setStackVersion(String stackVersion) {
- this.stackVersion = stackVersion;
+ public String getVersion() {
+ return version;
}
/**
@@ -185,6 +177,15 @@ public class ServiceComponentHostResponse {
}
/**
+ * Gets the desired repository of the component.
+ *
+ * @return the desired repository.
+ */
+ public String getDesiredRepositoryVersion() {
+ return desiredRepositoryVersion;
+ }
+
+ /**
* @return the clusterName
*/
public String getClusterName() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/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 9dbda20..9bd3e44 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
@@ -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
@@ -21,46 +21,40 @@ package org.apache.ambari.server.controller;
import java.util.Map;
+import org.apache.ambari.server.state.RepositoryVersionState;
+import org.apache.ambari.server.state.StackId;
+
public class ServiceComponentResponse {
private Long clusterId; // REF
-
private String clusterName; // REF
-
private String serviceName;
-
private String componentName;
-
private String displayName;
-
- private String desiredStackVersion;
-
+ private String desiredStackId;
private String desiredState;
-
private String category;
-
- Map<String, Integer> serviceComponentStateCount;
-
+ private Map<String, Integer> serviceComponentStateCount;
private boolean recoveryEnabled;
+ private String desiredVersion;
+ private RepositoryVersionState repoState;
+
+ public ServiceComponentResponse(Long clusterId, String clusterName, String serviceName,
+ String componentName, StackId desiredStackId, String desiredState,
+ Map<String, Integer> serviceComponentStateCount, boolean recoveryEnabled, String displayName,
+ String desiredVersion, RepositoryVersionState repoState) {
- public ServiceComponentResponse(Long clusterId, String clusterName,
- String serviceName,
- String componentName,
- String desiredStackVersion,
- String desiredState,
- Map<String, Integer> serviceComponentStateCount,
- boolean recoveryEnabled,
- String displayName) {
- super();
this.clusterId = clusterId;
this.clusterName = clusterName;
this.serviceName = serviceName;
this.componentName = componentName;
this.displayName = displayName;
- this.desiredStackVersion = desiredStackVersion;
+ this.desiredStackId = desiredStackId.getStackId();
this.desiredState = desiredState;
this.serviceComponentStateCount = serviceComponentStateCount;
this.recoveryEnabled = recoveryEnabled;
+ this.desiredVersion = desiredVersion;
+ this.repoState = repoState;
}
/**
@@ -141,17 +135,12 @@ public class ServiceComponentResponse {
}
/**
+ * Gets the desired stack ID.
+ *
* @return the desiredStackVersion
*/
- public String getDesiredStackVersion() {
- return desiredStackVersion;
- }
-
- /**
- * @param desiredStackVersion the desiredStackVersion to set
- */
- public void setDesiredStackVersion(String desiredStackVersion) {
- this.desiredStackVersion = desiredStackVersion;
+ public String getDesiredStackId() {
+ return desiredStackId;
}
/**
@@ -196,10 +185,29 @@ public class ServiceComponentResponse {
this.recoveryEnabled = recoveryEnabled;
}
+ /**
+ * @return the desired version of the component
+ */
+ public String getDesiredVersion() {
+ return desiredVersion;
+ }
+
+ /**
+ * @return the state of the repository against the desired version
+ */
+ public RepositoryVersionState getRepositoryState() {
+ return repoState;
+ }
+
+
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
ServiceComponentResponse that =
(ServiceComponentResponse) o;
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
index a8e6315..0fbb63f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceRequest.java
@@ -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
@@ -17,7 +17,7 @@
*/
package org.apache.ambari.server.controller;
-
+import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
public class ServiceRequest {
@@ -28,17 +28,25 @@ public class ServiceRequest {
private String credentialStoreEnabled; // CREATE/UPDATE/GET
private String credentialStoreSupported; //GET
+ private Long desiredRepositoryVersionId;
+ /**
+ * Short-lived object that gets set while validating a request
+ */
+ private RepositoryVersionEntity resolvedRepository;
+
public ServiceRequest(String clusterName, String serviceName,
- String desiredState) {
- this(clusterName, serviceName, desiredState, null);
+ Long desiredRepositoryVersionId, String desiredState) {
+ this(clusterName, serviceName, desiredRepositoryVersionId, desiredState, null);
}
public ServiceRequest(String clusterName, String serviceName,
- String desiredState,
- String credentialStoreEnabled) {
+ Long desiredRepositoryVersionId, String desiredState, String credentialStoreEnabled) {
this.clusterName = clusterName;
this.serviceName = serviceName;
this.desiredState = desiredState;
+
+ this.desiredRepositoryVersionId = desiredRepositoryVersionId;
+
this.credentialStoreEnabled = credentialStoreEnabled;
// Credential store supported cannot be changed after
// creation since it comes from the stack definition.
@@ -73,6 +81,10 @@ public class ServiceRequest {
this.desiredState = desiredState;
}
+ public Long getDesiredRepositoryVersionId() {
+ return desiredRepositoryVersionId;
+ }
+
/**
* @return the clusterName
*/
@@ -130,13 +142,25 @@ public class ServiceRequest {
this.credentialStoreSupported = credentialStoreSupported;
}
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("clusterName=" + clusterName
- + ", serviceName=" + serviceName
- + ", desiredState=" + desiredState
- + ", credentialStoreEnabled=" + credentialStoreEnabled
- + ", credentialStoreSupported=" + credentialStoreSupported);
+ sb.append("clusterName=").append(clusterName)
+ .append(", serviceName=").append(serviceName)
+ .append(", desiredState=").append(desiredState)
+ .append(", credentialStoreEnabled=").append(credentialStoreEnabled)
+ .append(", credentialStoreSupported=").append(credentialStoreSupported);
return sb.toString();
}
+
+ /**
+ * @param repositoryVersion
+ */
+ public void setResolvedRepository(RepositoryVersionEntity repositoryVersion) {
+ resolvedRepository = repositoryVersion;
+ }
+
+ public RepositoryVersionEntity getResolvedRepository() {
+ return resolvedRepository;
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
index 3e35c0c..dea95a6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
@@ -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
@@ -18,32 +18,39 @@
package org.apache.ambari.server.controller;
+import org.apache.ambari.server.state.RepositoryVersionState;
+import org.apache.ambari.server.state.StackId;
public class ServiceResponse {
private Long clusterId;
private String clusterName;
private String serviceName;
- private String desiredStackVersion;
+ private StackId desiredStackId;
+ private String desiredRepositoryVersion;
+ private Long desiredRepositoryVersionId;
+ private RepositoryVersionState repositoryVersionState;
private String desiredState;
private String maintenanceState;
private boolean credentialStoreSupported;
private boolean credentialStoreEnabled;
- public ServiceResponse(Long clusterId, String clusterName,
- String serviceName,
- String desiredStackVersion, String desiredState,
- boolean credentialStoreSupported, boolean credentialStoreEnabled) {
+ public ServiceResponse(Long clusterId, String clusterName, String serviceName,
+ StackId desiredStackId, String desiredRepositoryVersion,
+ RepositoryVersionState repositoryVersionState, String desiredState,
+ boolean credentialStoreSupported, boolean credentialStoreEnabled) {
this.clusterId = clusterId;
this.clusterName = clusterName;
this.serviceName = serviceName;
- this.setDesiredStackVersion(desiredStackVersion);
- this.setDesiredState(desiredState);
+ this.desiredStackId = desiredStackId;
+ this.repositoryVersionState = repositoryVersionState;
+ setDesiredState(desiredState);
+ this.desiredRepositoryVersion = desiredRepositoryVersion;
this.credentialStoreSupported = credentialStoreSupported;
this.credentialStoreEnabled = credentialStoreEnabled;
}
-
-
+
+
/**
* @return the serviceName
@@ -102,23 +109,40 @@ public class ServiceResponse {
}
/**
- * @return the desiredStackVersion
+ * @return the desired stack ID.
*/
- public String getDesiredStackVersion() {
- return desiredStackVersion;
+ public String getDesiredStackId() {
+ return desiredStackId.getStackId();
+
}
/**
- * @param desiredStackVersion the desiredStackVersion to set
+ * Gets the desired repository version.
+ *
+ * @return the desired repository version.
*/
- public void setDesiredStackVersion(String desiredStackVersion) {
- this.desiredStackVersion = desiredStackVersion;
+ public String getDesiredRepositoryVersion() {
+ return desiredRepositoryVersion;
+ }
+
+ /**
+ * Gets the calculated repository version state from the components of this
+ * service.
+ *
+ * @return the desired repository version state
+ */
+ public RepositoryVersionState getRepositoryVersionState() {
+ return repositoryVersionState;
}
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
ServiceResponse that = (ServiceResponse) o;
@@ -137,11 +161,11 @@ public class ServiceResponse {
return true;
}
-
+
public void setMaintenanceState(String state) {
maintenanceState = state;
}
-
+
public String getMaintenanceState() {
return maintenanceState;
}
@@ -194,4 +218,18 @@ public class ServiceResponse {
return result;
}
+ /**
+ * @param id
+ */
+ public void setDesiredRepositoryVersionId(Long id) {
+ desiredRepositoryVersionId = id;
+ }
+
+ /**
+ * @param id
+ */
+ public Long getDesiredRepositoryVersionId() {
+ return desiredRepositoryVersionId;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/48f7fb22/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
index b26814a..5036bf4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
@@ -243,7 +243,7 @@ public abstract class AbstractControllerResourceProvider extends AbstractAuthori
*
* @return resource provider for the specified type
*/
- ResourceProvider getResourceProvider(Resource.Type type) {
+ public static ResourceProvider getResourceProvider(Resource.Type type) {
return ((ClusterControllerImpl) ClusterControllerHelper.getClusterController()).
ensureResourceProvider(type);
}