@@ -16,6 +16,7 @@ public class Pools {
16
16
static final String CONFIG_JOBS_SCHEDULED_NUM_THREADS = "jobs.scheduled.num_threads" ;
17
17
static final String CONFIG_JOBS_POOL_NUM_THREADS = "jobs.pool.num_threads" ;
18
18
static final String CONFIG_BROKERS_NUM_THREADS = "brokers.num_threads" ;
19
+ static final String CONFIG_DEBUG_LOG_THREADS = "jobs.debug.logs" ;
19
20
20
21
public final static int DEFAULT_SCHEDULED_THREADS = Runtime .getRuntime ().availableProcessors () / 4 ;
21
22
public final static int DEFAULT_POOL_THREADS = Runtime .getRuntime ().availableProcessors () * 2 ;
@@ -46,9 +47,8 @@ private Pools() {
46
47
public static ExecutorService createDefaultPool () {
47
48
int threads = getNoThreadsInDefaultPool ();
48
49
int queueSize = threads * 25 ;
49
- return new ThreadPoolExecutor (threads / 2 , threads , 30L , TimeUnit .SECONDS , new ArrayBlockingQueue <>(queueSize ),
50
- new CallerBlocksPolicy ());
51
- // new ThreadPoolExecutor.CallerRunsPolicy());
50
+ return new ThreadPoolExecutorLogger (threads / 2 , threads , 30L , TimeUnit .SECONDS , new ArrayBlockingQueue <>(queueSize ),
51
+ new CallerBlocksPolicy (), "DEFAULT" , threadPoolDebug ());
52
52
}
53
53
static class CallerBlocksPolicy implements RejectedExecutionHandler {
54
54
@ Override
@@ -80,7 +80,9 @@ public static int getNoThreadsInBrokerPool() {
80
80
}
81
81
82
82
private static ExecutorService createSinglePool () {
83
- return Executors .newSingleThreadExecutor ();
83
+ return new ThreadPoolExecutorLogger (1 , 1 ,
84
+ 0L , TimeUnit .MILLISECONDS ,
85
+ new LinkedBlockingQueue <Runnable >(), "SINGLE" , threadPoolDebug () );
84
86
}
85
87
86
88
private static ScheduledExecutorService createScheduledPool () {
@@ -90,8 +92,8 @@ private static ScheduledExecutorService createScheduledPool() {
90
92
private static ExecutorService createBrokerPool () {
91
93
int threads = getNoThreadsInBrokerPool ();
92
94
int queueSize = threads * 25 ;
93
- return new ThreadPoolExecutor (threads / 2 , threads , 30L , TimeUnit .SECONDS , new ArrayBlockingQueue <>(queueSize ),
94
- new CallerBlocksPolicy ());
95
+ return new ThreadPoolExecutorLogger (threads / 2 , threads , 30L , TimeUnit .SECONDS , new ArrayBlockingQueue <>(queueSize ),
96
+ new CallerBlocksPolicy (), "BROKER" , threadPoolDebug () );
95
97
}
96
98
97
99
public static <T > Future <Void > processBatch (List <T > batch , GraphDatabaseService db , Consumer <T > action ) {
@@ -114,4 +116,9 @@ public static <T> T force(Future<T> future) throws ExecutionException {
114
116
}
115
117
}
116
118
}
119
+
120
+ public static Boolean threadPoolDebug ()
121
+ {
122
+ return Boolean .valueOf ( ApocConfiguration .get ( CONFIG_DEBUG_LOG_THREADS , "false" ) );
123
+ }
117
124
}
0 commit comments