/// <summary> /// Check out an object from the pool and call isAlive to guarantee state. Decrement resource count /// on pool if object is not alive and discard it by removing references /// </summary> /// <param name="obj"></param> /// <returns>AbstractResource</returns> public override AbstractResource checkOutAlive(object obj) { AbstractResource resource = checkOut(obj); while (!resource.isAlive()) { //LogUtils.getInstance().Log("Found disconnected/timed out connection... Fetching another: " + ((ConnectionPoolSource)this.PoolSource).CxnSource.SiteId.Id); this.decrementResourceCount(); //this.TotalResources--; resource = checkOut(obj); } if (resource is VistaPoolConnection && this.PoolSource.RecycleCount > 0) // only need to step in here if the recycle count was actually set { VistaPoolConnection cxn = (VistaPoolConnection)resource; if (cxn.QueryCount >= this.PoolSource.RecycleCount) // if we've used cxn more times than specified before recycle, we should disconnect this connection and return another { //LogUtils.getInstance().Log("Max number of queries exceeded for connection - disconnecting and discarding: " + ((ConnectionPoolSource)this.PoolSource).CxnSource.SiteId.Id); new System.Threading.Tasks.Task(() => cxn.disconnect()).Start(); this.decrementResourceCount(); //this.TotalResources--; return(this.checkOutAlive(obj)); } } return(resource); }
public override AbstractResource checkOutAlive(object obj) { AbstractResource resource = checkOut(obj); while (!resource.isAlive()) { // System.Console.WriteLine("Found a disconnected resource from ConnectionPools"); LogUtils.getInstance().Log("Found a disconnected resource from ConnectionPools... decrementing resource count and checking out another"); _pools[(String)obj].decrementResourceCount(); // we decrement resource count for this pool here because checkOut doesn't do it //_pools[(String)obj].TotalResources--; resource = checkOut(obj); } return(resource); }