Package com.yahoo.jrt

Interface SessionHandler


  • public interface SessionHandler
    Interface used to handle the lifetime of a Target. The word session is used to denote all the RPC activity across a single Target during its lifetime. This interface gives the application information about when different Target objects enter different stages in their lifetime. Combined with the ability to bind application specific data to a Target with the Target.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. Each Supervisor can only have a single session handler. Use the Supervisor.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 Detail

      • handleSessionInit

        void handleSessionInit​(Target target)
        Invoked when a new Target is created. This is a nice place to initialize and attach application context to the Target.
        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 the Target application context under the feet of active invocations.
        Parameters:
        target - the target