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

Zookeeper name resolver #2549

Merged
merged 64 commits into from
Aug 14, 2015
Merged

Zookeeper name resolver #2549

merged 64 commits into from
Aug 14, 2015

Conversation

hongweiwang
Copy link
Contributor

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 be zookeeper://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.

@grpc-kokoro
Copy link

Can one of the admins verify this patch?

@nicolasnoble
Copy link
Member

This is ok to test.

Also, you'll need to merge master again, it seems :)

@hongweiwang hongweiwang changed the title Zookeeper Name Resolver Zookeeper name resolver Jul 21, 2015

/* 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,
Copy link
Member

Choose a reason for hiding this comment

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

is this blocking?

Copy link
Contributor Author

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.

@ctiller
Copy link
Member

ctiller commented Jul 21, 2015

test this please

@ctiller
Copy link
Member

ctiller commented Jul 21, 2015

This is ok to test.

@ctiller
Copy link
Member

ctiller commented Jul 22, 2015

David - can you do a first pass review over this?

@dgquintas
Copy link
Contributor

On it.

extern "C" {
#endif

/* Register zookeeper name resolver in grpc */
Copy link
Contributor

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.
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. change "deinitialized" to "destroyed". Same for the argument "deinit" -> "destroy"
  2. 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.

@dgquintas
Copy link
Contributor

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() {
Copy link
Member

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.

@dgquintas
Copy link
Contributor

LGTM. Any last words before I merge? :)

dgquintas added a commit that referenced this pull request Aug 14, 2015
@dgquintas dgquintas merged commit bd0d1bd into grpc:master Aug 14, 2015
@stanley-cheung
Copy link
Contributor

When I try to do a sudo make install after make in the base grpc directory, I got this error

[INSTALL] Installing public C headers
[MAKE]    Generating cache.mk
[STRIP]   Stripping libgpr.a
[STRIP]   Stripping libgrpc.a
[STRIP]   Stripping libgrpc_unsecure.a
[STRIP]   Stripping libgrpc_zookeeper.a
strip: './libs/opt/libgrpc_zookeeper.a': No such file
make: *** [strip-static_c] Error 1

@hongweiwang
Copy link
Contributor Author

Fixed by #2941

@jtattermusch
Copy link
Contributor

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.

"c:\jenkins\workspace\gRPC_master\config\dbg\language\csharp\platform\windows\vsprojects\grpc_zookeeper\grpc_zookeeper.vcxproj.metaproj" (default target) (7) ->

(Build target) -> 

  c:\jenkins\workspace\gRPC_master\config\dbg\language\csharp\platform\windows\vsprojects\grpc_zookeeper\grpc_zookeeper.vcxproj.metaproj : error MSB3202: The project file "c:\jenkins\workspace\gRPC_master\config\dbg\language\csharp\platform\windows\vsprojects\grpc_zookeeper\grpc_zookeeper.vcxproj" was not found.

@hongweiwang
Copy link
Contributor Author

I am sorry about it. @nicolasnoble helps me on grpc_zookeeper building. Please contact him to fix it.

@huidi7
Copy link

huidi7 commented Aug 9, 2016

@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.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 26, 2019
@lock lock bot unassigned dgquintas Jan 26, 2019
@thelinuxfoundation
Copy link

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,
CLA GitHub bot

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants