Package com.yahoo.jrt

Class Target

java.lang.Object
com.yahoo.jrt.Target

public abstract class Target extends Object
A Target represents a connection endpoint with RPC capabilities. Each such connection has a client and a server side. The client side is the one initiating the connection. RPC requests may be invoked across the connection from both the client and the server side.
  • Method Details

    • setContext

      public void setContext(Object context)
      Sets the application context associated with this target.
      Parameters:
      context - the application context
    • getContext

      public Object getContext()
      Obtains the application context associated with this target.
      Returns:
      the application context
    • isValid

      public abstract boolean isValid()
      Checks if this target is still valid for invocations.
      Returns:
      true if this target is still valid
    • getConnectionLostReason

      public Exception getConnectionLostReason()
      Obtains the low-level reason behind losing the connection for which this target is an endpoint. If the target is still valid or if the target became invalid because it was closed, this method will return null. In other cases this method may or may not return an exception indicating why the connection was lost. Also, if an exception is returned, its nature may vary based on implementation details across platforms.
      Returns:
      exception causing connection loss or null
    • connectionAuthContext

      public abstract com.yahoo.security.tls.ConnectionAuthContext connectionAuthContext()
      Returns the connection auth context associated with this target.
    • peerSpec

      public abstract Spec peerSpec()
      Returns:
      address spec of socket peer
    • isClient

      public abstract boolean isClient()
      Check if this target represents the client side of a connection.
      Returns:
      true if this is a client-side target
    • isServer

      public abstract boolean isServer()
      Check if this target represents the server side of a connection.
      Returns:
      true if this is a server-side target
    • invokeSync

      public abstract void invokeSync(Request req, double timeout)
      Invoke a request on this target and wait for it to return.
      Parameters:
      req - the request
      timeout - timeout in seconds
    • invokeSync

      public void invokeSync(Request req, Duration timeout)
    • invokeAsync

      public abstract void invokeAsync(Request req, double timeout, RequestWaiter waiter)
      Invoke a request on this target and let the completion be signalled with a callback.
      Parameters:
      req - the request
      timeout - timeout in seconds
      waiter - callback handler
    • invokeAsync

      public void invokeAsync(Request req, Duration timeout, RequestWaiter waiter)
    • invokeVoid

      public abstract boolean invokeVoid(Request req)
      Invoke a request on this target, but ignore the return value(s). The success or failure of the invocation is also ignored. However, the return value gives a little hint by indicating whether the invocation has been attempted at all.
      Parameters:
      req - the request
      Returns:
      false if the invocation was not attempted due to the target being invalid
    • addWatcher

      public abstract boolean addWatcher(TargetWatcher watcher)
      Add a watcher to this target. A watcher is notified if the target becomes invalid. If the target is already invalid when this method is invoked, no operation is performed and false is returned. Multiple adds of the same watcher has no additional effect.
      Parameters:
      watcher - the watcher to be added
      Returns:
      true if the add operation was performed
    • removeWatcher

      public abstract boolean removeWatcher(TargetWatcher watcher)
      Remove a watcher from this target. If the target is already invalid when this method is invoked, no operation is performed and false is returned. Multiple removes of the same watcher has no additional effect.
      Parameters:
      watcher - the watcher to be removed
      Returns:
      true if the remove operation was performed
      See Also:
    • close

      public abstract void close()
      Close this target. Note that the close operation is asynchronous. If you need to wait for the target to become invalid, use the Transport.sync method.