You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Akshay Singh <ak...@yahoo.com> on 2012/08/17 20:40:29 UTC
Tracking client IP address at thrift server
Hi users,
I am (very) new to Thrift, so might be asking a question which has been answered many times.
I
am running a thrift server, which is accessed by multiple clients. I
simply to want to keep track of the requesting client's address at
server, and update some counters based on that.
Web search gave me these relevant links,
https://issues.apache.org/jira/browse/THRIFT-1053
http://grokbase.com/t/thrift/user/11aqrp2782/how-can-i-get-the-clients-ip-from-the-server-of-thrift
But I could not really make out a simple method to obtain the address the client machines at server. Please help.
Regards,
Akshay
RE: Tracking client IP address at thrift server
Posted by Craig Artley <ca...@hotmail.com>.
I did it by decorating the TProcessor like this psuedo-code.
-craig
class TrackingProcessor implements TProcessor {
TrackingProcessor (TProcessor processor) {this.processor=processor;}
public boolean process(TProtocol in, TProtocol out) throws TException {
TTransport t = in.getTransport();
InetAddress ia = t instanceof TSocket ?
((TSocket)t).getSocket().getInetAddress() : null;
// Now you have the IP address, so what ever you want.
// Delegate to the processor we are decorating.
return processor.process(in,out);
}
}
----------------------------------------
> Date: Sat, 18 Aug 2012 02:40:29 +0800
> From: akshay_iiit@yahoo.com
> Subject: Tracking client IP address at thrift server
> To: user@thrift.apache.org
>
> Hi users,
>
>
> I am (very) new to Thrift, so might be asking a question which has been answered many times.
>
> I
> am running a thrift server, which is accessed by multiple clients. I
> simply to want to keep track of the requesting client's address at
> server, and update some counters based on that.
>
> Web search gave me these relevant links,
> https://issues.apache.org/jira/browse/THRIFT-1053
> http://grokbase.com/t/thrift/user/11aqrp2782/how-can-i-get-the-clients-ip-from-the-server-of-thrift
>
> But I could not really make out a simple method to obtain the address the client machines at server. Please help.
>
> Regards,
> Akshay