You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Rene Winkler Sørensen <RE...@vestas.com> on 2015/06/02 11:19:10 UTC
client connect event
My team is building a client/server application using thrift over rpc/tcp, we have one requirement from our stakeholder that we find very complicated in thrift. Every time a client opens a connection, we need to log the IP of that connection, it does not matter if the client calls anything, the log have to be there. So my question is, how do I do that, as far as I can see, the options are very limited. I found an event called TServerEventHandler, but I don't get the right information there as I see it, can anyone point me in the right direction if there is one??
Yours sincerely / Med venlig hilsen
René Winkler Sørensen
Software Development Engineer
Product Development, Service Engineering
Technology & Service Solutions (TSS)
Vestas Wind Systems A/S
T: 83 11 39 97
M: +45 2245 5971
rewso@vestas.com<ma...@vestas.com>
Vestas Wind Systems A/S
This e-mail is subject to out e-mail disclaimer statement.
Please refer to http://www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender.
Re: client connect event
Posted by Mike Stanley <mi...@mikestanley.org>.
There is also the out-of-band, deployment option. Put a proxy service in
front of your services (like HAProxy) and enable logging, such as outlined
here https://transloadit.com/blog/2010/08/haproxy-logging/. This also
provides the architectural benefit of load balancing your thrift services.
On Tue, Jun 2, 2015 at 2:19 PM, Ben Craig <be...@ni.com> wrote:
> If you are using the C++ bindings, then you want to implement your own
> 'IfFactory'. For a service named 'Foo', the thrift compiler will make a
> C++ interface name 'FooIfFactory'. It also generates a class inheriting
> from FooIfFactory named 'FooIfSingletonFactory'.
>
> FooIfFactory looks something like this:
> class FooIfFactory {
> public:
> typedef FooIf Handler;
>
> virtual ~FooIfFactory() {}
>
> virtual FooIf* getHandler(const ::apache::thrift::TConnectionInfo&
> connInfo) = 0;
> virtual void releaseHandler(FooIf* /* handler */) = 0;
> };
>
> connInfo has pointers to the respective Transport classes, and you can
> dynamic_cast to get to the TSocket, and eventually to the IP.
>
>
>
> From: Stuart Reynolds <st...@stureynolds.com>
> To: user@thrift.apache.org,
> Date: 06/02/2015 11:34 AM
> Subject: Re: client connect event
> Sent by: stuart.reynolds@gmail.com
>
>
>
> Subclassing is an easy way to inject missing functionality. Override
> methods that perform your own logic and call the superclass's version
> of the method.
> TSocket / TTransport are probably the right places to add this.
>
> On Tue, Jun 2, 2015 at 2:19 AM, Rene Winkler Sørensen <RE...@vestas.com>
>
> wrote:
> > My team is building a client/server application using thrift over
> rpc/tcp, we have one requirement from our stakeholder that we find very
> complicated in thrift. Every time a client opens a connection, we need to
> log the IP of that connection, it does not matter if the client calls
> anything, the log have to be there. So my question is, how do I do that,
> as far as I can see, the options are very limited. I found an event called
>
> TServerEventHandler, but I don't get the right information there as I see
> it, can anyone point me in the right direction if there is one??
> >
> >
> > Yours sincerely / Med venlig hilsen
> >
> >
> > René Winkler Sørensen
> > Software Development Engineer
> > Product Development, Service Engineering
> > Technology & Service Solutions (TSS)
> >
> >
> > Vestas Wind Systems A/S
> > T: 83 11 39 97
> > M: +45 2245 5971
> > rewso@vestas.com<ma...@vestas.com>
> >
> > Vestas Wind Systems A/S
> > This e-mail is subject to out e-mail disclaimer statement.
> > Please refer to http://www.vestas.com/legal/notice
> > If you have received this e-mail in error please contact the sender.
> >
>
>
RE: client connect event
Posted by Rene Winkler Sørensen <RE...@vestas.com>.
Hi Ben,
Thanks for your answer, you gave me the hint that I needed.
Using the TServerEventHandler I am now able to every time a user ask for a login.
public Object createContext(Thrift.Protocol.TProtocol input, Thrift.Protocol.TProtocol output)
{
var client = ((TSocket)input.Transport).TcpClient;
_log.DebugFormat("Client {0} is now connected", client.Client.RemoteEndPoint.ToString());
return input.Transport;
}
Yours sincerely / Med venlig hilsen
René Winkler Sørensen
Software Development Engineer
Product Development, Service Engineering
Technology & Service Solutions (TSS)
Vestas Wind Systems A/S
T: 83 11 39 97
M: +45 2245 5971
rewso@vestas.com
Vestas Wind Systems A/S
This e-mail is subject to out e-mail disclaimer statement.
Please refer to http://www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender.
-----Original Message-----
From: Ben Craig [mailto:ben.craig@ni.com]
Sent: 2. juni 2015 20:20
To: user@thrift.apache.org
Cc: stuart.reynolds@gmail.com
Subject: Re: client connect event
If you are using the C++ bindings, then you want to implement your own
'IfFactory'. For a service named 'Foo', the thrift compiler will make a
C++ interface name 'FooIfFactory'. It also generates a class inheriting
from FooIfFactory named 'FooIfSingletonFactory'.
FooIfFactory looks something like this:
class FooIfFactory {
public:
typedef FooIf Handler;
virtual ~FooIfFactory() {}
virtual FooIf* getHandler(const ::apache::thrift::TConnectionInfo&
connInfo) = 0;
virtual void releaseHandler(FooIf* /* handler */) = 0;
};
connInfo has pointers to the respective Transport classes, and you can
dynamic_cast to get to the TSocket, and eventually to the IP.
From: Stuart Reynolds <st...@stureynolds.com>
To: user@thrift.apache.org,
Date: 06/02/2015 11:34 AM
Subject: Re: client connect event
Sent by: stuart.reynolds@gmail.com
Subclassing is an easy way to inject missing functionality. Override
methods that perform your own logic and call the superclass's version
of the method.
TSocket / TTransport are probably the right places to add this.
On Tue, Jun 2, 2015 at 2:19 AM, Rene Winkler Sørensen <RE...@vestas.com>
wrote:
> My team is building a client/server application using thrift over
rpc/tcp, we have one requirement from our stakeholder that we find very
complicated in thrift. Every time a client opens a connection, we need to
log the IP of that connection, it does not matter if the client calls
anything, the log have to be there. So my question is, how do I do that,
as far as I can see, the options are very limited. I found an event called
TServerEventHandler, but I don't get the right information there as I see
it, can anyone point me in the right direction if there is one??
>
>
> Yours sincerely / Med venlig hilsen
>
>
> René Winkler Sørensen
> Software Development Engineer
> Product Development, Service Engineering
> Technology & Service Solutions (TSS)
>
>
> Vestas Wind Systems A/S
> T: 83 11 39 97
> M: +45 2245 5971
> rewso@vestas.com<ma...@vestas.com>
>
> Vestas Wind Systems A/S
> This e-mail is subject to out e-mail disclaimer statement.
> Please refer to http://www.vestas.com/legal/notice
> If you have received this e-mail in error please contact the sender.
>
Re: client connect event
Posted by Ben Craig <be...@ni.com>.
If you are using the C++ bindings, then you want to implement your own
'IfFactory'. For a service named 'Foo', the thrift compiler will make a
C++ interface name 'FooIfFactory'. It also generates a class inheriting
from FooIfFactory named 'FooIfSingletonFactory'.
FooIfFactory looks something like this:
class FooIfFactory {
public:
typedef FooIf Handler;
virtual ~FooIfFactory() {}
virtual FooIf* getHandler(const ::apache::thrift::TConnectionInfo&
connInfo) = 0;
virtual void releaseHandler(FooIf* /* handler */) = 0;
};
connInfo has pointers to the respective Transport classes, and you can
dynamic_cast to get to the TSocket, and eventually to the IP.
From: Stuart Reynolds <st...@stureynolds.com>
To: user@thrift.apache.org,
Date: 06/02/2015 11:34 AM
Subject: Re: client connect event
Sent by: stuart.reynolds@gmail.com
Subclassing is an easy way to inject missing functionality. Override
methods that perform your own logic and call the superclass's version
of the method.
TSocket / TTransport are probably the right places to add this.
On Tue, Jun 2, 2015 at 2:19 AM, Rene Winkler Sørensen <RE...@vestas.com>
wrote:
> My team is building a client/server application using thrift over
rpc/tcp, we have one requirement from our stakeholder that we find very
complicated in thrift. Every time a client opens a connection, we need to
log the IP of that connection, it does not matter if the client calls
anything, the log have to be there. So my question is, how do I do that,
as far as I can see, the options are very limited. I found an event called
TServerEventHandler, but I don't get the right information there as I see
it, can anyone point me in the right direction if there is one??
>
>
> Yours sincerely / Med venlig hilsen
>
>
> René Winkler Sørensen
> Software Development Engineer
> Product Development, Service Engineering
> Technology & Service Solutions (TSS)
>
>
> Vestas Wind Systems A/S
> T: 83 11 39 97
> M: +45 2245 5971
> rewso@vestas.com<ma...@vestas.com>
>
> Vestas Wind Systems A/S
> This e-mail is subject to out e-mail disclaimer statement.
> Please refer to http://www.vestas.com/legal/notice
> If you have received this e-mail in error please contact the sender.
>
Re: client connect event
Posted by Stuart Reynolds <st...@stureynolds.com>.
Subclassing is an easy way to inject missing functionality. Override
methods that perform your own logic and call the superclass's version
of the method.
TSocket / TTransport are probably the right places to add this.
On Tue, Jun 2, 2015 at 2:19 AM, Rene Winkler Sørensen <RE...@vestas.com> wrote:
> My team is building a client/server application using thrift over rpc/tcp, we have one requirement from our stakeholder that we find very complicated in thrift. Every time a client opens a connection, we need to log the IP of that connection, it does not matter if the client calls anything, the log have to be there. So my question is, how do I do that, as far as I can see, the options are very limited. I found an event called TServerEventHandler, but I don't get the right information there as I see it, can anyone point me in the right direction if there is one??
>
>
> Yours sincerely / Med venlig hilsen
>
>
> René Winkler Sørensen
> Software Development Engineer
> Product Development, Service Engineering
> Technology & Service Solutions (TSS)
>
>
> Vestas Wind Systems A/S
> T: 83 11 39 97
> M: +45 2245 5971
> rewso@vestas.com<ma...@vestas.com>
>
> Vestas Wind Systems A/S
> This e-mail is subject to out e-mail disclaimer statement.
> Please refer to http://www.vestas.com/legal/notice
> If you have received this e-mail in error please contact the sender.
>