public final class ConnectionManager extends Object
A ConnectionManager
is created by a connection-based
Endpoint
implemention to manage connections to a
particular ConnectionEndpoint
. The newRequest
method is used to send a request to the connection
endpoint.
Each request attempt is mapped to a new session of the Jini ERI
multiplexing protocol on an established connection chosen by the
ConnectionEndpoint
. Request data is written as the data sent for
the session, and response data is read as the data recdeived for the session.
Logger
named
net.jini.jeri.connection.ConnectionManager
to log information at
the following levels:
Level | Description |
---|---|
FINEST | connection opened or reused |
This implementation uses the Logger
named
net.jini.jeri.connection.mux
to log information at the following
levels:
Level | Description |
---|---|
WARNING | unexpected exception during asynchronous I/O processing, or thread creation failure |
HANDLED | I/O exception during asynchronous I/O processing |
FINEST | detailed implementation activity |
This implementation recognizes the following system properties:
org.apache.river.jeri.connectionTimeout
- Time in milliseconds
to leave idle client-side connections around before closing them. The default
value is 15000 milliseconds (15 seconds).
org.apache.river.jeri.handshakeTimeout
- Time in milliseconds
for client-side connections to wait for the server to acknowledge an opening
handshake. The default value is 15000 milliseconds (15 seconds).
Constructor and Description |
---|
ConnectionManager(ConnectionEndpoint ep)
Creates a new
ConnectionManager that manages client-side
connections to the specified connection endpoint. |
Modifier and Type | Method and Description |
---|---|
OutboundRequestIterator |
newRequest(OutboundRequestHandle handle)
Returns an
OutboundRequestIterator to use to send a new
request for the specified handle to this connection manager's
ConnectionEndpoint . |
public ConnectionManager(ConnectionEndpoint ep)
ConnectionManager
that manages client-side
connections to the specified connection endpoint.ep
- the connection endpointpublic OutboundRequestIterator newRequest(OutboundRequestHandle handle)
OutboundRequestIterator
to use to send a new
request for the specified handle to this connection manager's
ConnectionEndpoint
.
If the hasNext
method of the returned iterator returns
true
, the next
method behaves as follows:
The connection endpoint'sconnect
method is invoked with any active connections that have not reached their maximum number of in-progress requests, any idle connections, andhandle
. If that returnsnull
, the endpoint'sconnect
method is invoked withhandle
. In either case, if a new connection is returned, the Jini ERI multiplexing protocol is started on the connection (as the client). Finally, thewriteRequestData
method of the connection is invoked withhandle
and the request output stream of theOutboundRequest
that is created for the request. If any exception is thrown while obtaining a connection from the endpoint or writing the request data, that exception is thrown to the caller. TheOutboundRequest
returned bynext
will invoke thereadResponseData
method of the connection with the specified handle and the response input stream before any other data is read from the response input stream. ThepopulateContext
andgetUnfulfilledConstraints
methods of theOutboundRequest
are implemented by delegating to the corresponding method of the connection passinghandle
and the other arguments (if any).
The returned iterator might allow continued iteration if the connection used for the most recent request attempt was shut down gracefully by the server.
handle
- a handle to identify the request in later invocations on
the connection endpoint and its connectionsOutboundRequestIterator
to use to send a new
request for the specified handle to this connection manager's
ConnectionEndpoint
NullPointerException
- if handle
is null
Copyright © 2016–2018. All rights reserved.