Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up inference around parsing name:version strings #737

Merged
merged 8 commits into from
Jun 30, 2017

Conversation

ahgittin
Copy link
Contributor

We've had some rough heuristics how to find name and version but not a strict definition.

This adds strict definitions in RegisteredTypeNaming (first commit).

It then changes core to prefer these methods. It doesn't change behaviour (except in a few fringe cases noted), but it does add log warnings where we were relying on hokey old strategies (previously assumed something was a version if it started with a number, that's it).

Then clean up a bunch of deprecated stuff where the above was used.

The methods in RegisteredTypeNaming let us hedge a little bit whether we want to be strict with OSGi versions or not. That's a subject for another PR (but an important one as discussed at #672).

@ahgittin
Copy link
Contributor Author

(There is a failing test, I'm working on that, otherwise this is good to review.)

@ahgittin ahgittin changed the title [WIP] Clean up inference around parsing name:version strings Clean up inference around parsing name:version strings Jun 20, 2017
@ahgittin
Copy link
Contributor Author

@geomacy @neykov ready for review. does not do the version changes discussed on ML but prepares us for them (and helped me understand them). this is mainly to fix issues where people have used funny v1 version strings.

@ahgittin
Copy link
Contributor Author

(the test failure is a test env config issue in hudson remoting)

ahgittin added a commit to ahgittin/brooklyn-server that referenced this pull request Jun 21, 2017
@ahgittin
Copy link
Contributor Author

re tests - see #740 which merges this and test pass

ahgittin added a commit to ahgittin/brooklyn-server that referenced this pull request Jun 22, 2017
@ahgittin ahgittin mentioned this pull request Jun 22, 2017
@geomacy
Copy link
Contributor

geomacy commented Jun 22, 2017

@ahgittin haven't ignored this but haven't been able to find the bandwidth to look at it - will be off tomorrow, but will look at this and related PRs on Monday!

Copy link
Contributor

@geomacy geomacy left a comment

Choose a reason for hiding this comment

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

Broadly this looks good but I don't feel I've got to the bottom of it yet - I have a question in particular about the code in BasicBrooklynCatalog.attemptType, see my comment there, could you add some detail around that?

/**
* For type names we currently work with any non-empty string that does not contain
* a ':' or whitespace or forward slash or backslash.
* However we discourage things that are not OSGi symbolic names; see {@link #isValidTypeName(String)}.
Copy link
Contributor

Choose a reason for hiding this comment

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

isGoodTypeName not isValidTypeName

public final static String QUALIFIER = OSGI_TOKEN_REGEX;
public final static String VERSION_REGEX =
NUMBER +
"(" + "\\." + NUMBER +
Copy link
Contributor

Choose a reason for hiding this comment

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

You've already defined DOT, might as well use it here.

@@ -82,7 +79,6 @@
* This generates instances of a template resolver that use a {@link ServiceTypeResolver}
Copy link
Contributor

Choose a reason for hiding this comment

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

Best to update description now ServiceTypeResolver is deleted. Should probably also remove this now too.

@@ -601,14 +602,34 @@ private void collectCatalogItems(String sourceYaml, Map<?,?> itemMetadata, List<
// if symname not set, infer from: id, then name, then item id, then item name
if (Strings.isBlank(symbolicName)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The changes in this block and the one below on versions are really pushing the line number count of this method, would be nice to split them out into another method; could it even be a method of RegisteredTypeNaming?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

want to completely gut this class as soon as #363 YOML is available, and remove much of this once 0.12.0 is out -- refactoring i think would make that harder as well as of course not being worth the effort if we're gutting it

if (candidateCiType == candidate.getCatalogItemType() &&
(type.equals(candidate.getSymbolicName()) || type.equals(candidate.getId()))) {
if (version==null || version.equals(candidate.getVersion())) {
log.warn("Lookup of '"+type+"' version '"+version+"' only worked using legacy routines; please advise Brooklyn community so they understand why");
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should even make this an error to highlight it more?

}
{
// legacy routine; should be the same as above code added in 0.12 because:
// if type is symbolic_name, the type will match below, and version will be null so any version allowed to match
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm afraid I don't follow this - is it the case that a type which is just a symbolic_name will be taken care of by line 900 above (so you actually mean "the type will match above" on this line i.e. at line 900); but how is the next case handled, where type is of form symbolic_name:version? When you say the id will match, where does that happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, should be above

Copy link
Contributor

Choose a reason for hiding this comment

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

grand, but how about the question above where type is of form symbolic_name:version? When you say "the id will match", where does that happen?

@geomacy
Copy link
Contributor

geomacy commented Jun 26, 2017

Would also be interested in @neykov's comments on this!

@neykov
Copy link
Member

neykov commented Jun 27, 2017

@geomacy left my comments in #740 which includes this PR.

@geomacy
Copy link
Contributor

geomacy commented Jun 27, 2017

👍 I was going to look at that next :-)

@ahgittin
Copy link
Contributor Author

great comments here @geomacy , addressed all except where commented above; moving on to #740

@asfgit asfgit merged commit 0236dbc into apache:master Jun 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants