Revision 1849
Added by Jing Tao about 21 years ago
src/edu/ucsb/nceas/metacat/DBConnectionPool.java | ||
---|---|---|
49 | 49 |
private static DBConnectionPool instance; |
50 | 50 |
private static Vector connectionPool; |
51 | 51 |
private static Thread runner; |
52 |
private static int countOfReachMaximum = 0; |
|
52 | 53 |
|
53 | 54 |
//maximum connection number in the connection pool |
54 | 55 |
final static int MAXIMUMCONNECTIONNUMBER= |
... | ... | |
236 | 237 |
+db.getConnectionTime(), 65); |
237 | 238 |
//set check out time |
238 | 239 |
db.setCheckOutTime(System.currentTimeMillis()); |
239 |
//check it out |
|
240 |
// set count of reach maximum 0 because it can check out |
|
241 |
countOfReachMaximum =0; |
|
240 | 242 |
return db; |
241 | 243 |
}//if |
242 | 244 |
else//The DBConnection has some problem |
... | ... | |
290 | 292 |
" open db connections is reached." + |
291 | 293 |
" New db connection to MetaCat" + |
292 | 294 |
" cannot be established.", 1); |
293 |
return null; |
|
294 |
//if couldn't get a connection, sleep 20 seconds and try again. |
|
295 |
/*try |
|
295 |
countOfReachMaximum ++; |
|
296 |
if (countOfReachMaximum >= 10) |
|
296 | 297 |
{ |
297 |
System.out.println("sleep"); |
|
298 |
Thread.sleep(2000); |
|
298 |
countOfReachMaximum =0; |
|
299 |
MetaCatUtil.debugMessage("finally could not get dbconnection", 1); |
|
300 |
return null; |
|
299 | 301 |
} |
300 |
catch (Exception e)
|
|
302 |
else
|
|
301 | 303 |
{ |
302 |
}*/ |
|
304 |
//if couldn't get a connection, sleep 20 seconds and try again. |
|
305 |
try |
|
306 |
{ |
|
307 |
MetaCatUtil.debugMessage("sleep for could not get dbconnection", 20); |
|
308 |
Thread.sleep(5000); |
|
309 |
} |
|
310 |
catch (Exception e) |
|
311 |
{ |
|
312 |
} |
|
313 |
} |
|
303 | 314 |
|
304 | 315 |
|
305 | 316 |
}//else |
Also available in: Unified diff
If db pool size is maxium and no connection is free. The checkout will be wait.