Oleksiy Stashok wrote:
> Ken,
>
> can you pls. describe the usecase you've told about on meeting for
> client side connection cache: responseReceived(), release()...
> As right now I don't see clearly how they could be used...
> Current usecase is:
> connect() -> cache.get()
> send()
> receive()
> .........(some client connection actions)................
> close() -> cache.release(0)
>
> which means that connection is supposed to be busy until it will be
> explicitly closed.
>
> Thanks.
>
> WBR,
> Alexey.
>
In CORBA, the connection is only busy while a request is being written
to it. A typical
CORBA client may send requests to many different object references on
many different
hosts. It may also wish to send multiple requests to the same host, in
which case
caching connections for re-use saves the overhead of opening a
connection per request.
We also associate session state with a connection, so establishing a
connection may requite
more operations than just the TCP connection (as in your case as well).
If two different threads wish to send requests to the same host at the
same time, using the
same connection can result in blocking, because only one thread can
write to the same
connection at a time. That's why I put in the max_parallel_connections,
so that we could avoid
this kind of blocking.
However, if parallel connections have any meaning, we need to
distinguish between busy
(currently in use for writing) and idle connections. That's why we need
release: it tells the
cache that the connection is no longer in use for writing, and so the
connection may
become more likely to be used in a get call, or may become eligible for
reclaimation (if there
are no pending responses).
The general assumption is that a request requires a response, but this
is indicated by the
numberOfResponses parameter (or whatever I called it) on the release
method. If a response is
expected, a release may make the connection idle, but it won't make it
available for reclamation.
Reclamation can only happen on connections that are idle AND have no
expected responses.
That's why I need both release and responseReceived: I need to tell that
cache both that
connections are idle (no writes) and no responses are expected (no reads
expected).
Ken.