-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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 name resolver #2549
Zookeeper name resolver #2549
Conversation
If a node does not contain IP or port, consider its children.
Can one of the admins verify this patch? |
This is ok to test. Also, you'll need to merge master again, it seems :) |
|
||
/* Get zookeeper node of given path r->name | ||
If not containing address(i.e. service node), get its children */ | ||
status = zoo_get(r->zookeeper_handle, r->name, GRPC_ZOOKEEPER_WATCH, |
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.
is this blocking?
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.
Currently we use zookeeper synchronous API (zoo_get), which is blocking. We can avoid it by using asynchronous API.
test this please |
This is ok to test. |
David - can you do a first pass review over this? |
On it. |
extern "C" { | ||
#endif | ||
|
||
/* Register zookeeper name resolver in grpc */ |
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.
tiny nit: please use /** so that the comment is picked up by doxygen.
@@ -355,6 +355,20 @@ typedef struct grpc_op { | |||
} data; | |||
} grpc_op; | |||
|
|||
|
|||
/** Registers a plugin to be initialized and deinitialized with the library. |
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.
what does "deinitialized" mean? Destroyed? Unregistered?
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.
- change "deinitialized" to "destroyed". Same for the argument "deinit" -> "destroy"
- Replace all but the intro line with the following:
The \a init and \a destroy functions will be invoked as part of \a grpc_init() and \a grpc_shutdown(), respectively. Note that these functions can be invoked an arbitrary number of times (and hence so will \a init and \a destroy).
It is safe to pass NULL to either argument. Plugins are destroyed in the reverse order they were initialized.
The last line is only true if you implement Nico's comment to use an array instead of the current linked list to hold the registered plugins.
I've gone over the changes again. Sorry for the delay and thanks for pinging me about it :) It looks good overall. I've added some minor comments. |
g_plugins_head->next = old_head; | ||
} | ||
|
||
void grpc_unregister_all_plugins() { |
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.
Let's actually pull that, and use a static array for the plugins instead of allocating them. 128 entries should be more than enough without wasting memory.
LGTM. Any last words before I merge? :) |
When I try to do a
|
Fixed by #2941 |
This PR have actually broken all Windows builds for 4 days. The error from Jenkins looks quite obviously related to the changes from this PR. Please check Jenkins status more carefully next time.
|
I am sorry about it. @nicolasnoble helps me on grpc_zookeeper building. Please contact him to fix it. |
@hongweiwang Hi, it seems there is limitation that the server side process has to be launched before the client when using zookeeper address for the service. If we launch the client side first, the zookeeper resolver will not try to resolve the service address any more when it finds there is no child node under the service zookeeper path. Just wonder if there is any incoming update on this. |
Thank you for your pull request. Before we can look at your contribution, we need to ensure all contributors are covered by a Contributor License Agreement. After the following items are addressed, please respond with a new comment here, and the automated system will re-verify.
Regards, |
Add zookeeper name resolver to gRPC. Zookeeper names in gRPC are represented as a URI.
zookeeper://host:port/name
Where
host:port
is zookeeper server address.name
is zookeeper path of the service. An example would bezookeeper://127.0.0.1:2181/storage/mysql
.Services are registered in zookeeper server in hierarchical format
service/instance
, similar to Apache Curator. Each service is a zookeeper node, and each instance is a child node of the service. Each instance node stores its address (host and port) in JSON format.