maple525866 commented on code in PR #7783:
URL: https://github.com/apache/incubator-seata/pull/7783#discussion_r2533005258
##########
core/src/main/java/org/apache/seata/core/rpc/netty/AbstractNettyRemotingClient.java:
##########
@@ -120,29 +124,30 @@ public abstract class AbstractNettyRemotingClient extends
AbstractNettyRemoting
@Override
public void init() {
- timerExecutor.scheduleAtFixedRate(
- () -> {
- try {
-
clientChannelManager.reconnect(getTransactionServiceGroup());
- } catch (Exception ex) {
- LOGGER.warn("reconnect server failed. {}",
ex.getMessage());
- }
- },
- SCHEDULE_DELAY_MILLS,
- SCHEDULE_INTERVAL_MILLS,
- TimeUnit.MILLISECONDS);
- if (this.isEnableClientBatchSendRequest()) {
- mergeSendExecutorService = new ThreadPoolExecutor(
- MAX_MERGE_SEND_THREAD,
- MAX_MERGE_SEND_THREAD,
- KEEP_ALIVE_TIME,
- TimeUnit.MILLISECONDS,
- new LinkedBlockingQueue<>(),
- new NamedThreadFactory(getThreadPrefix(),
MAX_MERGE_SEND_THREAD));
- mergeSendExecutorService.submit(new MergedSendRunnable());
+ mergeLock.lock();
+ try {
+ if (timerStarted.compareAndSet(false, true)) {
+ timerExecutor.scheduleAtFixedRate(
Review Comment:
I don't think `mergeLock` should be used here, because it's originally
designed for merging and sending data; not using it can ensure single
responsibility.
##########
core/src/main/java/org/apache/seata/core/rpc/netty/AbstractNettyRemotingClient.java:
##########
@@ -271,11 +289,19 @@ public void destroyChannel(String serverAddress, Channel
channel) {
@Override
public void destroy() {
- clientBootstrap.shutdown();
- if (mergeSendExecutorService != null) {
- mergeSendExecutorService.shutdown();
+ mergeLock.lock();
+ try {
+ if (timerStarted.compareAndSet(true, false)) {
+ LOGGER.info("Reconnect timer stopped (role: {})",
transactionRole.name());
Review Comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]