mirror of
https://github.com/apache/rocketmq.git
synced 2026-09-21 13:49:50 +08:00
[ISSUE 3585] [Part E] eliminate duplicated getNamespace() call when where is no namespace (#3591)
Co-authored-by: colin <39513055@qq.com>
This commit is contained in:
@@ -39,6 +39,7 @@ public class ClientConfig {
|
||||
private String instanceName = System.getProperty("rocketmq.client.name", "DEFAULT");
|
||||
private int clientCallbackExecutorThreads = Runtime.getRuntime().availableProcessors();
|
||||
protected String namespace;
|
||||
private boolean namespaceInitialized = false;
|
||||
protected AccessChannel accessChannel = AccessChannel.LOCAL;
|
||||
|
||||
/**
|
||||
@@ -195,6 +196,7 @@ public class ClientConfig {
|
||||
*/
|
||||
public void setNamesrvAddr(String namesrvAddr) {
|
||||
this.namesrvAddr = namesrvAddr;
|
||||
this.namespaceInitialized = false;
|
||||
}
|
||||
|
||||
public int getClientCallbackExecutorThreads() {
|
||||
@@ -278,20 +280,26 @@ public class ClientConfig {
|
||||
}
|
||||
|
||||
public String getNamespace() {
|
||||
if (namespaceInitialized) {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(namespace)) {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(this.namesrvAddr)) {
|
||||
if (NameServerAddressUtils.validateInstanceEndpoint(namesrvAddr)) {
|
||||
return NameServerAddressUtils.parseInstanceIdFromEndpoint(namesrvAddr);
|
||||
namespace = NameServerAddressUtils.parseInstanceIdFromEndpoint(namesrvAddr);
|
||||
}
|
||||
}
|
||||
namespaceInitialized = true;
|
||||
return namespace;
|
||||
}
|
||||
|
||||
public void setNamespace(String namespace) {
|
||||
this.namespace = namespace;
|
||||
this.namespaceInitialized = true;
|
||||
}
|
||||
|
||||
public AccessChannel getAccessChannel() {
|
||||
|
||||
Reference in New Issue
Block a user