Use common thread pool only if it is set by user#2
Use common thread pool only if it is set by user#2sazzad16 wants to merge 3 commits intoyangbodong22011:feature-introduce-jedis-thread-factoryfrom
Conversation
| } | ||
| } | ||
|
|
||
| private ExecutorService getThreadPool() { |
There was a problem hiding this comment.
Do you want the user to call createAndUseDefaultThreadPool to enable the thread pool? Before again, Executors.newFixedThreadPool(MULTI_NODE_PIPELINE_SYNC_WORKERS) is still used here, and, I don't think newFixedThreadPool is needed, we already have thread pool with custom parameters. Just define it as static.
There was a problem hiding this comment.
I want to keep the current behavior as the default behavior just so a large[1] pipeline doesn't cause many other pipelines to be waiting for a long time.
[1] with many connections (master nodes) and many commands to each node.
There was a problem hiding this comment.
[1] with many connections (master nodes) and many commands to each node.
In this case users should use setThreadPool to set it themselves.
The time to create and destroy FixedThreadPool each time will be longer than the execution pipeline (the operating system needs to call multiple system calls to create and destroy threads)
| */ | ||
| public class JedisThreadPoolBuilder { | ||
| private static final Logger log = LoggerFactory.getLogger(JedisThreadPoolBuilder.class); | ||
| public class MultiNodePipelineThreadPool { |
There was a problem hiding this comment.
If we name it MultiNodePipelineThreadPool, it is ok at present, but when we need a XXXThreadPool next time, we have to copy the code of MultiNodePipelineThreadPool, which will make a lot of code redundant, such as PoolBuilder.
There was a problem hiding this comment.
I'm thinking to take the risk.
If such situations comes we can have JedisThreadPool with a name to thread pool map. I'm trying to avoid more complex implementation right now.
There was a problem hiding this comment.
Can't agree with your point of view. This does not introduce complexity, just add two tool classes JedisThreadFactoryBuilder and JedisThreadPoolBuilder (putting it in the util directory also ok), and then customize the thread pool where needed.
No description provided.