Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
AMBARI-25116. Fix other strange and buggy code (dlysnichenko) (#2785)
AMBARI-25116. Fix other strange and buggy code (dlysnichenko)
  • Loading branch information
dlysnichenko committed Jan 30, 2019
1 parent cf82327 commit cbd628460a186991f8cf2c391657eb5891c2ab82
Showing 65 changed files with 208 additions and 305 deletions.
@@ -351,6 +351,18 @@
<exclude>src/test/resources/mpacks_replay.log</exclude>
<exclude>src/test/python/stacks/2.5/HIVE/*.txt</exclude>
<exclude>src/test/python/mpacks/mystack-ambari-mpack-1.0.0.1/stacks/MYSTACK/3.0/services/SERVICEC/dashboards/service-metrics/STORM.txt</exclude>
<exclude>src/test/python/uninstall/dashboards/files/metainfo.xml</exclude> <!--exclude symlink-->
<exclude>src/test/python/uninstall/dashboards/files/STORM.txt</exclude> <!--exclude symlink-->
<exclude>src/test/python/uninstall/dashboards/SERVICEB</exclude> <!--exclude symlink-->
<exclude>src/test/python/uninstall/dashboards/SERVICEA</exclude> <!--exclude symlink-->
<exclude>src/test/python/uninstall/extensions/SERVICEB</exclude> <!--exclude symlink-->
<exclude>src/test/python/uninstall/extensions/SERVICEA</exclude> <!--exclude symlink-->
<exclude>src/test/python/uninstall/common-services/SERVICEB</exclude> <!--exclude symlink-->
<exclude>src/test/python/uninstall/common-services/SERVICEA</exclude> <!--exclude symlink-->
<exclude>src/test/python/uninstall/stacks/2.0/files/metainfo1.xml</exclude> <!--exclude symlink-->
<exclude>src/test/python/uninstall/stacks/2.0/files/metainfo2.xml</exclude> <!--exclude symlink-->
<exclude>src/test/python/uninstall/stacks/2.0/SERVICEB</exclude> <!--exclude symlink-->
<exclude>src/test/python/uninstall/stacks/2.0/SERVICEA</exclude> <!--exclude symlink-->
<exclude>src/test/python/uninstall/dashboards/files/STORM.txt</exclude>
<exclude>src/main/resources/hive-schema-0.10.0.oracle.sql</exclude>
<exclude>src/main/resources/hive-schema-0.12.0.oracle.sql</exclude>
@@ -274,10 +274,10 @@ protected void processHostStatus(List<ComponentStatus> componentStatuses, List<C
Long clusterId = null;
if (CollectionUtils.isNotEmpty(componentStatuses)) {
calculateHostStatus = true;
for (ComponentStatus componentStatus : componentStatuses) {
clusterId = componentStatus.getClusterId();
break;
}
clusterId = componentStatuses.stream()
.findFirst()
.map(ComponentStatus::getClusterId)
.orElse(null);
}

if (!calculateHostStatus && CollectionUtils.isNotEmpty(reports)) {
@@ -391,15 +391,13 @@ protected void processCommandReports(List<CommandReport> reports, String hostNam
}

if (writeKeytabsStructuredOut != null) {
if (SET_KEYTAB.equalsIgnoreCase(customCommand)) {
Map<String, String> keytabs = writeKeytabsStructuredOut.getKeytabs();
if (keytabs != null) {
for (Map.Entry<String, String> entry : keytabs.entrySet()) {
String keytabPath = entry.getValue();
for (KerberosKeytabPrincipalEntity kkpe: kerberosKeytabPrincipalDAO.findByHostAndKeytab(host.getHostId(), keytabPath)) {
kkpe.setDistributed(true);
kerberosKeytabPrincipalDAO.merge(kkpe);
}
Map<String, String> keytabs = writeKeytabsStructuredOut.getKeytabs();
if (keytabs != null) {
for (Map.Entry<String, String> entry : keytabs.entrySet()) {
String keytabPath = entry.getValue();
for (KerberosKeytabPrincipalEntity kkpe : kerberosKeytabPrincipalDAO.findByHostAndKeytab(host.getHostId(), keytabPath)) {
kkpe.setDistributed(true);
kerberosKeytabPrincipalDAO.merge(kkpe);
}
}
}
@@ -152,15 +152,13 @@ protected AlertDefinitionsAgentUpdateEvent handleUpdate(AlertDefinitionsAgentUpd
LOG.debug("Handled {} of alerts for {} cluster(s) on host with id {}, changed = {}", update.getEventType(), updateClusters.size(), hostId, changed);
break;
case CREATE:
if (!updateClusters.isEmpty()) {
if (!Sets.intersection(existingClusters.keySet(), updateClusters.keySet()).isEmpty()) {
throw new AmbariException("Existing clusters in create");
}
mergedClusters.putAll(existingClusters);
mergedClusters.putAll(updateClusters);
LOG.debug("Handled {} of alerts for {} cluster(s)", update.getEventType(), updateClusters.size());
changed = true;
if (!Sets.intersection(existingClusters.keySet(), updateClusters.keySet()).isEmpty()) {
throw new AmbariException("Existing clusters in create");
}
mergedClusters.putAll(existingClusters);
mergedClusters.putAll(updateClusters);
LOG.debug("Handled {} of alerts for {} cluster(s)", update.getEventType(), updateClusters.size());
changed = true;
break;
default:
LOG.warn("Unhandled event type {}", update.getEventType());
@@ -22,7 +22,6 @@
import java.util.Set;

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

/**
* An extension version is like a stack version but it contains custom services. Linking an extension
@@ -31,10 +30,6 @@
*/
public class ExtensionLinkResourceDefinition extends BaseResourceDefinition {

public ExtensionLinkResourceDefinition(Type resourceType) {
super(Resource.Type.ExtensionLink);
}

public ExtensionLinkResourceDefinition() {
super(Resource.Type.ExtensionLink);
}
@@ -22,7 +22,6 @@
import java.util.Set;

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

/**
* An extension version is like a stack version but it contains custom services. Linking an extension
@@ -31,10 +30,6 @@
*/
public class ExtensionResourceDefinition extends BaseResourceDefinition {

public ExtensionResourceDefinition(Type resourceType) {
super(Resource.Type.Extension);
}

public ExtensionResourceDefinition() {
super(Resource.Type.Extension);
}
@@ -27,7 +27,6 @@
import org.apache.ambari.server.api.util.TreeNode;
import org.apache.ambari.server.controller.internal.ResourceImpl;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.spi.Resource.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@@ -40,10 +39,6 @@ public class MpackResourceDefinition extends BaseResourceDefinition {
private final static Logger LOG =
LoggerFactory.getLogger(MpackResourceDefinition.class);

public MpackResourceDefinition(Type resourceType) {
super(Resource.Type.Mpack);
}

public MpackResourceDefinition() {
super(Resource.Type.Mpack);
}
@@ -22,14 +22,9 @@
import java.util.Set;

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

public class StackResourceDefinition extends BaseResourceDefinition {

public StackResourceDefinition(Type resourceType) {
super(Resource.Type.Stack);
}

public StackResourceDefinition() {
super(Resource.Type.Stack);
}
@@ -84,16 +84,13 @@ public UpgradeCheckResult perform(UpgradeCheckRequest request) throws AmbariExce
.map(FailedPluginClassDetail::new)
.collect(Collectors.toSet());

// check for failure
if (failedPluginClasses.size() > 0) {
result.setStatus(UpgradeCheckStatus.WARNING);
result.getFailedDetail().addAll(failedPluginSimpleClasses);
result.setFailReason(getFailReason(result, request));

result.getFailedOn().addAll(failedPluginSimpleClasses.stream()
.map(detail -> detail.toSimpleString())
.collect(Collectors.toSet()));
}
result.setStatus(UpgradeCheckStatus.WARNING);
result.getFailedDetail().addAll(failedPluginSimpleClasses);
result.setFailReason(getFailReason(result, request));

result.getFailedOn().addAll(failedPluginSimpleClasses.stream()
.map(detail -> detail.toSimpleString())
.collect(Collectors.toSet()));

return result;
}
@@ -3942,7 +3942,7 @@ public String getDatabasePassword() {

if (dbpasswd != null) {
return dbpasswd;
} else if (dbpasswd == null && isPasswordAlias) {
} else if (isPasswordAlias) {
LOG.error("Can't read db password from keystore. Please, check master key was set correctly.");
throw new RuntimeException("Can't read db password from keystore. Please, check master key was set correctly.");
} else {
@@ -3384,11 +3384,9 @@ public ExecutionCommand getExecutionCommand(Cluster cluster,
hostParamsCmd.putAll(ec.getHostLevelParams());
ec.getHostLevelParams().putAll(hostParamsCmd);

if (null != cluster) {
// Generate localComponents
for (ServiceComponentHost sch : cluster.getServiceComponentHosts(scHost.getHostName())) {
ec.getLocalComponents().add(sch.getServiceComponentName());
}
// Generate localComponents
for (ServiceComponentHost sch : cluster.getServiceComponentHosts(scHost.getHostName())) {
ec.getLocalComponents().add(sch.getServiceComponentName());
}

return ec;
@@ -2956,17 +2956,15 @@ private Map<String, Map<String, String>> addAdditionalConfigurations(Cluster clu
if (configurations.get(CLUSTER_HOST_INFO) == null) {
Map<String, Set<String>> clusterHostInfo = StageUtils.getClusterHostInfo(cluster);

if (clusterHostInfo != null) {
Map<String, String> componentHosts = new HashMap<>();
Map<String, String> componentHosts = new HashMap<>();

clusterHostInfo = StageUtils.substituteHostIndexes(clusterHostInfo);
clusterHostInfo = StageUtils.substituteHostIndexes(clusterHostInfo);

for (Map.Entry<String, Set<String>> entry : clusterHostInfo.entrySet()) {
componentHosts.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
}

configurations.put(CLUSTER_HOST_INFO, componentHosts);
for (Map.Entry<String, Set<String>> entry : clusterHostInfo.entrySet()) {
componentHosts.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
}

configurations.put(CLUSTER_HOST_INFO, componentHosts);
}
configurations.put("principals", principalNames(cluster, configurations));
return configurations;
@@ -26,15 +26,17 @@ public class StackServiceRequest extends StackVersionRequest {
private String credentialStoreEnabled;

public StackServiceRequest(String stackName, String stackVersion,
String serviceName) {
String serviceName) {
this(stackName, stackVersion, serviceName, null, null);
}

public StackServiceRequest(String stackName, String stackVersion,
String serviceName, String credentialStoreSupported, String credentialStoreEnabled) {
String serviceName, String credentialStoreSupported, String credentialStoreEnabled) {
super(stackName, stackVersion);

this.setServiceName(serviceName);
this.setCredentialStoreSupported(credentialStoreSupported);
this.setCredentialStoreEnabled(credentialStoreEnabled);
}

public String getServiceName() {
@@ -198,7 +198,7 @@ public Set<Resource> getResources(Request request, Predicate predicate)
} else {
// Verify authorization to retrieve the requested data
try {
Long clusterId = (StringUtils.isEmpty(clusterName)) ? null : getClusterId(clusterName);
Long clusterId = getClusterId(clusterName);
String definitionName = (String) propertyMap.get(ALERT_DEFINITION_NAME);
String definitionId = (String) propertyMap.get(ALERT_DEFINITION_ID);

@@ -101,9 +101,6 @@ public OperationResult performOperation(String categoryName, Map<String, String>
OperationType operationType;
try {
operationType = OperationType.translate(operation);
if (operationType == null) {
throw new SystemException(String.format("The requested operation is not supported for this category: %s", categoryName));
}
} catch (IllegalArgumentException e) {
throw new SystemException(String.format("The requested operation is not supported for this category: %s", categoryName), e);
}
@@ -19,7 +19,6 @@
package org.apache.ambari.server.controller.internal;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -195,10 +194,6 @@ private Map<String, Map<String, Map<String, String>>> calculateExistingConfigura
String configType = configuration.getKey();
Map<String, String> configurationProperties = new HashMap<>(configuration.getValue());

if (configurationProperties == null) {
configurationProperties = Collections.emptySortedMap();
}

properties.put("properties", configurationProperties);
requestConfigurations.put(configType, properties);
}
@@ -292,8 +292,6 @@ public void initRemovePropertyUpdaters() {
oozieEnvUpdaters.put("oozie_existing_mysql_host", new SingleHostTopologyUpdater("OOZIE_SERVER"));
oozieEnvUpdaters.put("oozie_existing_oracle_host", new SingleHostTopologyUpdater("OOZIE_SERVER"));
oozieEnvUpdaters.put("oozie_existing_postgresql_host", new SingleHostTopologyUpdater("OOZIE_SERVER"));
oozieEnvUpdaters.put("oozie_existing_oracle_host", new SingleHostTopologyUpdater("OOZIE_SERVER"));
oozieEnvUpdaters.put("oozie_existing_postgresql_host", new SingleHostTopologyUpdater("OOZIE_SERVER"));
oozieSiteUpdaters.put("oozie.service.JPAService.jdbc.url", new SingleHostTopologyUpdater("OOZIE_SERVER"));

singleHostTopologyUpdaters.put("oozie-env", oozieEnvUpdaters);
@@ -305,8 +303,6 @@ public void initRemovePropertyUpdaters() {
oozieEnvOriginalValueMap.put("oozie_existing_mysql_host", new OriginalValuePropertyUpdater());
oozieEnvOriginalValueMap.put("oozie_existing_oracle_host", new OriginalValuePropertyUpdater());
oozieEnvOriginalValueMap.put("oozie_existing_postgresql_host", new OriginalValuePropertyUpdater());
oozieEnvOriginalValueMap.put("oozie_existing_oracle_host", new OriginalValuePropertyUpdater());
oozieEnvOriginalValueMap.put("oozie_existing_postgresql_host", new OriginalValuePropertyUpdater());
oozieSiteOriginalValueMap.put("oozie.service.JPAService.jdbc.url", new OriginalValuePropertyUpdater());

removePropertyUpdaters.put("oozie-env", oozieEnvOriginalValueMap);
@@ -76,7 +76,6 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;

@@ -196,8 +195,7 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
* @param managementController the management controller
*/
@AssistedInject
public HostComponentResourceProvider(@Assisted AmbariManagementController managementController,
Injector injector) {
public HostComponentResourceProvider(@Assisted AmbariManagementController managementController) {
super(Resource.Type.HostComponent, propertyIds, keyPropertyIds, managementController);

setRequiredCreateAuthorizations(EnumSet.of(RoleAuthorization.SERVICE_ADD_DELETE_SERVICES,RoleAuthorization.HOST_ADD_DELETE_COMPONENTS));
@@ -711,9 +711,7 @@ private Set<Resource> getRequestResources(String clusterName,
// !!! this call will result in mixed results of cluster and non-cluster. this
// will get fixed in a future iteration, as the host_role_command table does not
// currently have direct cluster affinity, and changing that is a tad destructive.
requestIds = actionManager.getRequestsByStatus(status,
maxResults != null ? maxResults : BaseRequest.DEFAULT_PAGE_SIZE,
ascOrder != null ? ascOrder : false);
requestIds = actionManager.getRequestsByStatus(status, maxResults, ascOrder);
}

LOG.debug("List<Long> requestIds = actionManager.getRequestsByStatus = {}", requestIds.size());
@@ -496,12 +496,8 @@ private Map<String, Object> buildStackDescriptor(String stackName, String stackV

Collection<KerberosServiceDescriptor> serviceDescriptors = getServiceDescriptors(stackInfo);

if (serviceDescriptors != null) {
serviceDescriptors.forEach(kerberosDescriptor::putService);
return kerberosDescriptor.toMap();
} else {
return null;
}
serviceDescriptors.forEach(kerberosDescriptor::putService);
return kerberosDescriptor.toMap();
}

/**
@@ -303,15 +303,15 @@ protected String resolvePort(Cluster cluster, String hostname, String componentN
portPropertyName = metricsProperties.get(portPropertyNameInMetricsProperties);
}
String portStr = getPropertyValueByNameAndConfigType(portPropertyName, portConfigType, cluster, hostname);
if (portStr == null && metricsProperties.containsKey(DEFAULT_PORT_PROPERTY)) {
if (portStr == null) {
if (metricsProperties.containsKey(DEFAULT_PORT_PROPERTY)) {
portStr = metricsProperties.get(DEFAULT_PORT_PROPERTY);
} else {
String message = String.format("Can not determine REST port for " +
"component %s. " +
"Default REST port property %s is not defined at metrics.json " +
"file for service, and there is no any other available ways " +
"to determine port information.",
"component %s. " +
"Default REST port property %s is not defined at metrics.json " +
"file for service, and there is no any other available ways " +
"to determine port information.",
componentName, DEFAULT_PORT_PROPERTY);
throw new AmbariException(message);
}
@@ -45,7 +45,6 @@ public class GangliaHostPropertyProvider extends GangliaPropertyProvider {
GANGLIA_CLUSTER_NAMES.add("HDPResourceManager");
GANGLIA_CLUSTER_NAMES.add("HDPHBaseMaster");
GANGLIA_CLUSTER_NAMES.add("HDPHistoryServer");
GANGLIA_CLUSTER_NAMES.add("HDPNameNode");
GANGLIA_CLUSTER_NAMES.add("HDPTaskTracker");
GANGLIA_CLUSTER_NAMES.add("HDPHBaseRegionServer");
GANGLIA_CLUSTER_NAMES.add("HDPFlumeServer");

0 comments on commit cbd6284

Please sign in to comment.