Skip to content

[AMBARI-24464] Integrate Blueprints with the new MPackAdvisor API for Configuration Recommendations#2259

Merged
benyoka merged 11 commits into
apache:branch-feature-AMBARI-14714from
benyoka:AMBARI-24464-branch-feature-AMBARI-14714
Sep 14, 2018
Merged

[AMBARI-24464] Integrate Blueprints with the new MPackAdvisor API for Configuration Recommendations#2259
benyoka merged 11 commits into
apache:branch-feature-AMBARI-14714from
benyoka:AMBARI-24464-branch-feature-AMBARI-14714

Conversation

@benyoka
Copy link
Copy Markdown
Contributor

@benyoka benyoka commented Sep 6, 2018

What changes were proposed in this pull request?

This is a preview patch for mpack advisor support for blueprints. Unit tests are being written at the moment.

Mpack advisor is the new default engine for configuration recommendation. It is possible to use the legacy stack advisor though by setting use.legacy.stackadvisor=true in ambari.properties.

How was this patch tested?

Tested by manual blueprint deployment. Unit tests are being written.

@asfgit
Copy link
Copy Markdown

asfgit commented Sep 6, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/3866/
Test FAILed.
Test FAILured.

Copy link
Copy Markdown

@rnettleton rnettleton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've taken an initial look, and the patch looks fine to me so far.

One the unit tests are available, I'll re-review.

Thanks.

@adoroszlai adoroszlai changed the title Ambari 24464 branch feature ambari 14714 [AMBARI-24464] Integrate Blueprints with the new MPackAdvisor API for Configuration Recommendations Sep 10, 2018
)
);

return null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this method return the map created by the previous statement, instead of null?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is from an intermediate commit.

}

private Map<String, Set<String>> gatherHostGroupBindings(ClusterTopology clusterTopology) {
Map<String, Set<String>> hgBindngs = Maps.newHashMap();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in hgBindngs, should be hgBindings.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

return getProperty(MPACK_ADVISOR_SCRIPT);
}

public boolean isUseLegacyStackAdvisor() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name shouldUseLegacyStackAdvisor would be more natural instead of isUseLegacyStackAdvisor. The latter may be OK for a JavaBean.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

*/
Stream<ResolvedComponent> getComponents();

Map<String, Set<ResolvedComponent>> getComponentsByHostgroup();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Group with capital G in getComponentsByHostGroup would be more in line with other methods in this interface.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

public class ExceptionUtils {

public interface ThrowingLambda<T extends Exception, R> {
R doIt() throws T;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since T is never used (see ? extends in unchecked), I think we could get rid of this custom interface in favor of Callable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

R doIt() throws T;
}

public static <R> R unchecked(ThrowingLambda<? extends Exception, R> throwingLambda) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add Javadoc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

/**
* Recommend configurations by the mpack advisor, then store the results in cluster topology.
* @param clusterTopology cluster topology instance
* @param userProvidedConfigurations User configurations of cluster provided in Blueprint + Cluster template
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this doc (with the exception of "mpack") belongs to the interface being implemented.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

static
{
userContext = new HashMap<>();
userContext.put("operation", "ClusterCreate");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be replaced with an ImmutableMap, initialized at the field declaration?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

private static MpackAdvisorHelper mpackAdvisorHelper;

static final String RECOMMENDATION_FAILED = "Configuration recommendation failed.";
static final String INVALID_RESPONSE = "Configuration recommendation returned with invalid response.";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These constants could be extracted to the interface to avoid duplication.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Set<Component> components = entry.getValue();
components.forEach( component -> {
Set<String> mpacksForComponent = getMpacksForComponent(component, componentNameToMpacks);
mpacksForComponent.forEach(mpack -> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way this class associates components to mpacks (and services in copyAndEnrichMpackInstances) is a bit redundant, since it's already performed by StackComponentResolver and the result is stored in ResolvedComponent instances. If some information is missing, I think it should be added there to avoid duplicated, and potentially different, implementations.

Copy link
Copy Markdown
Contributor Author

@benyoka benyoka Sep 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I've rewritten the logic to leverage ResolvedComponent's.

@asfgit
Copy link
Copy Markdown

asfgit commented Sep 11, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/3906/
Test FAILed.
Test FAILured.

@asfgit
Copy link
Copy Markdown

asfgit commented Sep 11, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/3910/
Test FAILed.
Test FAILured.

Map<StackId, Set<String>> mpackServices = topology.getComponents().collect(toMap(
ResolvedComponent::stackId,
comp -> ImmutableSet.of(comp.serviceInfo().getName()),
(set1, set2) -> ImmutableSet.copyOf(Sets.union(set1, set2))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be done less expensively (and perhaps more simply) by using built-ins:

Map<StackId, Set<String>> mpackServices = topology.getComponents().collect(
  groupingBy(ResolvedComponent::stackId,
    mapping(comp -> comp.serviceInfo().getName(), toSet())));

@benyoka
Copy link
Copy Markdown
Contributor Author

benyoka commented Sep 12, 2018

Looks like many test failures are due to this change. Looking into it.

@asfgit
Copy link
Copy Markdown

asfgit commented Sep 12, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/3919/
Test FAILed.
Test FAILured.

@asfgit
Copy link
Copy Markdown

asfgit commented Sep 12, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/3922/
Test FAILed.
Test FAILured.

@adoroszlai
Copy link
Copy Markdown
Contributor

Thanks for the changes. Please make sure to fix the remaining unit tests, if possible.

@asfgit
Copy link
Copy Markdown

asfgit commented Sep 12, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/3925/
Test FAILed.
Test FAILured.

@benyoka
Copy link
Copy Markdown
Contributor Author

benyoka commented Sep 12, 2018

retest this please

@asfgit
Copy link
Copy Markdown

asfgit commented Sep 12, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/3929/
Test FAILed.
Test FAILured.

@benyoka
Copy link
Copy Markdown
Contributor Author

benyoka commented Sep 13, 2018

retest this please

@adoroszlai
Copy link
Copy Markdown
Contributor

Latest build failed at Python tests, and is not caused by this change, happens on the base branch, too.

FAIL: test_get_stack_feature (TestStackFeature.TestStackFeature)

@asfgit
Copy link
Copy Markdown

asfgit commented Sep 13, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/Ambari-Github-PullRequest-Builder/3933/
Test FAILed.
Test FAILured.

@benyoka benyoka merged commit 1edb62b into apache:branch-feature-AMBARI-14714 Sep 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants