UniverseUniversity


Home Projects Jobs Clientele Contact

uu


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Db pool [was: My little comments to CPP code]



> Almost there. Now look at the samples for the proper syntax....

My guess is that the proper syntax is:

<servlet name="InitServlet" dso="./debug/libui/libuu.so">
<parameter name="num_connections" value="100"/>
</servlet>


> I think you missed the fact that connections do not have to be closed
> nor are necessarily open when pool returns them. You are, however,
> right in that the login() stored procedure should be called every time
> connection is retrieved, and logout/cleanup should be called every time
> connection is returned to the pool. I think it is best to tie these to
> pool
> itself, in order to avoid forgetting to call these by accident.
>
> Another thing you are forgetting about is when init() and destroy() are
> called.
>


Ok, here is how I understand DB pool related functionlity at this point(so
far without some details of how pool will work internally):

DB pool initialized in InitServlet::init() and pointer to it stored in
ServletContext.
The database handle will be retrieved in UUServlet and passed to data
model classes as an argument to constructor.

Connection has to be opened and added to the pool if
"No connections available in m_connections list" AND ( "maxCon parameter
is null" OR "maxCon limit has not been reached" )

Connection has to be closed and removed from the pool
1. At shutdown. We have to loop through all connections in m_connections
list and close them, then clear m_connections list.
I don't know how else connections can be closed, maybe when it was
inactive for some time and Postgres will close it by itself?

However I don't see the point in returning closed connections to the
client. If, for some reason, there are closed connection in m_connections
list, they have to be removed from the list until first open connection is
found and returned to client.

login() stored procedure will be called in uuDBPool::getConnection()
whenever there is an open connection to return and
logout() stored procedure will be called in
uuDBPool::releaseConnection(Connection& con) whenever connection is
returned to the pool.

Since we process authentication in the pool, uuDBPool::getConnection()
will get 4 parameters(login, password, server, sessionid) to call login().

The question now when uuDBPool::getConnection() and
uuDBPool::releaseConnection() will be called.
It has to be done in servlet' service() imho. But since we have UUServlet
my guess that we can do it there.
So uuDBPool::getConnection() will be called in UUServlet constractor and
uuDBPool::releaseConnection() will be called in UUServlet destructor.


Please comment.

>
> --
> Ilya A. Volynets-Evenbakh
> Total Knowledge. CTO
> http://www.total-knowledge.com
>
>



Authoright © Total Knowledge: 2001-2008