Package com.yahoo.jrt

Class Supervisor


  • public class Supervisor
    extends java.lang.Object
    A Supervisor keeps a method repository and handles dispatching of incoming invocation requests. Each end-point of a connection is represented by a Target object and each Target is associated with a single Supervisor that handles the invocation requests obtained from that Target. Note that RPC invocations can be performed both ways across a connection, so even the client side of a connection has RPC server capabilities.
    • Constructor Detail

      • Supervisor

        public Supervisor​(Transport transport)
        Create a new Supervisor based on the given Transport
        Parameters:
        transport - object performing low-level operations for this Supervisor
    • Method Detail

      • setMaxInputBufferSize

        public void setMaxInputBufferSize​(int bytes)
        Set maximum input buffer size. This value will only affect connections that use a common input buffer when decoding incoming packets. Note that this value is not an absolute max. The buffer will still grow larger than this value if needed to decode big packets. However, when the buffer becomes larger than this value, it will be shrunk back when possible.
        Parameters:
        bytes - buffer size in bytes. 0 means unlimited.
      • setMaxOutputBufferSize

        public void setMaxOutputBufferSize​(int bytes)
        Set maximum output buffer size. This value will only affect connections that use a common output buffer when encoding outgoing packets. Note that this value is not an absolute max. The buffer will still grow larger than this value if needed to encode big packets. However, when the buffer becomes larger than this value, it will be shrunk back when possible.
        Parameters:
        bytes - buffer size in bytes. 0 means unlimited.
      • transport

        public Transport transport()
        Obtain the underlying Transport object.
        Returns:
        underlying Transport object
      • setSessionHandler

        public void setSessionHandler​(SessionHandler handler)
        Set the session handler for this Supervisor
        Parameters:
        handler - the session handler
      • addMethod

        public void addMethod​(Method method)
        Add a method to the set of methods held by this Supervisor
        Parameters:
        method - the method to add
      • removeMethod

        public void removeMethod​(Method method)
        Remove a method from the set of methods held by this Supervisor. Use this if you know exactly which method to remove and not only the name.
        Parameters:
        method - the method to remove
      • connect

        public Target connect​(Spec spec,
                              java.lang.Object context)
        Connect to the given address. The new Target will be associated with this Supervisor and will have 'context' as application context.
        Parameters:
        spec - where to connect
        context - application context for the Target
        Returns:
        Target representing our end of the connection
        See Also:
        Target.getContext()
      • listen

        public Acceptor listen​(Spec spec)
                        throws ListenFailedException
        Listen to the given address.
        Parameters:
        spec - the address to listen to
        Returns:
        active object accepting new connections that will be associated with this Supervisor
        Throws:
        ListenFailedException
      • invokeBatch

        public void invokeBatch​(Spec spec,
                                Request req,
                                double timeout)
        Convenience method for connecting to a peer, invoking a method and disconnecting.
        Parameters:
        spec - the address to connect to
        req - the invocation request
        timeout - request timeout in seconds