-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
CURATOR-704. Add server compatibility check support #497
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
53d30e3
CURATOR-709. Add server compatibility check support
laurentgo f9116d5
Remove newlines introduced by accident
laurentgo 0858710
Fix license header (missing newline)
laurentgo 5179c18
Remove Version enum
laurentgo 191cc6e
Update integration tests
laurentgo c50c2f8
Codestyle fix
laurentgo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
curator-client/src/main/java/org/apache/curator/utils/ZookeeperCompatibility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.curator.utils; | ||
|
||
/** | ||
* Describe feature supports based on server compatibility (as opposed to {@code Compatibility} | ||
* which represents client compatibility. | ||
*/ | ||
public interface ZookeeperCompatibility { | ||
public enum Version implements ZookeeperCompatibility { | ||
VERSION_3_5(false), | ||
LATEST(true); | ||
|
||
private final boolean hasPersistentWatchers; | ||
|
||
private Version(boolean hasPersistentWatchers) { | ||
this.hasPersistentWatchers = hasPersistentWatchers; | ||
} | ||
|
||
@Override | ||
public boolean hasPersistentWatchers() { | ||
return this.hasPersistentWatchers && Compatibility.hasPersistentWatchers(); | ||
} | ||
} | ||
|
||
/** | ||
* Check if both client and server support persistent watchers | ||
* @return {@code true} if both the client library and the server version support persistent watchers | ||
*/ | ||
boolean hasPersistentWatchers(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 am not sure that enumerating the ZK versions will pay back in the future.
What about letting the user build this object?
And we provide a default instance with all the known features
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 okay removing the enum. Do you think the user should just create the concrete class or would you prefer to introduce a
Builder
class to help with it?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 guess we probably are pursuing something similar to
ClientBuilder::assume_server_version
(I am the author). My thought was that client library know server compatibility(capabilities, bugs and etc.) given a server version.So, I think it is Curator's responsibility to build the compatibility matrix and do the dirty work but not the caller. I think we probably need only a server version (the class and the
LATEST
) in api side.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.
So I changed the code to remove the enum and replace it with a class + builder combo. Let me know if you're okay with this pattern
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 think all we want could be a simple (major, minor, patch) tuple. Curator can derive the compatibility matrix(
ZookeeperCompatibility
in your case) from (major, minor, patch).I could be biased by ClientBuilder::assume_server_version. But I think it might not be what we want to let the caller to construct the compatibility matrix (
ZookeeperCompatibility
in your case). I don't think users of Curator need such level of customization.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 getting mixed signals here. @eolivelli proposed to remove the constant for ZK 3.5 and let user build the object (and @kezhuw put a thumbs up on this comment), but then @kezhuw is proposing to have user just provide the version and curator do the work, which seems to lean back on my original proposal.
Personally, I'd okay proposing predefined constants but asking the user to provide the full version may be overly complicating things as the only version we currently care about is 3.5 vs 3.6/3.7/3.8 (as permanent watchers seems to be the only feature we are checking for)
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.
Apologize for this! @laurentgo
I do agree with @eolivelli that enumerate zookeeper version is not good.
I am not sure about this.
Yes, a bit. I guess I have same worry about this. But it is a one for all in api side. That is there will be no new feature toggle apis in future. All features could derive from that version and thus implementation detail.
Given all the candidates(feature enum, feature builder and version class), I prefer to a version class currently.
Any idea ? @eolivelli @tisonkun
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.
If there are other features (which are not captured by
Compatibility
class I guess), I'd gladly add those but I don't know enough of Curator/Zookeeper to quickly identify thoseThere 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.
This is what I am care about. We have to add new
hasXyz
each time we find one which I think is not good. But that is fine. We are unlikely to have ten features anyway 😄 .