blob: c6c4e4a565fc12029a01a2741356a5108e4f771b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package akka
import org.aspectj.lang.annotation.{Pointcut, Before, Aspect}
import java.util.concurrent.{TimeUnit, Executors}
@Aspect
class PoolMonitorAspect {
@Pointcut("execution(scala.concurrent.forkjoin.ForkJoinPool.new(..))")
protected def poolMonitor:Unit = {}
@Before("poolMonitor() && this(pool)")
def beforePoolInstantiation(pool: scala.concurrent.forkjoin.ForkJoinPool) {
val scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleAtFixedRate(new Runnable {
def run() {
println("PoolName : " + pool.getClass.getSimpleName)
println("ThreadCount :" + pool.getActiveThreadCount)
println("Parallelism :" + pool.getParallelism)
println("PoolSize :" + pool.getPoolSize())
println("Submission :" + pool.getQueuedSubmissionCount())
println("Steals :" + pool.getStealCount())
println("All :" + pool.toString)
}
}, 4, 4, TimeUnit.SECONDS)
}
}
|