Skip to content

Commit

Permalink
[ISSUE #9182] Fix NameServer will be not ready forever when set needW…
Browse files Browse the repository at this point in the history
…aitForService to true (#9183)

* Fix NameServer will be not ready forever when set needWaitForService to true

* Remove unused import
  • Loading branch information
gaoyf authored Feb 17, 2025
1 parent 295821b commit 98308f6
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.netty.channel.ChannelHandlerContext;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.rocketmq.common.MQVersion;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.help.FAQUrl;
Expand All @@ -43,8 +42,6 @@ public class ClientRequestProcessor implements NettyRequestProcessor {
protected NamesrvController namesrvController;
private long startupTimeMillis;

private AtomicBoolean needCheckNamesrvReady = new AtomicBoolean(true);

public ClientRequestProcessor(final NamesrvController namesrvController) {
this.namesrvController = namesrvController;
this.startupTimeMillis = System.currentTimeMillis();
Expand All @@ -62,7 +59,7 @@ public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx,
final GetRouteInfoRequestHeader requestHeader =
(GetRouteInfoRequestHeader) request.decodeCommandCustomHeader(GetRouteInfoRequestHeader.class);

boolean namesrvReady = needCheckNamesrvReady.get() && System.currentTimeMillis() - startupTimeMillis >= TimeUnit.SECONDS.toMillis(namesrvController.getNamesrvConfig().getWaitSecondsForService());
boolean namesrvReady = System.currentTimeMillis() - startupTimeMillis >= TimeUnit.SECONDS.toMillis(namesrvController.getNamesrvConfig().getWaitSecondsForService());

if (namesrvController.getNamesrvConfig().isNeedWaitForService() && !namesrvReady) {
log.warn("name server not ready. request code {} ", request.getCode());
Expand All @@ -74,11 +71,6 @@ public RemotingCommand getRouteInfoByTopic(ChannelHandlerContext ctx,
TopicRouteData topicRouteData = this.namesrvController.getRouteInfoManager().pickupTopicRouteData(requestHeader.getTopic());

if (topicRouteData != null) {
//topic route info register success ,so disable namesrvReady check
if (needCheckNamesrvReady.get()) {
needCheckNamesrvReady.set(false);
}

if (this.namesrvController.getNamesrvConfig().isOrderMessageEnable()) {
String orderTopicConf =
this.namesrvController.getKvConfigManager().getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG,
Expand Down

0 comments on commit 98308f6

Please # to comment.