Skip to content

Commit

Permalink
[ISSUE apache#8358] Client does not send heartbeats to all Nameserve …
Browse files Browse the repository at this point in the history
…in clustered mode, resulting in frequent disconnections (apache#8359)

* Adding null does not update

* rolling back

* remove client scanAvailableNameSrv
  • Loading branch information
weihubeats authored Jul 4, 2024
1 parent 933ffc0 commit 92c9223
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public MQClientInstance(ClientConfig clientConfig, int instanceIndex, String cli
this.nettyClientConfig.setClientCallbackExecutorThreads(clientConfig.getClientCallbackExecutorThreads());
this.nettyClientConfig.setUseTLS(clientConfig.isUseTLS());
this.nettyClientConfig.setSocksProxyConfig(clientConfig.getSocksProxyConfig());
this.nettyClientConfig.setScanAvailableNameSrv(false);
ClientRemotingProcessor clientRemotingProcessor = new ClientRemotingProcessor(this);
ChannelEventListener channelEventListener;
if (clientConfig.isEnableHeartbeatChannelEventListener()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class NettyClientConfig {
private int connectTimeoutMillis = NettySystemConfig.connectTimeoutMillis;
private long channelNotActiveInterval = 1000 * 60;

private boolean isScanAvailableNameSrv = true;

/**
* IdleStateEvent will be triggered when neither read nor write was performed for
* the specified period of this time. Specify {@code 0} to disable
Expand Down Expand Up @@ -218,4 +220,12 @@ public String getSocksProxyConfig() {
public void setSocksProxyConfig(String socksProxyConfig) {
this.socksProxyConfig = socksProxyConfig;
}

public boolean isScanAvailableNameSrv() {
return isScanAvailableNameSrv;
}

public void setScanAvailableNameSrv(boolean scanAvailableNameSrv) {
this.isScanAvailableNameSrv = scanAvailableNameSrv;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,20 +251,24 @@ public void run(Timeout timeout) {
};
this.timer.newTimeout(timerTaskScanResponseTable, 1000 * 3, TimeUnit.MILLISECONDS);

int connectTimeoutMillis = this.nettyClientConfig.getConnectTimeoutMillis();
TimerTask timerTaskScanAvailableNameSrv = new TimerTask() {
@Override
public void run(Timeout timeout) {
try {
NettyRemotingClient.this.scanAvailableNameSrv();
} catch (Exception e) {
LOGGER.error("scanAvailableNameSrv exception", e);
} finally {
timer.newTimeout(this, connectTimeoutMillis, TimeUnit.MILLISECONDS);
if (nettyClientConfig.isScanAvailableNameSrv()) {
int connectTimeoutMillis = this.nettyClientConfig.getConnectTimeoutMillis();
TimerTask timerTaskScanAvailableNameSrv = new TimerTask() {
@Override
public void run(Timeout timeout) {
try {
NettyRemotingClient.this.scanAvailableNameSrv();
} catch (Exception e) {
LOGGER.error("scanAvailableNameSrv exception", e);
} finally {
timer.newTimeout(this, connectTimeoutMillis, TimeUnit.MILLISECONDS);
}
}
}
};
this.timer.newTimeout(timerTaskScanAvailableNameSrv, 0, TimeUnit.MILLISECONDS);
};
this.timer.newTimeout(timerTaskScanAvailableNameSrv, 0, TimeUnit.MILLISECONDS);
}


}

private Map.Entry<String, SocksProxyConfig> getProxy(String addr) {
Expand Down

0 comments on commit 92c9223

Please sign in to comment.