Class NonblockingSocketClientHandler

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, net.morimekta.providence.PServiceCallHandler

    public class NonblockingSocketClientHandler
    extends java.lang.Object
    implements net.morimekta.providence.PServiceCallHandler, java.io.Closeable
    Client handler for thrift RPC using the TNonblockingServer, or similar that uses the TFramedTransport message wrapper. It is able to handle a true async-like message and response order, so even if the server sends responses out of order this client will match to the correct caller. The client handler is dependent on that there is a single client with unique sequence IDs on incoming service calls, otherwise there will be trouble with matching responses to the requesting thread. When using this client handler make sure to close it when no longer in use. Otherwise it will keep the socket channel open almost indefinitely.
    • Constructor Summary

      Constructors 
      Constructor Description
      NonblockingSocketClientHandler​(net.morimekta.providence.serializer.Serializer serializer, java.net.SocketAddress address, net.morimekta.providence.descriptor.PService service)  
      NonblockingSocketClientHandler​(net.morimekta.providence.serializer.Serializer serializer, java.net.SocketAddress address, net.morimekta.providence.descriptor.PService service, int connect_timeout, int read_timeout)  
      NonblockingSocketClientHandler​(net.morimekta.providence.serializer.Serializer serializer, java.net.SocketAddress address, net.morimekta.providence.descriptor.PService service, net.morimekta.providence.PServiceCallInstrumentation instrumentation)  
      NonblockingSocketClientHandler​(net.morimekta.providence.serializer.Serializer serializer, java.net.SocketAddress address, net.morimekta.providence.descriptor.PService service, net.morimekta.providence.PServiceCallInstrumentation instrumentation, int connect_timeout, int read_timeout)  
      NonblockingSocketClientHandler​(net.morimekta.providence.serializer.Serializer serializer, java.net.SocketAddress address, net.morimekta.providence.descriptor.PService service, net.morimekta.providence.PServiceCallInstrumentation instrumentation, int connect_timeout, int read_timeout, int response_timeout)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      <Request extends net.morimekta.providence.PMessage<Request>,​Response extends net.morimekta.providence.PMessage<Response>>
      net.morimekta.providence.PServiceCall<Response>
      handleCall​(net.morimekta.providence.PServiceCall<Request> call, net.morimekta.providence.descriptor.PService service)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NonblockingSocketClientHandler

        public NonblockingSocketClientHandler​(net.morimekta.providence.serializer.Serializer serializer,
                                              java.net.SocketAddress address,
                                              net.morimekta.providence.descriptor.PService service)
      • NonblockingSocketClientHandler

        public NonblockingSocketClientHandler​(net.morimekta.providence.serializer.Serializer serializer,
                                              java.net.SocketAddress address,
                                              net.morimekta.providence.descriptor.PService service,
                                              net.morimekta.providence.PServiceCallInstrumentation instrumentation)
      • NonblockingSocketClientHandler

        public NonblockingSocketClientHandler​(net.morimekta.providence.serializer.Serializer serializer,
                                              java.net.SocketAddress address,
                                              net.morimekta.providence.descriptor.PService service,
                                              int connect_timeout,
                                              int read_timeout)
      • NonblockingSocketClientHandler

        public NonblockingSocketClientHandler​(net.morimekta.providence.serializer.Serializer serializer,
                                              java.net.SocketAddress address,
                                              net.morimekta.providence.descriptor.PService service,
                                              net.morimekta.providence.PServiceCallInstrumentation instrumentation,
                                              int connect_timeout,
                                              int read_timeout)
      • NonblockingSocketClientHandler

        public NonblockingSocketClientHandler​(net.morimekta.providence.serializer.Serializer serializer,
                                              java.net.SocketAddress address,
                                              net.morimekta.providence.descriptor.PService service,
                                              net.morimekta.providence.PServiceCallInstrumentation instrumentation,
                                              int connect_timeout,
                                              int read_timeout,
                                              int response_timeout)
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • handleCall

        public <Request extends net.morimekta.providence.PMessage<Request>,​Response extends net.morimekta.providence.PMessage<Response>> net.morimekta.providence.PServiceCall<Response> handleCall​(net.morimekta.providence.PServiceCall<Request> call,
                                                                                                                                                                                                          net.morimekta.providence.descriptor.PService service)
                                                                                                                                                                                                   throws java.io.IOException
        Specified by:
        handleCall in interface net.morimekta.providence.PServiceCallHandler
        Throws:
        java.io.IOException