Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
63083ec
AMBARI-23032 fix execptions, export cluster settings and single mpack…
Feb 21, 2018
4ec0391
AMBARI-23032 fix review comments (benyoka)
Feb 22, 2018
bd2f0b3
AMBARI-23032 better method naming (benyoka)
Feb 22, 2018
33c0f20
AMBARI-23032 fix review comments #2 (benyoka)
Feb 22, 2018
aba404a
AMBARI-23032 fix review comments #3 (benyoka)
Feb 22, 2018
c31829c
Merge remote-tracking branch 'upstream/branch-feature-AMBARI-14714' i…
Feb 26, 2018
91f1560
AMBARI-23032 fix swallowed exceptions during mpack installation
Feb 26, 2018
0d21dad
AMBARI-23032 prepare for mpack info in component
Mar 1, 2018
bf1e23c
Merge remote-tracking branch 'upstream/branch-feature-AMBARI-14714' i…
Mar 1, 2018
fdbed57
Merge remote-tracking branch 'upstream/branch-feature-AMBARI-14714' i…
Mar 13, 2018
1277c6e
Merge remote-tracking branch 'upstream/branch-feature-AMBARI-14714' i…
Mar 19, 2018
2631e7d
Merge remote-tracking branch 'upstream/branch-feature-AMBARI-14714' i…
Mar 19, 2018
3024885
AMBARI-23032 fix exceptions during installation and blueprint export …
Mar 20, 2018
cf468a6
AMBARI-23032 revert accidental changes (benyoka)
Mar 20, 2018
bb94bb7
AMBARI-23032 revert accidental changes #2 (benyoka)
Mar 20, 2018
424e420
AMBARI-23032 fixed a number of unit tests (benyoka)
Mar 21, 2018
66cbcae
AMBARI-23032 make sure Blueprints tag is exported (benyoka)
Mar 23, 2018
b5ecffb
Merge branch-feature-AMBARI-14714
Mar 26, 2018
f8c7cdb
AMBARI-23032 fix import error (benyoka)
Mar 26, 2018
2c424dd
Merge remote-tracking branch 'upstream/branch-feature-AMBARI-14714' i…
Mar 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
import org.apache.ambari.server.controller.internal.BlueprintConfigurationProcessor;
import org.apache.ambari.server.controller.internal.BlueprintResourceProvider;
import org.apache.ambari.server.controller.internal.ClusterSettingResourceProvider;
import org.apache.ambari.server.controller.internal.ClusterStackVersionResourceProvider;
import org.apache.ambari.server.controller.internal.ComponentResourceProvider;
import org.apache.ambari.server.controller.internal.ExportBlueprintRequest;
import org.apache.ambari.server.controller.internal.HostComponentResourceProvider;
import org.apache.ambari.server.controller.internal.RequestImpl;
import org.apache.ambari.server.controller.internal.ResourceImpl;
import org.apache.ambari.server.controller.spi.ClusterController;
Expand All @@ -59,7 +62,6 @@
import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
import org.apache.ambari.server.controller.utilities.PredicateBuilder;
import org.apache.ambari.server.state.SecurityType;
import org.apache.ambari.server.state.StackId;
import org.apache.ambari.server.topology.AmbariContext;
import org.apache.ambari.server.topology.ClusterTopology;
import org.apache.ambari.server.topology.ClusterTopologyImpl;
Expand Down Expand Up @@ -112,13 +114,23 @@ public TreeNode<Set<String>> finalizeProperties(
TreeNode<Set<String>> serviceGroupNode = ensureChild(resultTree, Resource.Type.ServiceGroup);
TreeNode<Set<String>> serviceNode = ensureChild(serviceGroupNode, Resource.Type.Service);
ensureChild(serviceNode, Resource.Type.Component,
"ServiceComponentInfo/cluster_name",
"ServiceComponentInfo/service_name",
"ServiceComponentInfo/component_name",
"ServiceComponentInfo/recovery_enabled");
ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID,
ComponentResourceProvider.COMPONENT_SERVICE_NAME_PROPERTY_ID,
ComponentResourceProvider.COMPONENT_SERVICE_TYPE_PROPERTY_ID,
ComponentResourceProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID,
ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID);

ensureChild(resultTree, Resource.Type.ClusterStackVersion,
ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_STACK_PROPERTY_ID,
ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID,
ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_MPACK_URI_PROPERTY_ID);

TreeNode<Set<String>> hostNode = ensureChild(resultTree, Resource.Type.Host);
ensureChild(hostNode, Resource.Type.HostComponent, "HostRoles/component_name");
ensureChild(hostNode, Resource.Type.HostComponent,
HostComponentResourceProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID,
HostComponentResourceProvider.HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID,
HostComponentResourceProvider.HOST_COMPONENT_SERVICE_TYPE_PROPERTY_ID,
HostComponentResourceProvider.HOST_COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID);

return resultTree;
}
Expand Down Expand Up @@ -191,11 +203,7 @@ private Resource createBlueprintResource(TreeNode<Resource> clusterNode) {
BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology);
configProcessor.doUpdateForBlueprintExport();

Set<StackId> stackIds = topology.getStackIds();
// TODO: mpacks should come from service groups once https://github.com/apache/ambari/pull/234 will be committed
Collection<Map<String, String>> mpackInstances = stackIds.stream().
map( stackId -> ImmutableMap.of("name", stackId.getStackName(), "version", stackId.getStackVersion())).collect(toList());
blueprintResource.setProperty(BlueprintResourceProvider.MPACK_INSTANCES_PROPERTY_ID, mpackInstances);
addMpackInstances(blueprintResource, clusterNode);

if (topology.isClusterKerberosEnabled()) {
Map<String, Object> securityConfigMap = new LinkedHashMap<>();
Expand All @@ -212,6 +220,12 @@ private Resource createBlueprintResource(TreeNode<Resource> clusterNode) {
}
blueprintResource.setProperty(BlueprintResourceProvider.BLUEPRINT_SECURITY_PROPERTY_ID, securityConfigMap);
}
// This is needed so that exported 3.0+ blueprints have a "Blueprints" section in all cases (previously
// Blueprints/stack_name, Blueprints/stack_version provided this but in 3.0 we have mpacks instead of stacks.)
else {
blueprintResource.setProperty(BlueprintResourceProvider.BLUEPRINT_SECURITY_PROPERTY_ID,
ImmutableMap.of(SecurityConfigurationFactory.TYPE_PROPERTY_ID, SecurityType.NONE.name()));
}

List<Map<String, Object>> groupList = formatGroupsAsList(topology);
blueprintResource.setProperty("host_groups", groupList);
Expand All @@ -227,6 +241,22 @@ private Resource createBlueprintResource(TreeNode<Resource> clusterNode) {
return blueprintResource;
}

/**
* Adds mpack instances to the exported blueprint resource.
*/
private void addMpackInstances(Resource blueprintResource, TreeNode<Resource> clusterNode) {
List<Map<String, Object>> mpackInstances = clusterNode.getChild("stack_versions").getChildren().stream().map(
child -> {
Map<String, Object> stackVersionProps = child.getObject().getPropertiesMap().get("ClusterStackVersions");
return ImmutableMap.of(
"name", stackVersionProps.get("stack"),
"version", stackVersionProps.get("version"),
"url", stackVersionProps.get("mpack_uri"));
}).
collect(toList());
blueprintResource.setProperty(BlueprintResourceProvider.MPACK_INSTANCES_PROPERTY_ID, mpackInstances);
}

/***
* Constructs the Settings object of the following form:
* "settings": [ {
Expand Down Expand Up @@ -457,8 +487,7 @@ private List<Map<String, String>> processHostGroupComponents(HostGroup group) {

protected ClusterTopology createClusterTopology(TreeNode<Resource> clusterNode)
throws InvalidTopologyTemplateException, InvalidTopologyException {

return new ClusterTopologyImpl(new AmbariContext(), new ExportBlueprintRequest(clusterNode));
return new ClusterTopologyImpl(controller.getAmbariContext(), new ExportBlueprintRequest(clusterNode));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
import org.apache.ambari.server.state.quicklinksprofile.QuickLinkVisibilityController;
import org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
import org.apache.ambari.server.topology.AmbariContext;


/**
Expand Down Expand Up @@ -564,6 +565,13 @@ RequestStatusResponse createAction(ExecuteActionRequest actionRequest, Map<Strin
*/
AmbariMetaInfo getAmbariMetaInfo();

/**
* Get the ambari context for this management controller.
*
* @return the ambari context
*/
AmbariContext getAmbariContext();

/**
* Get the service factory for this management controller.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostStartEvent;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostStopEvent;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostUpgradeEvent;
import org.apache.ambari.server.topology.AmbariContext;
import org.apache.ambari.server.topology.Setting;
import org.apache.ambari.server.topology.TopologyDeleteFormer;
import org.apache.ambari.server.utils.SecretReference;
Expand Down Expand Up @@ -357,6 +358,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
private CredentialStoreService credentialStoreService;
@Inject
private SettingDAO settingDAO;
@Inject
private AmbariContext ambariContext;

private MaintenanceStateHelper maintenanceStateHelper;

Expand Down Expand Up @@ -5192,6 +5195,11 @@ public AmbariMetaInfo getAmbariMetaInfo() {
return ambariMetaInfo;
}

@Override
public AmbariContext getAmbariContext() {
return ambariContext;
}

@Override
public ServiceGroupFactory getServiceGroupFactory() {
return serviceGroupFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou

protected static final String CLUSTER_STACK_VERSION_ID_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "id");
protected static final String CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "cluster_name");
protected static final String CLUSTER_STACK_VERSION_STACK_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "stack");
protected static final String CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "version");
public static final String CLUSTER_STACK_VERSION_STACK_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "stack");
public static final String CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "version");
public static final String CLUSTER_STACK_VERSION_MPACK_URI_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "mpack_uri");
protected static final String CLUSTER_STACK_VERSION_STATE_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "state");
protected static final String CLUSTER_STACK_VERSION_HOST_STATES_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "host_states");
protected static final String CLUSTER_STACK_VERSION_REPO_SUMMARY_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "repository_summary");
Expand Down Expand Up @@ -159,9 +160,9 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou

private static Set<String> propertyIds = Sets.newHashSet(CLUSTER_STACK_VERSION_ID_PROPERTY_ID,
CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID, CLUSTER_STACK_VERSION_STACK_PROPERTY_ID,
CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID, CLUSTER_STACK_VERSION_HOST_STATES_PROPERTY_ID,
CLUSTER_STACK_VERSION_STATE_PROPERTY_ID, CLUSTER_STACK_VERSION_REPOSITORY_VERSION_PROPERTY_ID,
CLUSTER_STACK_VERSION_STAGE_SUCCESS_FACTOR,
CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID, CLUSTER_STACK_VERSION_MPACK_URI_PROPERTY_ID,
CLUSTER_STACK_VERSION_HOST_STATES_PROPERTY_ID, CLUSTER_STACK_VERSION_STATE_PROPERTY_ID,
CLUSTER_STACK_VERSION_REPOSITORY_VERSION_PROPERTY_ID, CLUSTER_STACK_VERSION_STAGE_SUCCESS_FACTOR,
CLUSTER_STACK_VERSION_FORCE, CLUSTER_STACK_VERSION_REPO_SUMMARY_PROPERTY_ID,
CLUSTER_STACK_VERSION_REPO_SUPPORTS_REVERT, CLUSTER_STACK_VERSION_REPO_REVERT_UPGRADE_ID);

Expand Down Expand Up @@ -297,6 +298,12 @@ public int compare(RepositoryVersionEntity o1, RepositoryVersionEntity o2) {
StackEntity repoVersionStackEntity = repositoryVersion.getStack();
StackId repoVersionStackId = new StackId(repoVersionStackEntity);

AmbariMetaInfo ami = getManagementController().getAmbariMetaInfo();
ami.getMpacks().stream().
filter(mp -> mp.getName().equals(repoVersionStackId.getStackName()) && mp.getVersion().equals(repoVersionStackId.getStackVersion())).
findFirst().
ifPresent(mpack -> setResourceProperty(resource, CLUSTER_STACK_VERSION_MPACK_URI_PROPERTY_ID, mpack.getMpackUri(), requestedIds));

try {
MpackHostStateDAO mpackHostStateDAO = mpackHostStateDAOProvider.get();
List<MpackHostStateEntity> mpackInstallStates = Lists.newArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
// Components

protected static final String COMPONENT_CLUSTER_ID_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "cluster_id";
protected static final String COMPONENT_CLUSTER_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "cluster_name";
public static final String COMPONENT_CLUSTER_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "cluster_name";
protected static final String COMPONENT_SERVICE_GROUP_ID_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_group_id";
protected static final String COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_group_name";
protected static final String COMPONENT_SERVICE_ID_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_id";
protected static final String COMPONENT_SERVICE_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_name";
protected static final String COMPONENT_SERVICE_TYPE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_type";
public static final String COMPONENT_SERVICE_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_name";
public static final String COMPONENT_SERVICE_TYPE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_type";
protected static final String COMPONENT_COMPONENT_ID_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "id";
protected static final String COMPONENT_COMPONENT_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "component_name";
public static final String COMPONENT_COMPONENT_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "component_name";
protected static final String COMPONENT_COMPONENT_TYPE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "component_type";
protected static final String COMPONENT_DISPLAY_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "display_name";
protected static final String COMPONENT_STATE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "state";
Expand All @@ -110,7 +110,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
protected static final String COMPONENT_INIT_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "init_count";
protected static final String COMPONENT_UNKNOWN_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "unknown_count";
protected static final String COMPONENT_INSTALL_FAILED_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "install_failed_count";
protected static final String COMPONENT_RECOVERY_ENABLED_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "recovery_enabled";
public static final String COMPONENT_RECOVERY_ENABLED_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "recovery_enabled";
protected static final String COMPONENT_DESIRED_STACK = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "desired_stack";
protected static final String COMPONENT_DESIRED_VERSION = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "desired_version";
protected static final String COMPONENT_REPOSITORY_STATE = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "repository_state";
Expand Down
Loading