Process
"Testonreturn parameter" Jedispool.returnresource (Jedis)->pool.returnobject (Jedis)->pool.gettestonreturn ()
|
|
|
|
"Testonborrow parameter" Jedispool.getresource ()->pool.borrowobject () | |
|
\ |
\ |
\ | _\| \|/Pooledobjectfactory.validateobject (pooledobject<t>
)|
|--->jedisfactory.validateobject (pooledobject<jedis>)-->ping-pass, not through destruction
|
|-->shardedjedisfactory.validateobject (ooledobject<jedis>)-Cluster all nodes ping pass, not through destroy
Org.apache.commons.pool2.impl.GenericObjectPool.borrowObject (Long Borrowmaxwaitmillis) throws Exception
Public T Borrowobject (long Borrowmaxwaitmillis) throws Exception {Assertopen ();
Abandonedconfig ac = this.abandonedconfig;
if (AC! = null && ac.getremoveabandonedonborrow () && (Getnumidle () < 2) && (Getnumactive () > Getmaxtotal ()-3))
{removeabandoned (AC);
} pooledobject<t> p = null; Get local copy of current Config so it's consistent for entire//method execution Boolean Blockwhenex
hausted = getblockwhenexhausted ();
Boolean create;
Long waitTime = System.currenttimemillis ();
while (p = = null) {create = false;
if (blockwhenexhausted) {p = Idleobjects.pollfirst ();
if (p = = null) {p = create ();
if (P! = null) {create = true; }} if (P == null) {if (Borrowmaxwaitmillis < 0) {p = Idleobjects.takefirst ();
} else {p = Idleobjects.pollfirst (Borrowmaxwaitmillis,
Timeunit.milliseconds);
}} if (p = = null) {throw new Nosuchelementexception (
"Timeout Waiting for Idle object");
} if (!p.allocate ()) {p = null;
}} else {p = Idleobjects.pollfirst ();
if (p = = null) {p = create ();
if (P! = null) {create = true; }} if (p = = null) {throw new Nosuchelementexception ("Pool exhausted"
); } if (!p.allocate ()) {p =Null
}} if (P! = null) {try {factory.activateobject (P);
} catch (Exception e) {try {destroy (P);
} catch (Exception E1) {//Ignore-activation failure is more important}
p = null;
if (create) {nosuchelementexception Nsee = new Nosuchelementexception (
"Unable to activate object");
Nsee.initcause (e);
Throw Nsee;
}} if (P! = null && (Gettestonborrow () | | | Create && gettestoncreate ())) {
Boolean validate = false;
Throwable validationthrowable = null; try {validate = Factory.validateobject (p);
} catch (Throwable t) {Poolutils.checkrethrow (t);
validationthrowable = t;
} if (!validate) {try {destroy (P);
Destroyedbyborrowvalidationcount.incrementandget ();
} catch (Exception e) {//Ignore-validation failure is more important
} p = null;
if (create) {nosuchelementexception Nsee = new Nosuchelementexception (
"Unable to validate object");
Nsee.initcause (validationthrowable);
Throw Nsee; }}}}} Updatestatsborrow (P, System.currenttimemillis ()
-WaitTime); return P.getobject (); }
• • •