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: [email protected]
> Subject: Tracking client IP address at thrift server
> To: [email protected]
>
> 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