You will need to write a NameResolver 
<https://github.com/grpc/grpc-java/blob/v1.1.1/core/src/main/java/io/grpc/NameResolver.java#L50>
 
to talk to ZooKeeper and get the server addresses.
Then you can use either the stock RoundRobinLoadBalancer 
<https://github.com/grpc/grpc-java/blob/v1.1.1/core/src/main/java/io/grpc/util/RoundRobinLoadBalancerFactory.java>,
 
or implement your own LoadBalancer 
<https://github.com/grpc/grpc-java/blob/v1.1.1/core/src/main/java/io/grpc/LoadBalancer.java>
.

Pass the NameResolver and LoadBalancer factories to ManagedChannelBuilder's 
nameResolverFactory() 
<https://github.com/grpc/grpc-java/blob/v1.1.1/core/src/main/java/io/grpc/ManagedChannelBuilder.java#L155>
 
and loadBalancerFactory() 
<https://github.com/grpc/grpc-java/blob/v1.1.1/core/src/main/java/io/grpc/ManagedChannelBuilder.java#L166>
.

The addresses emitted from NameResolver are passed to LoadBalancer.

If you write your own LoadBalancer, be aware of the upcoming API change 
<https://groups.google.com/d/msg/grpc-io/Rzr2mQIgHVc/UMkPunYKAAAJ>.

On Wednesday, February 1, 2017 at 8:27:17 PM UTC-8, Abhinay reddy wrote:
>
> Thanks for your reply!
>
> I can have zookeeper address schema. Could you please let me know how can 
> I implement this in regards to grpc client
>
> Thanks 
> Abhi
>
> On Wed, Feb 1, 2017 at 8:23 PM, <[email protected] <javascript:>> 
> wrote:
>
>> Trying to implement load balancer in gRPC client in JAVA, not sure how to 
>> implement. Can anyone help me out?
>>
>> I have been using managedChannel.forAddress("")...If I use load balancer 
>> where should I provide multiple server addresses?
>>
>> On Thursday, 11 August 2016 18:22:52 UTC-7, archerhui wrote:
>>>
>>> Hi,
>>>
>>> The grpc-java lb api has been under testapi for a few months. I wonder 
>>> if there is a forecast date when the function is ready to release? And as 
>>> for the name service resolver, if there is a plan to support zookeeper 
>>> address schema?
>>>
>>> Looking forward to your reply.
>>>
>>> Thanks,
>>>
>>> Hui
>>>
>>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "grpc.io" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/grpc-io/CLApO9C16y0/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/grpc-io.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/grpc-io/413aabc4-de93-45f9-963b-a635cfe007cd%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/grpc-io/413aabc4-de93-45f9-963b-a635cfe007cd%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/78de87f3-8952-47ea-a1d4-23f2dce19c7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to