-
Notifications
You must be signed in to change notification settings - Fork 52
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
Conversation
changed a while ago to EntitySpecResolver; removes references to catalog items and hokey lookup
(There is a failing test, I'm working on that, otherwise this is good to review.) |
name:version
stringsname:version
strings
(the test failure is a test env config issue in hudson remoting) |
re tests - see #740 which merges this and test pass |
@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! |
There was a problem hiding this 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)}. |
There was a problem hiding this comment.
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 + |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, should be above
There was a problem hiding this comment.
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?
Would also be interested in @neykov's comments on this! |
👍 I was going to look at that next :-) |
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).