make EventHandler non-global
- add Logging trait for nicer interface - add EventHandlerLogging class for offering the nice interface from app.log - add eventHandler instance to app and use that for all internal logging (this means that some places (dispatchers, remoting) were infiltrated by app just to do logging, but I think we'll need app in there soon enough for other reasons)
This commit is contained in:
parent
e25ee9f0e2
commit
85b7accfd4
61 changed files with 590 additions and 542 deletions
|
|
@ -8,9 +8,9 @@ import java.util.Collection
|
|||
import java.util.concurrent._
|
||||
import atomic.{ AtomicLong, AtomicInteger }
|
||||
import ThreadPoolExecutor.CallerRunsPolicy
|
||||
|
||||
import akka.util.Duration
|
||||
import akka.event.EventHandler
|
||||
import akka.AkkaApplication
|
||||
|
||||
object ThreadPoolConfig {
|
||||
type Bounds = Int
|
||||
|
|
@ -59,7 +59,8 @@ trait ExecutorServiceFactoryProvider {
|
|||
def createExecutorServiceFactory(name: String): ExecutorServiceFactory
|
||||
}
|
||||
|
||||
case class ThreadPoolConfig(allowCorePoolTimeout: Boolean = ThreadPoolConfig.defaultAllowCoreThreadTimeout,
|
||||
case class ThreadPoolConfig(app: AkkaApplication,
|
||||
allowCorePoolTimeout: Boolean = ThreadPoolConfig.defaultAllowCoreThreadTimeout,
|
||||
corePoolSize: Int = ThreadPoolConfig.defaultCorePoolSize,
|
||||
maxPoolSize: Int = ThreadPoolConfig.defaultMaxPoolSize,
|
||||
threadTimeout: Duration = ThreadPoolConfig.defaultTimeout,
|
||||
|
|
@ -76,7 +77,7 @@ case class ThreadPoolConfig(allowCorePoolTimeout: Boolean = ThreadPoolConfig.def
|
|||
case Right(bounds) ⇒
|
||||
val service = new ThreadPoolExecutor(corePoolSize, maxPoolSize, threadTimeout.length, threadTimeout.unit, queueFactory(), threadFactory)
|
||||
service.allowCoreThreadTimeOut(allowCorePoolTimeout)
|
||||
new BoundedExecutorDecorator(service, bounds)
|
||||
new BoundedExecutorDecorator(app, service, bounds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -197,7 +198,7 @@ class MonitorableThread(runnable: Runnable, name: String)
|
|||
/**
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
class BoundedExecutorDecorator(val executor: ExecutorService, bound: Int) extends ExecutorServiceDelegate {
|
||||
class BoundedExecutorDecorator(val app: AkkaApplication, val executor: ExecutorService, bound: Int) extends ExecutorServiceDelegate {
|
||||
protected val semaphore = new Semaphore(bound)
|
||||
|
||||
override def execute(command: Runnable) = {
|
||||
|
|
@ -214,10 +215,10 @@ class BoundedExecutorDecorator(val executor: ExecutorService, bound: Int) extend
|
|||
})
|
||||
} catch {
|
||||
case e: RejectedExecutionException ⇒
|
||||
EventHandler.warning(this, e.toString)
|
||||
app.eventHandler.warning(this, e.toString)
|
||||
semaphore.release
|
||||
case e: Throwable ⇒
|
||||
EventHandler.error(e, this, e.getMessage)
|
||||
app.eventHandler.error(e, this, e.getMessage)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue