|
34 | 34 | import org.apache.rocketmq.broker.filter.CommitLogDispatcherCalcBitMap;
|
35 | 35 | import org.apache.rocketmq.broker.filter.ConsumerFilterManager;
|
36 | 36 | import org.apache.rocketmq.broker.latency.BrokerFastFailure;
|
37 |
| -import org.apache.rocketmq.broker.latency.BrokerFixedThreadPoolExecutor; |
38 | 37 | import org.apache.rocketmq.broker.longpolling.LmqPullRequestHoldService;
|
39 | 38 | import org.apache.rocketmq.broker.longpolling.NotifyMessageArrivingListener;
|
40 | 39 | import org.apache.rocketmq.broker.longpolling.PullRequestHoldService;
|
|
98 | 97 | import org.apache.rocketmq.common.message.MessageExtBrokerInner;
|
99 | 98 | import org.apache.rocketmq.common.stats.MomentStatsItem;
|
100 | 99 | import org.apache.rocketmq.common.utils.ServiceProvider;
|
| 100 | +import org.apache.rocketmq.common.utils.ThreadUtils; |
101 | 101 | import org.apache.rocketmq.logging.org.slf4j.Logger;
|
102 | 102 | import org.apache.rocketmq.logging.org.slf4j.LoggerFactory;
|
103 | 103 | import org.apache.rocketmq.remoting.Configuration;
|
|
160 | 160 | import java.util.concurrent.LinkedBlockingQueue;
|
161 | 161 | import java.util.concurrent.ScheduledExecutorService;
|
162 | 162 | import java.util.concurrent.ScheduledFuture;
|
163 |
| -import java.util.concurrent.ScheduledThreadPoolExecutor; |
164 | 163 | import java.util.concurrent.TimeUnit;
|
165 | 164 | import java.util.concurrent.locks.Lock;
|
166 | 165 | import java.util.concurrent.locks.ReentrantLock;
|
@@ -455,116 +454,116 @@ protected void initializeRemotingServer() throws CloneNotSupportedException {
|
455 | 454 | * Initialize resources including remoting server and thread executors.
|
456 | 455 | */
|
457 | 456 | protected void initializeResources() {
|
458 |
| - this.scheduledExecutorService = new ScheduledThreadPoolExecutor(1, |
| 457 | + this.scheduledExecutorService = ThreadUtils.newScheduledThreadPool(1, |
459 | 458 | new ThreadFactoryImpl("BrokerControllerScheduledThread", true, getBrokerIdentity()));
|
460 | 459 |
|
461 |
| - this.sendMessageExecutor = new BrokerFixedThreadPoolExecutor( |
| 460 | + this.sendMessageExecutor = ThreadUtils.newThreadPoolExecutor( |
462 | 461 | this.brokerConfig.getSendMessageThreadPoolNums(),
|
463 | 462 | this.brokerConfig.getSendMessageThreadPoolNums(),
|
464 | 463 | 1000 * 60,
|
465 | 464 | TimeUnit.MILLISECONDS,
|
466 | 465 | this.sendThreadPoolQueue,
|
467 | 466 | new ThreadFactoryImpl("SendMessageThread_", getBrokerIdentity()));
|
468 | 467 |
|
469 |
| - this.pullMessageExecutor = new BrokerFixedThreadPoolExecutor( |
| 468 | + this.pullMessageExecutor = ThreadUtils.newThreadPoolExecutor( |
470 | 469 | this.brokerConfig.getPullMessageThreadPoolNums(),
|
471 | 470 | this.brokerConfig.getPullMessageThreadPoolNums(),
|
472 | 471 | 1000 * 60,
|
473 | 472 | TimeUnit.MILLISECONDS,
|
474 | 473 | this.pullThreadPoolQueue,
|
475 | 474 | new ThreadFactoryImpl("PullMessageThread_", getBrokerIdentity()));
|
476 | 475 |
|
477 |
| - this.litePullMessageExecutor = new BrokerFixedThreadPoolExecutor( |
| 476 | + this.litePullMessageExecutor = ThreadUtils.newThreadPoolExecutor( |
478 | 477 | this.brokerConfig.getLitePullMessageThreadPoolNums(),
|
479 | 478 | this.brokerConfig.getLitePullMessageThreadPoolNums(),
|
480 | 479 | 1000 * 60,
|
481 | 480 | TimeUnit.MILLISECONDS,
|
482 | 481 | this.litePullThreadPoolQueue,
|
483 | 482 | new ThreadFactoryImpl("LitePullMessageThread_", getBrokerIdentity()));
|
484 | 483 |
|
485 |
| - this.putMessageFutureExecutor = new BrokerFixedThreadPoolExecutor( |
| 484 | + this.putMessageFutureExecutor = ThreadUtils.newThreadPoolExecutor( |
486 | 485 | this.brokerConfig.getPutMessageFutureThreadPoolNums(),
|
487 | 486 | this.brokerConfig.getPutMessageFutureThreadPoolNums(),
|
488 | 487 | 1000 * 60,
|
489 | 488 | TimeUnit.MILLISECONDS,
|
490 | 489 | this.putThreadPoolQueue,
|
491 | 490 | new ThreadFactoryImpl("SendMessageThread_", getBrokerIdentity()));
|
492 | 491 |
|
493 |
| - this.ackMessageExecutor = new BrokerFixedThreadPoolExecutor( |
| 492 | + this.ackMessageExecutor = ThreadUtils.newThreadPoolExecutor( |
494 | 493 | this.brokerConfig.getAckMessageThreadPoolNums(),
|
495 | 494 | this.brokerConfig.getAckMessageThreadPoolNums(),
|
496 | 495 | 1000 * 60,
|
497 | 496 | TimeUnit.MILLISECONDS,
|
498 | 497 | this.ackThreadPoolQueue,
|
499 | 498 | new ThreadFactoryImpl("AckMessageThread_", getBrokerIdentity()));
|
500 | 499 |
|
501 |
| - this.queryMessageExecutor = new BrokerFixedThreadPoolExecutor( |
| 500 | + this.queryMessageExecutor = ThreadUtils.newThreadPoolExecutor( |
502 | 501 | this.brokerConfig.getQueryMessageThreadPoolNums(),
|
503 | 502 | this.brokerConfig.getQueryMessageThreadPoolNums(),
|
504 | 503 | 1000 * 60,
|
505 | 504 | TimeUnit.MILLISECONDS,
|
506 | 505 | this.queryThreadPoolQueue,
|
507 | 506 | new ThreadFactoryImpl("QueryMessageThread_", getBrokerIdentity()));
|
508 | 507 |
|
509 |
| - this.adminBrokerExecutor = new BrokerFixedThreadPoolExecutor( |
| 508 | + this.adminBrokerExecutor = ThreadUtils.newThreadPoolExecutor( |
510 | 509 | this.brokerConfig.getAdminBrokerThreadPoolNums(),
|
511 | 510 | this.brokerConfig.getAdminBrokerThreadPoolNums(),
|
512 | 511 | 1000 * 60,
|
513 | 512 | TimeUnit.MILLISECONDS,
|
514 | 513 | this.adminBrokerThreadPoolQueue,
|
515 | 514 | new ThreadFactoryImpl("AdminBrokerThread_", getBrokerIdentity()));
|
516 | 515 |
|
517 |
| - this.clientManageExecutor = new BrokerFixedThreadPoolExecutor( |
| 516 | + this.clientManageExecutor = ThreadUtils.newThreadPoolExecutor( |
518 | 517 | this.brokerConfig.getClientManageThreadPoolNums(),
|
519 | 518 | this.brokerConfig.getClientManageThreadPoolNums(),
|
520 | 519 | 1000 * 60,
|
521 | 520 | TimeUnit.MILLISECONDS,
|
522 | 521 | this.clientManagerThreadPoolQueue,
|
523 | 522 | new ThreadFactoryImpl("ClientManageThread_", getBrokerIdentity()));
|
524 | 523 |
|
525 |
| - this.heartbeatExecutor = new BrokerFixedThreadPoolExecutor( |
| 524 | + this.heartbeatExecutor = ThreadUtils.newThreadPoolExecutor( |
526 | 525 | this.brokerConfig.getHeartbeatThreadPoolNums(),
|
527 | 526 | this.brokerConfig.getHeartbeatThreadPoolNums(),
|
528 | 527 | 1000 * 60,
|
529 | 528 | TimeUnit.MILLISECONDS,
|
530 | 529 | this.heartbeatThreadPoolQueue,
|
531 | 530 | new ThreadFactoryImpl("HeartbeatThread_", true, getBrokerIdentity()));
|
532 | 531 |
|
533 |
| - this.consumerManageExecutor = new BrokerFixedThreadPoolExecutor( |
| 532 | + this.consumerManageExecutor = ThreadUtils.newThreadPoolExecutor( |
534 | 533 | this.brokerConfig.getConsumerManageThreadPoolNums(),
|
535 | 534 | this.brokerConfig.getConsumerManageThreadPoolNums(),
|
536 | 535 | 1000 * 60,
|
537 | 536 | TimeUnit.MILLISECONDS,
|
538 | 537 | this.consumerManagerThreadPoolQueue,
|
539 | 538 | new ThreadFactoryImpl("ConsumerManageThread_", true, getBrokerIdentity()));
|
540 | 539 |
|
541 |
| - this.replyMessageExecutor = new BrokerFixedThreadPoolExecutor( |
| 540 | + this.replyMessageExecutor = ThreadUtils.newThreadPoolExecutor( |
542 | 541 | this.brokerConfig.getProcessReplyMessageThreadPoolNums(),
|
543 | 542 | this.brokerConfig.getProcessReplyMessageThreadPoolNums(),
|
544 | 543 | 1000 * 60,
|
545 | 544 | TimeUnit.MILLISECONDS,
|
546 | 545 | this.replyThreadPoolQueue,
|
547 | 546 | new ThreadFactoryImpl("ProcessReplyMessageThread_", getBrokerIdentity()));
|
548 | 547 |
|
549 |
| - this.endTransactionExecutor = new BrokerFixedThreadPoolExecutor( |
| 548 | + this.endTransactionExecutor = ThreadUtils.newThreadPoolExecutor( |
550 | 549 | this.brokerConfig.getEndTransactionThreadPoolNums(),
|
551 | 550 | this.brokerConfig.getEndTransactionThreadPoolNums(),
|
552 | 551 | 1000 * 60,
|
553 | 552 | TimeUnit.MILLISECONDS,
|
554 | 553 | this.endTransactionThreadPoolQueue,
|
555 | 554 | new ThreadFactoryImpl("EndTransactionThread_", getBrokerIdentity()));
|
556 | 555 |
|
557 |
| - this.loadBalanceExecutor = new BrokerFixedThreadPoolExecutor( |
| 556 | + this.loadBalanceExecutor = ThreadUtils.newThreadPoolExecutor( |
558 | 557 | this.brokerConfig.getLoadBalanceProcessorThreadPoolNums(),
|
559 | 558 | this.brokerConfig.getLoadBalanceProcessorThreadPoolNums(),
|
560 | 559 | 1000 * 60,
|
561 | 560 | TimeUnit.MILLISECONDS,
|
562 | 561 | this.loadBalanceThreadPoolQueue,
|
563 | 562 | new ThreadFactoryImpl("LoadBalanceProcessorThread_", getBrokerIdentity()));
|
564 | 563 |
|
565 |
| - this.syncBrokerMemberGroupExecutorService = new ScheduledThreadPoolExecutor(1, |
| 564 | + this.syncBrokerMemberGroupExecutorService = ThreadUtils.newScheduledThreadPool(1, |
566 | 565 | new ThreadFactoryImpl("BrokerControllerSyncBrokerScheduledThread", getBrokerIdentity()));
|
567 |
| - this.brokerHeartbeatExecutorService = new ScheduledThreadPoolExecutor(1, |
| 566 | + this.brokerHeartbeatExecutorService = ThreadUtils.newScheduledThreadPool(1, |
568 | 567 | new ThreadFactoryImpl("BrokerControllerHeartbeatScheduledThread", getBrokerIdentity()));
|
569 | 568 |
|
570 | 569 | this.topicQueueMappingCleanService = new TopicQueueMappingCleanService(this);
|
@@ -828,8 +827,6 @@ public boolean recoverAndInitService() throws CloneNotSupportedException {
|
828 | 827 |
|
829 | 828 | initializeResources();
|
830 | 829 |
|
831 |
| - registerProcessor(); |
832 |
| - |
833 | 830 | initializeScheduledTasks();
|
834 | 831 |
|
835 | 832 | initialTransaction();
|
@@ -1690,6 +1687,8 @@ public void run() {
|
1690 | 1687 | }
|
1691 | 1688 | }
|
1692 | 1689 | }, 10, 5, TimeUnit.SECONDS);
|
| 1690 | + |
| 1691 | + registerProcessor(); |
1693 | 1692 | }
|
1694 | 1693 |
|
1695 | 1694 | protected void scheduleSendHeartbeat() {
|
|
0 commit comments