You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Rob Baccus <ro...@audiencescience.com> on 2009/10/01 23:53:40 UTC

How do we find the Server the client is connected to?

How do I determine the server the client is connected to?  It is not
exposed as far as I can see in either the ZooKeep object or the
ClentCnxn object.  I did find on line 790 in ClientCnxn.StartConnect()
method the place the actual server connection is happening but that is
not exposed.

Rob Baccus
425-201-3812


Re: How do we find the Server the client is connected to?

Posted by Patrick Hunt <ph...@apache.org>.
Possible, but very ugly. I do something similar to this in zk tests:
org.apache.zookeeper.server.quorum.QuorumPeerMainTest.testBadPeerAddressInQuorum()
if you want to see an example.

Patrick

Ted Dunning wrote:
> Grovel the logs.
> 
> On Thu, Oct 1, 2009 at 3:46 PM, Todd Greenwood <to...@audiencescience.com>wrote:
> 
>> Failover testing.
>>
>>> -----Original Message-----
>>> From: Patrick Hunt [mailto:phunt@apache.org]
>>> Sent: Thursday, October 01, 2009 3:44 PM
>>> To: zookeeper-user@hadoop.apache.org; Rob Baccus
>>> Subject: Re: How do we find the Server the client is connected to?
>>>
>>> That detail is purposefully not exposed through the client api,
>> however
>>> it is output to the log on connection establishment.
>>>
>>> Why would your client code need to know which server in the ensemble
>> it
>>> is connected to?
>>>
>>> Patrick
>>>
>>> Rob Baccus wrote:
>>>> How do I determine the server the client is connected to?  It is not
>>>> exposed as far as I can see in either the ZooKeep object or the
>>>> ClentCnxn object.  I did find on line 790 in
>> ClientCnxn.StartConnect()
>>>> method the place the actual server connection is happening but that
>> is
>>>> not exposed.
>>>>
>>>> Rob Baccus
>>>> 425-201-3812
>>>>
>>>>
> 
> 
> 

Re: How do we find the Server the client is connected to?

Posted by Ted Dunning <te...@gmail.com>.
Grovel the logs.

On Thu, Oct 1, 2009 at 3:46 PM, Todd Greenwood <to...@audiencescience.com>wrote:

> Failover testing.
>
> > -----Original Message-----
> > From: Patrick Hunt [mailto:phunt@apache.org]
> > Sent: Thursday, October 01, 2009 3:44 PM
> > To: zookeeper-user@hadoop.apache.org; Rob Baccus
> > Subject: Re: How do we find the Server the client is connected to?
> >
> > That detail is purposefully not exposed through the client api,
> however
> > it is output to the log on connection establishment.
> >
> > Why would your client code need to know which server in the ensemble
> it
> > is connected to?
> >
> > Patrick
> >
> > Rob Baccus wrote:
> > > How do I determine the server the client is connected to?  It is not
> > > exposed as far as I can see in either the ZooKeep object or the
> > > ClentCnxn object.  I did find on line 790 in
> ClientCnxn.StartConnect()
> > > method the place the actual server connection is happening but that
> is
> > > not exposed.
> > >
> > > Rob Baccus
> > > 425-201-3812
> > >
> > >
>



-- 
Ted Dunning, CTO
DeepDyve

Re: How do we find the Server the client is connected to?

Posted by Patrick Hunt <ph...@apache.org>.
It's possible, but not pretty.

Try this:

1) create a subclass of ZooKeeper to be used in your tests

2) in the subclass add something like this:

     public String getConnectedServer() {
         return ((SocketChannel)cnxn.sendThread.sockKey.channel()).socket()
             .getInetAddress().toString();
     }

Feel free to add a JIRA, I think we could make this a protected method 
on ZooKeeper to make testing easier (and not expose internals).

Regards,

Patrick

Todd Greenwood wrote:
> Failover testing.
> 
>> -----Original Message-----
>> From: Patrick Hunt [mailto:phunt@apache.org]
>> Sent: Thursday, October 01, 2009 3:44 PM
>> To: zookeeper-user@hadoop.apache.org; Rob Baccus
>> Subject: Re: How do we find the Server the client is connected to?
>>
>> That detail is purposefully not exposed through the client api,
> however
>> it is output to the log on connection establishment.
>>
>> Why would your client code need to know which server in the ensemble
> it
>> is connected to?
>>
>> Patrick
>>
>> Rob Baccus wrote:
>>> How do I determine the server the client is connected to?  It is not
>>> exposed as far as I can see in either the ZooKeep object or the
>>> ClentCnxn object.  I did find on line 790 in
> ClientCnxn.StartConnect()
>>> method the place the actual server connection is happening but that
> is
>>> not exposed.
>>>
>>> Rob Baccus
>>> 425-201-3812
>>>
>>>

RE: How do we find the Server the client is connected to?

Posted by Todd Greenwood <to...@audiencescience.com>.
Failover testing.

> -----Original Message-----
> From: Patrick Hunt [mailto:phunt@apache.org]
> Sent: Thursday, October 01, 2009 3:44 PM
> To: zookeeper-user@hadoop.apache.org; Rob Baccus
> Subject: Re: How do we find the Server the client is connected to?
> 
> That detail is purposefully not exposed through the client api,
however
> it is output to the log on connection establishment.
> 
> Why would your client code need to know which server in the ensemble
it
> is connected to?
> 
> Patrick
> 
> Rob Baccus wrote:
> > How do I determine the server the client is connected to?  It is not
> > exposed as far as I can see in either the ZooKeep object or the
> > ClentCnxn object.  I did find on line 790 in
ClientCnxn.StartConnect()
> > method the place the actual server connection is happening but that
is
> > not exposed.
> >
> > Rob Baccus
> > 425-201-3812
> >
> >

Re: How do we find the Server the client is connected to?

Posted by Patrick Hunt <ph...@apache.org>.
That detail is purposefully not exposed through the client api, however 
it is output to the log on connection establishment.

Why would your client code need to know which server in the ensemble it 
is connected to?

Patrick

Rob Baccus wrote:
> How do I determine the server the client is connected to?  It is not
> exposed as far as I can see in either the ZooKeep object or the
> ClentCnxn object.  I did find on line 790 in ClientCnxn.StartConnect()
> method the place the actual server connection is happening but that is
> not exposed.
> 
> Rob Baccus
> 425-201-3812
> 
>