Commit 5b00ca90 authored by jianhua.zhang's avatar jianhua.zhang

调整线程池数量

parent 18fd5782
......@@ -45,7 +45,9 @@ public class Engine {
*/
private AddressBalanceHandler addressHandler;
public static final int FETCHER_NUM = 10;
public static final int BLOCK_FETCHER_NUM = 10;
public static final int BALANCE_FETCHER_NUM = 3;
public Engine(String name) {
this.executor = new Executor(name);
......@@ -76,8 +78,7 @@ public class Engine {
this.handler = new BlockDataHandler();
this.fetcher = new BlockDataFetcher(this.handler);
this.executor.execute(this.handler);
//int cupNum = ThreadPoolUtil.getCupNum()*2;
for (int i = 0; i <= FETCHER_NUM; i++) {
for (int i = 0; i <= BLOCK_FETCHER_NUM; i++) {
this.executor.execute(this.fetcher);
}
......@@ -87,9 +88,12 @@ public class Engine {
this.addressHandler = new AddressBalanceHandler();
this.addressFetcher = new AddressBalanceFetcher(this.addressHandler);
this.executor.execute(this.addressHandler);
this.executor.execute(this.addressFetcher);
for (int i = 0; i < BALANCE_FETCHER_NUM; i++) {
this.executor.execute(this.addressFetcher);
}
}
public synchronized void reload() {
this.executor.shutdown();
this.executor.rebuild();
......
......@@ -26,10 +26,10 @@ public class PersistThreadPool {
public PersistThreadPool() {
for (int i = 0; i < POLL_SIZE; i++) {
executors.add(new ThreadPoolExecutor(POLL_SIZE, POLL_SIZE * 5, 0, TimeUnit.SECONDS,
executors.add(new ThreadPoolExecutor(POLL_SIZE, POLL_SIZE * 2, 0, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(), new PersistThreadFactory(i)));
}
log.info("初始化线程池 name:{} coreSize:{} maxSize:{}", "PersistThreadPool", POLL_SIZE, POLL_SIZE * 5);
log.info("初始化线程池 name:{} coreSize:{} maxSize:{}", "PersistThreadPool", POLL_SIZE, POLL_SIZE * 2);
}
public void stop() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment