Revision 1759
Added by Jing Tao over 21 years ago
src/edu/ucsb/nceas/metacat/DBConnectionPool.java | ||
---|---|---|
191 | 191 |
int random = 0; //random number |
192 | 192 |
int index = 0; //index |
193 | 193 |
int size = 0; //size of connection pool |
194 |
MetaCatUtil.debugMessage("Try to checking out connection...", 55);
|
|
194 |
MetaCatUtil.debugMessage("Try to checking out connection...", 65);
|
|
195 | 195 |
size = connectionPool.size(); |
196 |
MetaCatUtil.debugMessage("size of connection pool: "+size, 45);
|
|
196 |
MetaCatUtil.debugMessage("size of connection pool: "+size, 55);
|
|
197 | 197 |
|
198 | 198 |
//try every DBConnection in the pool |
199 | 199 |
//every DBConnection will be try LIMITE times |
... | ... | |
206 | 206 |
{ |
207 | 207 |
index =(i+random)%size; |
208 | 208 |
db = (DBConnection) connectionPool.elementAt(index); |
209 |
MetaCatUtil.debugMessage("Index: "+index, 55);
|
|
210 |
MetaCatUtil.debugMessage("Tag: "+db.getTag(), 55);
|
|
211 |
MetaCatUtil.debugMessage("Status: "+db.getStatus(), 55);
|
|
209 |
MetaCatUtil.debugMessage("Index: "+index, 65);
|
|
210 |
MetaCatUtil.debugMessage("Tag: "+db.getTag(), 65);
|
|
211 |
MetaCatUtil.debugMessage("Status: "+db.getStatus(), 65);
|
|
212 | 212 |
//check if the connection is free |
213 | 213 |
if (db.getStatus()==FREE) |
214 | 214 |
{ |
... | ... | |
227 | 227 |
db.setAutoCommit(true); |
228 | 228 |
//debug message |
229 | 229 |
MetaCatUtil.debugMessage("The connection is checked out: " |
230 |
+db.getTag(), 55);
|
|
230 |
+db.getTag(), 65);
|
|
231 | 231 |
MetaCatUtil.debugMessage("The method for checking is: " |
232 |
+db.getCheckOutMethodName(), 45);
|
|
233 |
MetaCatUtil.debugMessage("The age is "+db.getAge(), 55);
|
|
234 |
MetaCatUtil.debugMessage("The usage is "+db.getUsageCount(), 55);
|
|
232 |
+db.getCheckOutMethodName(), 65);
|
|
233 |
MetaCatUtil.debugMessage("The age is "+db.getAge(), 65);
|
|
234 |
MetaCatUtil.debugMessage("The usage is "+db.getUsageCount(), 65);
|
|
235 | 235 |
MetaCatUtil.debugMessage("The conection time it has: " |
236 |
+db.getConnectionTime(), 55);
|
|
236 |
+db.getConnectionTime(), 65);
|
|
237 | 237 |
//set check out time |
238 | 238 |
db.setCheckOutTime(System.currentTimeMillis()); |
239 | 239 |
//check it out |
... | ... | |
329 | 329 |
if (dbConn.getUsageCount() >= MAXIMUMUSAGENUMBER ) |
330 | 330 |
{ |
331 | 331 |
MetaCatUtil.debugMessage("Connection usageCount is too many: "+ |
332 |
dbConn.getUsageCount(), 40);
|
|
332 |
dbConn.getUsageCount(), 65);
|
|
333 | 333 |
return false; |
334 | 334 |
} |
335 | 335 |
|
... | ... | |
337 | 337 |
if (dbConn.getConnectionTime() >= MAXIMUMCONNECTIONTIME) |
338 | 338 |
{ |
339 | 339 |
MetaCatUtil.debugMessage("Connection has too much connection time: "+ |
340 |
dbConn.getConnectionTime(), 40);
|
|
340 |
dbConn.getConnectionTime(), 65);
|
|
341 | 341 |
return false; |
342 | 342 |
} |
343 | 343 |
|
344 | 344 |
//Check if the DBConnection is too old |
345 | 345 |
if (dbConn.getAge() >=MAXIMUMAGE) |
346 | 346 |
{ |
347 |
MetaCatUtil.debugMessage("Connection is too old: "+dbConn.getAge(), 40);
|
|
347 |
MetaCatUtil.debugMessage("Connection is too old: "+dbConn.getAge(), 65);
|
|
348 | 348 |
return false; |
349 | 349 |
} |
350 | 350 |
|
... | ... | |
397 | 397 |
//if it is same return it. If it is not same, maybe the connection already |
398 | 398 |
// was returned ealier. |
399 | 399 |
MetaCatUtil.debugMessage("serial number in Connection: " |
400 |
+conn.getCheckOutSerialNumber(), 55);
|
|
401 |
MetaCatUtil.debugMessage("serial number in local: "+serialNumber, 55);
|
|
400 |
+conn.getCheckOutSerialNumber(), 65);
|
|
401 |
MetaCatUtil.debugMessage("serial number in local: "+serialNumber, 65);
|
|
402 | 402 |
if (conn.getCheckOutSerialNumber() == serialNumber) |
403 | 403 |
{ |
404 | 404 |
dbConn = (DBConnection) connectionPool.elementAt(index); |
... | ... | |
412 | 412 |
dbConn.setCheckOutTime(0); |
413 | 413 |
|
414 | 414 |
MetaCatUtil.debugMessage("Connection: "+dbConn.getTag()+" checked in.", |
415 |
55);
|
|
415 |
65);
|
|
416 | 416 |
MetaCatUtil.debugMessage("Connection: "+dbConn.getTag()+"'s status: " |
417 |
+dbConn.getStatus(), 55);
|
|
417 |
+dbConn.getStatus(), 65);
|
|
418 | 418 |
|
419 | 419 |
}//if |
420 | 420 |
else |
... | ... | |
536 | 536 |
//check if it is valiate, if not create new one and replace old one |
537 | 537 |
if (!validateDBConnection(dbConn)) |
538 | 538 |
{ |
539 |
MetaCatUtil.debugMessage("Recyle it: "+ dbConn.getTag(), 40);
|
|
539 |
MetaCatUtil.debugMessage("Recyle it: "+ dbConn.getTag(), 65);
|
|
540 | 540 |
//close this DBConnection |
541 | 541 |
dbConn.close(); |
542 | 542 |
//remove it form connection pool |
Also available in: Unified diff
Change debug level.