|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tentackle.db.DefaultConnectionManager
org.tentackle.db.MpxConnectionManager
public class MpxConnectionManager
Multiplexing connection manager.
A connection manager for applications with a large number of Db instances,
e.g. application servers. The manager will multiplex N Db instances against
M connections, allowing N > M. This is not to be mixed up with db-pooling, as connection
multiplexing is completely transparent to the application whereas pooling requires
an explicit relation to something like a session.
Note that the authentication must be done at the application level because
the pool's connections are derived from the userinfo of a server db.
| Field Summary | |
|---|---|
protected int |
incSize
|
protected int |
maxMinutes
|
protected int |
maxSize
|
protected int |
minMinutes
|
protected int |
minSize
|
protected Random |
random
|
protected Db |
serverDb
|
protected int |
unConCount
|
protected int[] |
unConList
|
| Fields inherited from class org.tentackle.db.DefaultConnectionManager |
|---|
conList, dbList, freeConCount, freeConList, freeDbCount, freeDbList, idOffset, iniSize, maxConSize, maxDbSize, name |
| Constructor Summary | |
|---|---|
MpxConnectionManager(Db serverDb)
Creates a connection manager with reasonable values for most servers. |
|
MpxConnectionManager(String name,
Db serverDb,
int maxDb,
int idOffset,
int iniSize,
int incSize,
int minSize,
int maxSize,
int minMinutes,
int maxMinutes)
Creates a new connection manager. |
|
| Method Summary | |
|---|---|
ManagedConnection |
attach(int id)
Attaches a Db to a connection.A Db must be attached before it can use any statements. |
protected int |
createConnections(int count)
Create spare connections. |
void |
detach(int id)
Detaches a connection from a Db.A Db must be detached to release the connection for use of other Db instances. |
int |
login(Db db)
Logs in a Db connection.It is up to the manager how to verify whether the Db is allowed to open, a real connection is initiated or just an application level authorization is performed. |
Db |
logout(int id)
Logs out a Db connection. |
protected int |
popUnattached()
Gets a connection from the unattached freelist. |
protected void |
pushUnattached(int index)
Adds the index of an unused connection to the freelist. |
void |
shutdown()
Shuts down this connection manager. All connections are closed and the threads stopped. |
| Methods inherited from class org.tentackle.db.DefaultConnectionManager |
|---|
addConnection, addDb, getConnectionCount, getDbCount, getMaxConnections, getMaxCountForClearWarnings, getMaxLogins, removeConnection, removeDb, setMaxCountForClearWarnings, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Db serverDb
protected int incSize
protected int minSize
protected int maxSize
protected int minMinutes
protected int maxMinutes
protected int[] unConList
protected int unConCount
protected Random random
| Constructor Detail |
|---|
public MpxConnectionManager(String name,
Db serverDb,
int maxDb,
int idOffset,
int iniSize,
int incSize,
int minSize,
int maxSize,
int minMinutes,
int maxMinutes)
name - the name of the connection managerserverDb - the root db to use for creating connections (may be open or closed)maxDb - the maximum number of Db instances, 0 = no limitidOffset - the offset for connection ids (> 0)iniSize - the initial size of the connection poolincSize - the number of connections to add if all in useminSize - the minimum number of connectionsmaxSize - the maximum number of connectionsminMinutes - minimum minutes a connection should be usedmaxMinutes - maximum minutes a connection should be usedpublic MpxConnectionManager(Db serverDb)
serverDb - the root db to use for creating connections (may be open or closed).| Method Detail |
|---|
public void shutdown()
shutdown in interface ConnectionManagershutdown in class DefaultConnectionManagerprotected void pushUnattached(int index)
index - the index of the connection in the connections listprotected int popUnattached()
protected int createConnections(int count)
count - the number of connections to create
public int login(Db db)
throws DbRuntimeException
ConnectionManagerDb connection.
login in interface ConnectionManagerlogin in class DefaultConnectionManagerdb - the db to login
DbRuntimeException - if login failed.
public Db logout(int id)
throws DbRuntimeException
ConnectionManagerDb connection.
The Db is not allowed to attach anymore. If the Db is still attached,
a rollback of any pending tx is done and an exception thrown.
logout in interface ConnectionManagerlogout in class DefaultConnectionManagerid - the connection ID of the db
DbRuntimeException - if logout failed.
public ManagedConnection attach(int id)
throws DbRuntimeException
ConnectionManagerDb to a connection.
attach in interface ConnectionManagerattach in class DefaultConnectionManagerid - the connection ID of the db
DbRuntimeException - if attach failed.
public void detach(int id)
throws DbRuntimeException
ConnectionManagerDb.
detach in interface ConnectionManagerdetach in class DefaultConnectionManagerid - the connection ID of the db
DbRuntimeException - if detach failed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||