Package com.yahoo.jrt
Class Supervisor
- java.lang.Object
-
- com.yahoo.jrt.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 aTarget
object and eachTarget
is associated with a single Supervisor that handles the invocation requests obtained from thatTarget
. 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 Summary
Constructors Constructor Description Supervisor(Transport transport)
Create a new Supervisor based on the givenTransport
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMethod(Method method)
Add a method to the set of methods held by this SupervisorTarget
connect(Spec spec)
Connect to the given address.Target
connect(Spec spec, java.lang.Object context)
Connect to the given address.void
invokeBatch(Spec spec, Request req, double timeout)
Convenience method for connecting to a peer, invoking a method and disconnecting.Acceptor
listen(Spec spec)
Listen to the given address.void
removeMethod(Method method)
Remove a method from the set of methods held by this Supervisor.void
setMaxInputBufferSize(int bytes)
Set maximum input buffer size.void
setMaxOutputBufferSize(int bytes)
Set maximum output buffer size.void
setSessionHandler(SessionHandler handler)
Set the session handler for this SupervisorTransport
transport()
Obtain the underlying Transport object.
-
-
-
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)
Connect to the given address. The newTarget
will be associated with this Supervisor.- Parameters:
spec
- where to connect- Returns:
- Target representing our end of the connection
- See Also:
connect(com.yahoo.jrt.Spec, java.lang.Object)
-
connect
public Target connect(Spec spec, java.lang.Object context)
Connect to the given address. The newTarget
will be associated with this Supervisor and will have 'context' as application context.- Parameters:
spec
- where to connectcontext
- 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
-
-