Skip to content

Commit

Permalink
Merge 2126929 into 90ae116
Browse files Browse the repository at this point in the history
  • Loading branch information
duhenglucky committed Aug 22, 2019
2 parents 90ae116 + 2126929 commit 464965f
Show file tree
Hide file tree
Showing 20 changed files with 2,517 additions and 38 deletions.
18 changes: 16 additions & 2 deletions client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
Expand Up @@ -16,7 +16,9 @@
*/
package org.apache.rocketmq.client;

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.common.UtilAll;
Expand Down Expand Up @@ -95,7 +97,6 @@ public void changeInstanceNameToPID() {
}
}


public String withNamespace(String resource) {
return NamespaceUtil.wrapNamespace(this.getNamespace(), resource);
}
Expand Down Expand Up @@ -124,9 +125,21 @@ public MessageQueue queueWithNamespace(MessageQueue queue) {
if (StringUtils.isEmpty(this.getNamespace())) {
return queue;
}

return new MessageQueue(withNamespace(queue.getTopic()), queue.getBrokerName(), queue.getQueueId());
}

public Collection<MessageQueue> queuesWithNamespace(Collection<MessageQueue> queues) {
if (StringUtils.isEmpty(this.getNamespace())) {
return queues;
}
Iterator<MessageQueue> iter = queues.iterator();
while (iter.hasNext()) {
MessageQueue queue = iter.next();
queue.setTopic(withNamespace(queue.getTopic()));
}
return queues;
}

public void resetClientConfig(final ClientConfig cc) {
this.namesrvAddr = cc.namesrvAddr;
this.clientIP = cc.clientIP;
Expand Down Expand Up @@ -170,6 +183,7 @@ public String getNamesrvAddr() {

/**
* Domain name mode access way does not support the delimiter(;), and only one domain name can be set.
*
* @param namesrvAddr name server address
*/
public void setNamesrvAddr(String namesrvAddr) {
Expand Down
Expand Up @@ -53,14 +53,17 @@ public static void checkGroup(String group) throws MQClientException {
if (UtilAll.isBlank(group)) {
throw new MQClientException("the specified group is blank", null);
}

if (group.length() > CHARACTER_MAX_LENGTH) {
throw new MQClientException("the specified group is longer than group max length 255.", null);
}

if (!regularExpressionMatcher(group, PATTERN)) {
throw new MQClientException(String.format(
"the specified group[%s] contains illegal characters, allowing only %s", group,
VALID_PATTERN_STR), null);
}
if (group.length() > CHARACTER_MAX_LENGTH) {
throw new MQClientException("the specified group is longer than group max length 255.", null);
}

}

/**
Expand Down

0 comments on commit 464965f

Please sign in to comment.