Package com.yahoo.jrt
Interface SessionHandler
-
public interface SessionHandler
Interface used to handle the lifetime of aTarget
. The word session is used to denote all the RPC activity across a singleTarget
during its lifetime. This interface gives the application information about when differentTarget
objects enter different stages in their lifetime. Combined with the ability to bind application specific data to aTarget
with theTarget.setContext(java.lang.Object)
method, this enables method invocations in the same session to share state information. Usage of this interface is optional. It is typically useful for server applications needing state to be shared between RPC method invocation on a session. EachSupervisor
can only have a single session handler. Use theSupervisor.setSessionHandler
method to set the session handler. The different callbacks may be called from several different threads, but for a single target there will be no overlapping of session callbacks, and the order will always be the same; init, live (not always called), down, fini.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
handleSessionDown(Target target)
Invoked when the target becomes invalid.void
handleSessionFini(Target target)
Invoked when the target is invalid and no more RPC invocations are active on our side of this target (invoked from the other side; we being the server).void
handleSessionInit(Target target)
Invoked when a newTarget
is created.void
handleSessionLive(Target target)
Invoked when a connection is established with the peer.
-
-
-
Method Detail
-
handleSessionInit
void handleSessionInit(Target target)
Invoked when a newTarget
is created. This is a nice place to initialize and attach application context to theTarget
.- Parameters:
target
- the target
-
handleSessionLive
void handleSessionLive(Target target)
Invoked when a connection is established with the peer. Note that if a connection could not be established with the peer, this method is never invoked.- Parameters:
target
- the target
-
handleSessionDown
void handleSessionDown(Target target)
Invoked when the target becomes invalid. This is typically caused by the network connection with the peer going down. Note that this method is invoked also when a connection with the peer could not be established at all.- Parameters:
target
- the target
-
handleSessionFini
void handleSessionFini(Target target)
Invoked when the target is invalid and no more RPC invocations are active on our side of this target (invoked from the other side; we being the server). If you need to perform cleanup related to the application data associated with the target, you should wait until this method is invoked, to avoid cleaning up theTarget
application context under the feet of active invocations.- Parameters:
target
- the target
-
-