Skip to content

Commit

Permalink
Rename class to MultiNodePipelineThreadPool
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed Aug 19, 2023
1 parent 46d394b commit a286ebd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/main/java/redis/clients/jedis/MultiNodePipelineBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import redis.clients.jedis.graph.GraphCommandObjects;
import redis.clients.jedis.providers.ConnectionProvider;
import redis.clients.jedis.util.IOUtils;
import redis.clients.jedis.util.JedisThreadPool;
import redis.clients.jedis.util.MultiNodePipelineThreadPool;

public abstract class MultiNodePipelineBase extends PipelineBase
implements PipelineCommands, PipelineBinaryCommands, RedisModulePipelineCommands, Closeable {
Expand Down Expand Up @@ -94,7 +94,7 @@ public void close() {
}

private ExecutorService getThreadPool() {
ExecutorService threadPool = JedisThreadPool.getThreadPool();
ExecutorService threadPool = MultiNodePipelineThreadPool.getThreadPool();
if (threadPool != null) return threadPool;

return Executors.newFixedThreadPool(MULTI_NODE_PIPELINE_SYNC_WORKERS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* JedisThreadFactoryBuilder is a class that builds a ThreadFactory for Jedis.
*/
public class JedisThreadFactoryBuilder {

private String namePrefix = null;
private boolean daemon = false;
private int priority = Thread.NORM_PRIORITY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@
/**
* This class is used to build a thread pool for Jedis.
*/
public class JedisThreadPool {
public class MultiNodePipelineThreadPool {

private static final Logger log = LoggerFactory.getLogger(JedisThreadPool.class);
private static final Logger log = LoggerFactory.getLogger(MultiNodePipelineThreadPool.class);

private static final RejectedExecutionHandler defaultRejectHandler = new AbortPolicy();

public static PoolBuilder poolBuilder() {
return new PoolBuilder();
}

/**
* The following are the default parameters for the multi node pipeline executor
* Since Redis query is usually a slower IO operation (requires more threads),
* so we set DEFAULT_CORE_POOL_SIZE to be the same as the core
*/
private static final long DEFAULT_KEEPALIVE_TIME_MS = 60000L;
private static final int DEFAULT_BLOCKING_QUEUE_SIZE = Protocol.CLUSTER_HASHSLOTS;
private static final int DEFAULT_CORE_POOL_SIZE = Runtime.getRuntime().availableProcessors();
private static final int DEFAULT_MAXIMUM_POOL_SIZE = Runtime.getRuntime().availableProcessors() * 2;
private static ExecutorService executorService = null;
/**
* The following are the default parameters for the multi node pipeline executor
* Since Redis query is usually a slower IO operation (requires more threads),
* so we set DEFAULT_CORE_POOL_SIZE to be the same as the core
*/
private static final long DEFAULT_KEEPALIVE_TIME_MS = 60000L;
private static final int DEFAULT_BLOCKING_QUEUE_SIZE = Protocol.CLUSTER_HASHSLOTS;
private static final int DEFAULT_CORE_POOL_SIZE = Runtime.getRuntime().availableProcessors();
private static final int DEFAULT_MAXIMUM_POOL_SIZE = Runtime.getRuntime().availableProcessors() * 2;
private static ExecutorService executorService = null;

public static ExecutorService getThreadPool() {
return executorService;
Expand All @@ -58,17 +58,17 @@ public static void setThreadPool(ExecutorService executor) {
* @return thread pool
*/
public static ExecutorService createDefaultThreadPool() {
return JedisThreadPool.poolBuilder()
return MultiNodePipelineThreadPool.poolBuilder()
.setCoreSize(DEFAULT_CORE_POOL_SIZE)
.setMaxSize(DEFAULT_MAXIMUM_POOL_SIZE)
.setKeepAliveMillSecs(DEFAULT_KEEPALIVE_TIME_MS)
.setThreadNamePrefix("jedis-multi-node-pipeline")
.setThreadNamePrefix("multi-node-pipeline")
.setWorkQueue(new ArrayBlockingQueue<>(DEFAULT_BLOCKING_QUEUE_SIZE)).build();
}

/**
* This is a shortcut for {@link JedisThreadPool#createDefaultThreadPool()} and
* {@link JedisThreadPool#setThreadPool(java.util.concurrent.ExecutorService)}.
* This is a shortcut for {@link MultiNodePipelineThreadPool#createDefaultThreadPool()} and
* {@link MultiNodePipelineThreadPool#setThreadPool(java.util.concurrent.ExecutorService)}.
*/
public static void createAndUseDefaultThreadPool() {
setThreadPool(createDefaultThreadPool());
Expand Down

0 comments on commit a286ebd

Please sign in to comment.