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]




sergey@total-knowledge.com wrote:
> Here you go...
>
>
> - What is our pool responsible for.
> It responsible for managing DB connections.
> When a servlet needs a database connection, it requests an available one
> from the pool. If none is available, a new one is created and added to the
> pool.
> Also it should close connections that have not been used for a specified
> time and responsible for queueing connections.
>   
What does "queuing connections" mean?
> - What pooling strategies we want to support (and why)
> 1. Get an open connection from the pool.
> We need a connection to provide user access to DB.
>
> 2. Return a connection to the pool.
> We need to count connections in the pool
>
> 3. Release all resources and close all connections at shutdown.
> We need to loop through all connections and close them on shutdown to
> clear the pool.
>
> 4. Setting up connection time-outs and communication failures.
> We need to set up timeouts for queueing and recognize and clean up
> "failure" connections.
>
> 5. Limit the number of connections in the pool to a predefined value.
> Set the max limit to make sure the pool is not overloaded.
>   
These are not strategies. These are functions. Should have been in previous
section. And "close connections when they are unused for period of time"
is an example of pooling strategy.
>
> - How will pooling and HTTP request object lifetimes will interoperate
> DB connection lives within HTTP request lifetime.
>   
Why bother with pooling then? Just open the damn connection, then close
it in the end.
> - What will API look like
>
> 1. The uudb() constructor that takes these parameters:
> string login,
> string password,
> int server(this one is needed for login() proc),
> string sessionid(needed for login() proc, not really used now),
> int maxCon(max connections for this pool),
>   
What does uudb class represent? Whole pool? Single connection?
> 2. Connection getConnection() { return con; } to get an open connection
> from the pool.
>
> 3. Connection newConnection() { return con; } to create a new connection.
>
> 4. Connection getConnection( long timeout ) { return con; } to get a
> connection from the pool, 'timeout' is a value for how long the client is
> waiting for a connection.
>   
Why do you need these three different functions?
> 5. void returnConnection(Connection con) used for returning a connection
> to the pool.
>   
Usually function responsible for returning connections to the pool
is called "release" or some such.
> 6. void shutdown() closes all connections in the pool.
>
>
> - Provide few use cases relevant for our application
>
> "DB Pool" diagram created(uu.xmi attached).
>   
I meant describe in words, not draw pretty pictures :)
What I want is: scenario (who does what) and then how
pool API plays into it.

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


Authoright © Total Knowledge: 2001-2008