Hi Carl,
Thanks for the reply.Due to timeline constraints I switch back to round
robin default dns solver as below.It is serving the purpose for the current
work load.In future surely I ll do further R n D on Eureka considering your
inputs as well.Here is the code I fallabacked to.

 ManagedChannelBuilder.forTarget(grpcHostTmp.getHost() + ":" +
grpcHostTmp.getPort())
.nameResolverFactory(new
DnsNameResolverProvider()).executor(messagingThreadPoolExecutor)
.loadBalancerFactory(RoundRobinLoadBalancerFactory.getInstance()).usePlaintext(true).build());


Is there anyway to load balance requests evenly across nodes with
DnsNameResolverProvider .Rightnow whats happening is till a node is going
down same node takes the load after that node goes down next node takes the
load.

Is there a way to rotate requests as in active active mode rather than
above active passive mode.

I am looking for a grpc built in solution without 3rd party eureka ,zoo
keeper.Or Do you have plans to incorporate better load balancing apis to
the grpc core libs??

Thanks,
Isuru


On Fri, Aug 10, 2018 at 10:41 PM, Carl Mastrangelo <[email protected]>
wrote:

> I believe you need to create the InetSocketAddress from an IP address,
> rather than a host name.  Typically host names are looked up via DNS (not
> sure what Eureka returns to you).   If you use the normal InetSocketAddress
> constructor, Java will do the DNS lookup for you.
>
> (It is also possible to not use Java's DNS resolver, but that's more
> complex.  I'd avoid it until you know you need it)
>
> On Thu, Aug 9, 2018 at 11:28 PM Isuru Samaraweera <[email protected]>
> wrote:
>
>> Hi Carl,
>> Thanks for the  reply.However when I do the eureka address lookup ,lookup
>> seems fine.But at the time stub method is invoked asynchronously below
>> error pops up.
>>
>> Caused by: java.nio.channels.UnresolvedAddressException
>> at sun.nio.ch.Net.checkAddress(Net.java:101)
>> at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:622)
>> at io.netty.util.internal.SocketUtils$3.run(SocketUtils.java:83)
>> at io.netty.util.internal.SocketUtils$3.run(SocketUtils.java:80)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at io.netty.util.internal.SocketUtils.connect(SocketUtils.java:80)
>> at io.netty.channel.socket.nio.NioSocketChannel.doConnect(
>> NioSocketChannel.java:310)
>> at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.connect(
>> AbstractNioChannel.java:254)
>> at io.netty.channel.DefaultChannelPipeline$HeadContext.connect(
>> DefaultChannelPipeline.java:1366)
>> at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(
>> AbstractChannelHandlerContext.java:545)
>> at io.netty.channel.AbstractChannelHandlerContext.connect(
>> AbstractChannelHandlerContext.java:530)
>> at io.netty.handler.codec.http2.Http2ConnectionHandler.connect(
>> Http2ConnectionHandler.java:461)
>> at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(
>> AbstractChannelHandlerContext.java:545)
>> at io.netty.channel.AbstractChannelHandlerContext.connect(
>> AbstractChannelHandlerContext.java:530)
>> at io.netty.channel.ChannelDuplexHandler.connect(
>> ChannelDuplexHandler.java:50)
>> at io.grpc.netty.ProtocolNegotiators$AbstractBufferingHandler.
>> connect(ProtocolNegotiators.java:466)
>> at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(
>> AbstractChannelHandlerContext.java:545)
>> at io.netty.channel.AbstractChannelHandlerContext.access$1000(
>> AbstractChannelHandlerContext.java:38)
>> at io.netty.channel.AbstractChannelHandlerContext$11.run(
>> AbstractChannelHandlerContext.java:535)
>> at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(
>> AbstractEventExecutor.java:163)
>> at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(
>> SingleThreadEventExecutor.java:404)
>> at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:465)
>> at io.netty.util.concurrent.SingleThreadEventExecutor$5.
>> run(SingleThreadEventExecutor.java:884)
>> at io.netty.util.concurrent.FastThreadLocalRunnable.run(
>> FastThreadLocalRunnable.java:30)
>>
>>
>>
>> I do the lookup as below .
>>
>> Application application = eurekaClient.getApplication(serviceName);
>> List<EquivalentAddressGroup> servers = new ArrayList<>();
>> for (InstanceInfo serviceInstance : application.getInstances()) {
>> servers.add(new EquivalentAddressGroup(
>> InetSocketAddress.createUnresolved(serviceInstance.getHostName(),
>> serviceInstance.getPort())));
>> }
>> listener.onAddresses(servers, Attributes.EMPTY);
>>
>>
>> Lookup looks up addressed properly.
>>
>> Do you have any clue on why above exception is thrown when stub method is
>> invoked??
>>
>>
>>
>> On Fri, Aug 10, 2018 at 3:24 AM, 'Carl Mastrangelo' via grpc.io <
>> [email protected]> wrote:
>>
>>> It is safe to share the channel.   The decision of which server is
>>> actually up to the load balancer, and it will correctly stop sending
>>> traffic to a server if the connection fails.
>>>
>>> On Thursday, August 9, 2018 at 8:56:08 AM UTC-7, Isuru Samaraweera wrote:
>>>>
>>>> Hi All,
>>>>
>>>> I am trying to use Eureka as a discovery server and do roundrobin
>>>> clientside load balancing in the grpc client level.I have 3 GRPC server
>>>> nodes registered in Eureka.
>>>>
>>>> Here is the way I create a ManagedChannel in  the client.
>>>>
>>>> EurekaClientConfig eurekaClientConfig = new
>>>> DefaultEurekaClientConfig();
>>>> ManagedChannel channel =  ManagedChannelBuilder
>>>>                .forTarget("eureka://" + "service-aeroline-passenger-
>>>> messaging")
>>>>                 .nameResolverFactory(new 
>>>> EurekaNameResolverProvider(eurekaClientConfig,
>>>> "9071"))
>>>>                 .loadBalancerFactory(RoundRobinLoadBalancerFactory.
>>>> getInstance())
>>>>                 .usePlaintext(true)
>>>>                 .build();
>>>>
>>>> My question is is it ok to create one channel and share across the
>>>> client application presuming that channel rotation across various nodes of
>>>> GRPC server is taken care by
>>>> the ManagedChannel it self.  i.e if server1 goes down does the channel
>>>> automatically diverted to server2 without creating a new channel object???
>>>>
>>>> Thanks,
>>>> Isuru
>>>>
>>>>
>>>> --
>>> 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/7g4PAv_7Clo/unsubscribe.
>>> To unsubscribe from this group and all its topics, 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/4460b577-ebd2-40d5-aa1f-182a1f4af411%40googlegroups.com
>>> <https://groups.google.com/d/msgid/grpc-io/4460b577-ebd2-40d5-aa1f-182a1f4af411%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Isuru Samaraweera
>>
>


-- 
Isuru Samaraweera

-- 
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/CAOtGh-p89GnauxhLMmGiSheFJXSH0Q5AfzwSbt-ahcXMm04oEw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to