Permalink
Browse files

Remove the notion of checkoutPool.

  • Loading branch information...
1 parent 0179a0d commit 9e10ef541aa8d10a2144d066f752cddff2a07fcd Raghavendra Prabhu committed Mar 14, 2012
@@ -13,23 +13,11 @@ import com.twitter.conversions.time._
object AsyncQueryEvaluator extends AsyncQueryEvaluatorFactory {
lazy val defaultWorkPool = FuturePool(Executors.newCachedThreadPool(new DaemonThreadFactory))
- lazy val defaultMaxWaiters = Int.MaxValue
-
- def checkoutPool(maxWaiters: Int) = {
- FuturePool(
- new ThreadPoolExecutor(
- 1, /* min size */
- 1, /* max size */
- 0, /* ignored, since the sizes are the same */
- TimeUnit.MILLISECONDS, /* similarly ignored */
- new LinkedBlockingQueue(maxWaiters)))
- }
private def createEvaluatorFactory() = {
new StandardAsyncQueryEvaluatorFactory(
new BlockingDatabaseWrapperFactory(
defaultWorkPool,
- checkoutPool(defaultMaxWaiters),
new ThrottledPoolingDatabaseFactory(10, 100.millis, 10.seconds, 1.second)
),
new SqlQueryFactory
@@ -12,7 +12,6 @@ import com.twitter.querulous.database.{Database, DatabaseFactory}
class BlockingDatabaseWrapperFactory(
workPool: => FuturePool,
- checkoutPool: => FuturePool,
factory: DatabaseFactory,
stats: StatsCollector = NullStatsCollector)
extends AsyncDatabaseFactory {
@@ -26,7 +25,6 @@ extends AsyncDatabaseFactory {
): AsyncDatabase = {
new BlockingDatabaseWrapper(
workPool,
- checkoutPool,
factory(hosts, name, username, password, urlOptions, driverName),
stats
)
@@ -39,7 +37,6 @@ private object AsyncConnectionCheckout {
class BlockingDatabaseWrapper(
workPool: FuturePool,
- checkoutPool: FuturePool,
protected[async] val database: Database,
stats: StatsCollector = NullStatsCollector)
extends AsyncDatabase {
@@ -50,11 +47,6 @@ extends AsyncDatabase {
stats.addGauge("db-async-active-threads")(e.getActiveCount.toDouble)
}
- getExecutor(checkoutPool) foreach { e =>
- val q = e.getQueue
- stats.addGauge("db-async-waiters")(q.size.toDouble)
- }
-
private val openTimeout = database.openTimeout
def withConnection[R](f: Connection => R) = {
@@ -77,7 +69,7 @@ extends AsyncDatabase {
val conn = new Promise[Connection]()
stats.timeFutureMillis("db-async-open-timing") {
- checkoutPool { conn() = Try(database.open()) }
+ workPool { conn() = Try(database.open()) }
}
// Return within a specified timeout. If within times out, that
@@ -15,13 +15,8 @@ class AsyncQueryEvaluator {
def apply() = async.AsyncQueryEvaluator.defaultWorkPool
}
- var checkoutPool: FuturePool = new FuturePool {
- def apply() = async.AsyncQueryEvaluator.checkoutPool(maxWaiters)
- }
-
var database: Database = new Database
var query: Query = new Query
- var maxWaiters = async.AsyncQueryEvaluator.defaultMaxWaiters
var singletonFactory = false
private var memoizedFactory: Option[async.AsyncQueryEvaluatorFactory] = None
@@ -49,7 +44,6 @@ class AsyncQueryEvaluator {
memoizedFactory = memoizedFactory orElse {
val db = new async.BlockingDatabaseWrapperFactory(
workPool(),
- checkoutPool(),
newDatabaseFactory(stats, dbStatsFactory),
stats
)
@@ -34,7 +34,6 @@ class BlockingDatabaseWrapperSpec extends Specification {
val wrapper = new BlockingDatabaseWrapper(
AsyncQueryEvaluator.defaultWorkPool,
- AsyncQueryEvaluator.checkoutPool(50),
database
)
@@ -13,7 +13,6 @@ import com.twitter.querulous.async._
class StandardAsyncQueryEvaluatorSpec extends Specification with JMocker with ClassMocker {
val workPool = AsyncQueryEvaluator.defaultWorkPool
- val checkoutPool = AsyncQueryEvaluator.checkoutPool(1)
val database = mock[Database]
val connection = mock[Connection]
@@ -22,7 +21,7 @@ class StandardAsyncQueryEvaluatorSpec extends Specification with JMocker with Cl
def newEvaluator() = {
new StandardAsyncQueryEvaluator(
- new BlockingDatabaseWrapper(workPool, checkoutPool, database),
+ new BlockingDatabaseWrapper(workPool, database),
queryFactory
)
}

0 comments on commit 9e10ef5

Please sign in to comment.