Package com.yahoo.jrt
Class Target
java.lang.Object
com.yahoo.jrt.Target
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 Summary
Modifier and TypeMethodDescriptionabstract boolean
addWatcher
(TargetWatcher watcher) Add a watcher to this target.abstract void
close()
Close this target.abstract com.yahoo.security.tls.ConnectionAuthContext
Returns the connection auth context associated with this target.Obtains the low-level reason behind losing the connection for which this target is an endpoint.Obtains the application context associated with this target.abstract void
invokeAsync
(Request req, double timeout, RequestWaiter waiter) Invoke a request on this target and let the completion be signalled with a callback.void
invokeAsync
(Request req, Duration timeout, RequestWaiter waiter) abstract void
invokeSync
(Request req, double timeout) Invoke a request on this target and wait for it to return.void
invokeSync
(Request req, Duration timeout) abstract boolean
invokeVoid
(Request req) Invoke a request on this target, but ignore the return value(s).abstract boolean
isClient()
Check if this target represents the client side of a connection.abstract boolean
isServer()
Check if this target represents the server side of a connection.abstract boolean
isValid()
Checks if this target is still valid for invocations.abstract Spec
peerSpec()
abstract boolean
removeWatcher
(TargetWatcher watcher) Remove a watcher from this target.void
setContext
(Object context) Sets the application context associated with this target.
-
Method Details
-
setContext
Sets the application context associated with this target.- Parameters:
context
- the application context
-
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
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
- 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
Invoke a request on this target and wait for it to return.- Parameters:
req
- the requesttimeout
- timeout in seconds
-
invokeSync
-
invokeAsync
Invoke a request on this target and let the completion be signalled with a callback.- Parameters:
req
- the requesttimeout
- timeout in secondswaiter
- callback handler
-
invokeAsync
-
invokeVoid
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
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
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 theTransport.sync
method.
-