Revision 5319
Added by Matt Jones about 14 years ago
DBConnectionPool.java | ||
---|---|---|
224 | 224 |
int random = 0; //random number |
225 | 225 |
int index = 0; //index |
226 | 226 |
int size = 0; //size of connection pool |
227 |
logMetacat.debug("DBConnectionPool.getDBConnection - Trying to check out connection..."); |
|
227 |
// logMetacat.debug("DBConnectionPool.getDBConnection - Trying to check out connection...");
|
|
228 | 228 |
size = connectionPool.size(); |
229 |
logMetacat.debug("DBConnectionPool.getDBConnection - size of connection pool: " + size); |
|
229 |
// logMetacat.debug("DBConnectionPool.getDBConnection - size of connection pool: " + size);
|
|
230 | 230 |
|
231 | 231 |
//try every DBConnection in the pool |
232 | 232 |
//every DBConnection will be try LIMITE times |
... | ... | |
239 | 239 |
{ |
240 | 240 |
index =(i+random)%size; |
241 | 241 |
db = (DBConnection) connectionPool.elementAt(index); |
242 |
logMetacat.debug("DBConnectionPool.getDBConnection - Index: " + index); |
|
243 |
logMetacat.debug("DBConnectionPool.getDBConnection - Tag: " + db.getTag()); |
|
244 |
logMetacat.debug("DBConnectionPool.getDBConnection - Status: " + db.getStatus()); |
|
242 |
// logMetacat.debug("DBConnectionPool.getDBConnection - Index: " + index);
|
|
243 |
// logMetacat.debug("DBConnectionPool.getDBConnection - Tag: " + db.getTag());
|
|
244 |
// logMetacat.debug("DBConnectionPool.getDBConnection - Status: " + db.getStatus());
|
|
245 | 245 |
//check if the connection is free |
246 | 246 |
if (db.getStatus()==FREE) |
247 | 247 |
{ |
... | ... | |
259 | 259 |
db.setCheckOutMethodName(methodName); |
260 | 260 |
db.setAutoCommit(true); |
261 | 261 |
//debug message |
262 |
logMetacat.debug("DBConnectionPool.getDBConnection - The connection is checked out: " + db.getTag()); |
|
263 |
logMetacat.debug("DBConnectionPool.getDBConnection - The method for checking is: " + db.getCheckOutMethodName()); |
|
264 |
logMetacat.debug("DBConnectionPool.getDBConnection - The age is " + db.getAge()); |
|
265 |
logMetacat.debug("DBConnectionPool.getDBConnection - The usage is " + db.getUsageCount()); |
|
266 |
logMetacat.debug("DBConnectionPool.getDBConnection - The connection time is: " + db.getConnectionTime()); |
|
262 |
// logMetacat.debug("DBConnectionPool.getDBConnection - The connection is checked out: " + db.getTag());
|
|
263 |
// logMetacat.debug("DBConnectionPool.getDBConnection - The method for checking is: " + db.getCheckOutMethodName());
|
|
264 |
// logMetacat.debug("DBConnectionPool.getDBConnection - The age is " + db.getAge());
|
|
265 |
// logMetacat.debug("DBConnectionPool.getDBConnection - The usage is " + db.getUsageCount());
|
|
266 |
// logMetacat.debug("DBConnectionPool.getDBConnection - The connection time is: " + db.getConnectionTime());
|
|
267 | 267 |
//set check out time |
268 | 268 |
db.setCheckOutTime(System.currentTimeMillis()); |
269 | 269 |
// set count of reach maximum 0 because it can check out |
... | ... | |
418 | 418 |
index = getIndexOfPoolForConnection(conn); |
419 | 419 |
if ( index ==-1 ) |
420 | 420 |
{ |
421 |
logMetacat.info("DBConnectionPool.returnDBConnection - Couldn't find a DBConnection in the pool" + |
|
422 |
" which have same tag to the returned DBConnetion object"); |
|
421 |
// logMetacat.info("DBConnectionPool.returnDBConnection - Couldn't find a DBConnection in the pool" +
|
|
422 |
// " which have same tag to the returned DBConnetion object");
|
|
423 | 423 |
return; |
424 | 424 |
|
425 | 425 |
}//if |
... | ... | |
429 | 429 |
//if it is as same as the object's checkout serial number. |
430 | 430 |
//if it is same return it. If it is not same, maybe the connection already |
431 | 431 |
// was returned earlier. |
432 |
logMetacat.debug("DBConnectionPool.returnDBConnection - serial number in Connection: " + |
|
433 |
conn.getCheckOutSerialNumber()); |
|
434 |
logMetacat.debug("DBConnectionPool.returnDBConnection - serial number in local: " + serialNumber); |
|
432 |
// logMetacat.debug("DBConnectionPool.returnDBConnection - serial number in Connection: " +
|
|
433 |
// conn.getCheckOutSerialNumber());
|
|
434 |
// logMetacat.debug("DBConnectionPool.returnDBConnection - serial number in local: " + serialNumber);
|
|
435 | 435 |
if (conn.getCheckOutSerialNumber() == serialNumber) |
436 | 436 |
{ |
437 | 437 |
dbConn = (DBConnection) connectionPool.elementAt(index); |
... | ... | |
444 | 444 |
//set check out time to 0 |
445 | 445 |
dbConn.setCheckOutTime(0); |
446 | 446 |
|
447 |
logMetacat.debug("DBConnectionPool.returnDBConnection - Connection: " + |
|
448 |
dbConn.getTag() + " checked in."); |
|
449 |
logMetacat.debug("DBConnectionPool.returnDBConnection - Connection: " + |
|
450 |
dbConn.getTag() + "'s status: " + dbConn.getStatus()); |
|
447 |
// logMetacat.debug("DBConnectionPool.returnDBConnection - Connection: " +
|
|
448 |
// dbConn.getTag() + " checked in.");
|
|
449 |
// logMetacat.debug("DBConnectionPool.returnDBConnection - Connection: " +
|
|
450 |
// dbConn.getTag() + "'s status: " + dbConn.getStatus());
|
|
451 | 451 |
|
452 | 452 |
}//if |
453 | 453 |
else |
454 | 454 |
{ |
455 |
logMetacat.info("DBConnectionPool.returnDBConnection - This DBConnection couldn't return" + |
|
456 |
dbConn.getTag()); |
|
455 |
// logMetacat.info("DBConnectionPool.returnDBConnection - This DBConnection couldn't return" +
|
|
456 |
// dbConn.getTag());
|
|
457 | 457 |
}//else |
458 | 458 |
}//else |
459 | 459 |
|
Also available in: Unified diff
Modifications to support the DataONE service API version 0.1.0. For DataONE, the get() and
create() services are partially complete. Several more functions and checks need to be added to
create() before it is viable. This DataONE support is not complete, and the current support breaks the MetacatRestClientTest for the time being (this client will eventually be removed).