-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
[ZOOKEEPER-2642] Resurrect the reconfig() methods that were in ZooKeeper.java. #122
Closed
Closed
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3611d18
Resurrect the reconfig() methods that were in ZooKeeper.java. While 3…
Randgalt e975fa0
Add @Deprecated annotations
Randgalt 5e8062c
work to make Javadoc sniffer happy
Randgalt a47bcc6
Note deprecated APIs in the doc and fix some style issues in ZooKeepe…
Randgalt ee483aa
Method name is now reconfigure()
Randgalt 4e8b6c6
Merge branch 'master' into ZOOKEEPER-2642
Randgalt 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
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 |
---|---|---|
|
@@ -39,32 +39,10 @@ | |
import org.apache.zookeeper.client.ZKClientConfig; | ||
import org.apache.zookeeper.client.ZooKeeperSaslClient; | ||
import org.apache.zookeeper.common.PathUtils; | ||
import org.apache.zookeeper.common.StringUtils; | ||
import org.apache.zookeeper.data.ACL; | ||
import org.apache.zookeeper.data.Stat; | ||
import org.apache.zookeeper.proto.CheckWatchesRequest; | ||
import org.apache.zookeeper.proto.Create2Response; | ||
import org.apache.zookeeper.proto.CreateRequest; | ||
import org.apache.zookeeper.proto.CreateResponse; | ||
import org.apache.zookeeper.proto.CreateTTLRequest; | ||
import org.apache.zookeeper.proto.DeleteRequest; | ||
import org.apache.zookeeper.proto.ExistsRequest; | ||
import org.apache.zookeeper.proto.GetACLRequest; | ||
import org.apache.zookeeper.proto.GetACLResponse; | ||
import org.apache.zookeeper.proto.GetChildren2Request; | ||
import org.apache.zookeeper.proto.GetChildren2Response; | ||
import org.apache.zookeeper.proto.GetChildrenRequest; | ||
import org.apache.zookeeper.proto.GetChildrenResponse; | ||
import org.apache.zookeeper.proto.GetDataRequest; | ||
import org.apache.zookeeper.proto.GetDataResponse; | ||
import org.apache.zookeeper.proto.RemoveWatchesRequest; | ||
import org.apache.zookeeper.proto.ReplyHeader; | ||
import org.apache.zookeeper.proto.RequestHeader; | ||
import org.apache.zookeeper.proto.SetACLRequest; | ||
import org.apache.zookeeper.proto.SetACLResponse; | ||
import org.apache.zookeeper.proto.SetDataRequest; | ||
import org.apache.zookeeper.proto.SetDataResponse; | ||
import org.apache.zookeeper.proto.SyncRequest; | ||
import org.apache.zookeeper.proto.SyncResponse; | ||
import org.apache.zookeeper.proto.*; | ||
import org.apache.zookeeper.server.DataTree; | ||
import org.apache.zookeeper.server.EphemeralType; | ||
import org.slf4j.Logger; | ||
|
@@ -2175,7 +2153,42 @@ public byte[] getConfig(boolean watch, Stat stat) | |
public void getConfig(boolean watch, DataCallback cb, Object ctx) { | ||
getConfig(watch ? watchManager.defaultWatcher : null, cb, ctx); | ||
} | ||
|
||
|
||
/** | ||
* @deprecated instead use the reconfigure() methods instead in {@link org.apache.zookeeper.admin.ZooKeeperAdmin} | ||
*/ | ||
@Deprecated | ||
public byte[] reconfig(String joiningServers, String leavingServers, String newMembers, long fromConfig, Stat stat) throws KeeperException, InterruptedException { | ||
return internalReconfig(joiningServers, leavingServers, newMembers, fromConfig, stat); | ||
} | ||
|
||
/** | ||
* @deprecated instead use the reconfigure() methods instead in {@link org.apache.zookeeper.admin.ZooKeeperAdmin} | ||
*/ | ||
@Deprecated | ||
public byte[] reconfig(List<String> joiningServers, List<String> leavingServers, List<String> newMembers, long fromConfig, Stat stat) throws KeeperException, InterruptedException { | ||
return internalReconfig(joiningServers, leavingServers, newMembers, fromConfig, stat); | ||
} | ||
|
||
/** | ||
* @deprecated instead use the reconfigure() methods instead in {@link org.apache.zookeeper.admin.ZooKeeperAdmin} | ||
*/ | ||
@Deprecated | ||
public void reconfig(String joiningServers, String leavingServers, | ||
String newMembers, long fromConfig, DataCallback cb, Object ctx) { | ||
internalReconfig(joiningServers, leavingServers, newMembers, fromConfig, cb, ctx); | ||
} | ||
|
||
/** | ||
* @deprecated instead use the reconfigure() methods instead in {@link org.apache.zookeeper.admin.ZooKeeperAdmin} | ||
*/ | ||
@Deprecated | ||
public void reconfig(List<String> joiningServers, | ||
List<String> leavingServers, List<String> newMembers, long fromConfig, | ||
DataCallback cb, Object ctx) { | ||
internalReconfig(joiningServers, leavingServers, newMembers, fromConfig, cb, ctx); | ||
} | ||
|
||
/** | ||
* Set the data for the node of the given path if such a node exists and the | ||
* given version matches the version of the node (if the given version is | ||
|
@@ -2910,4 +2923,49 @@ private ClientCnxnSocket getClientCnxnSocket() throws IOException { | |
throw ioe; | ||
} | ||
} | ||
|
||
protected byte[] internalReconfig(String joiningServers, String leavingServers, String newMembers, long fromConfig, Stat stat) throws KeeperException, InterruptedException | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: inconsistent brace style for method names from line onwards. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
RequestHeader h = new RequestHeader(); | ||
h.setType(ZooDefs.OpCode.reconfig); | ||
ReconfigRequest request = new ReconfigRequest(joiningServers, leavingServers, newMembers, fromConfig); | ||
GetDataResponse response = new GetDataResponse(); | ||
ReplyHeader r = cnxn.submitRequest(h, request, response, null); | ||
if (r.getErr() != 0) { | ||
throw KeeperException.create(KeeperException.Code.get(r.getErr()), ""); | ||
} | ||
if (stat != null) { | ||
DataTree.copyStat(response.getStat(), stat); | ||
} | ||
return response.getData(); | ||
} | ||
|
||
protected byte[] internalReconfig(List<String> joiningServers, List<String> leavingServers, List<String> newMembers, long fromConfig, Stat stat) throws KeeperException, InterruptedException | ||
{ | ||
return internalReconfig(StringUtils.joinStrings(joiningServers, ","), | ||
StringUtils.joinStrings(leavingServers, ","), | ||
StringUtils.joinStrings(newMembers, ","), | ||
fromConfig, stat); | ||
} | ||
|
||
protected void internalReconfig(String joiningServers, String leavingServers, | ||
String newMembers, long fromConfig, DataCallback cb, Object ctx) | ||
{ | ||
RequestHeader h = new RequestHeader(); | ||
h.setType(ZooDefs.OpCode.reconfig); | ||
ReconfigRequest request = new ReconfigRequest(joiningServers, leavingServers, newMembers, fromConfig); | ||
GetDataResponse response = new GetDataResponse(); | ||
cnxn.queuePacket(h, new ReplyHeader(), request, response, cb, | ||
ZooDefs.CONFIG_NODE, ZooDefs.CONFIG_NODE, ctx, null); | ||
} | ||
|
||
protected void internalReconfig(List<String> joiningServers, | ||
List<String> leavingServers, List<String> newMembers, long fromConfig, | ||
DataCallback cb, Object ctx) | ||
{ | ||
internalReconfig(StringUtils.joinStrings(joiningServers, ","), | ||
StringUtils.joinStrings(leavingServers, ","), | ||
StringUtils.joinStrings(newMembers, ","), | ||
fromConfig, cb, ctx); | ||
} | ||
} |
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
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
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.
If I remember well, Patrick Hunt once told me during a code review that we should use explicit imports instead of wildcards. Right, @phunt ?
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.
fixed