in lib/TopicName.cc [55:94]
bool TopicName::init(const std::string& topicName) {
topicName_ = topicName;
if (topicName.find("://") == std::string::npos) {
std::string topicNameCopy_ = topicName;
std::vector<std::string> pathTokens;
boost::algorithm::split(pathTokens, topicNameCopy_, boost::algorithm::is_any_of("/"));
if (pathTokens.size() == 3) {
topicName_ =
TopicDomain::Persistent + "://" + pathTokens[0] + "/" + pathTokens[1] + "/" + pathTokens[2];
} else if (pathTokens.size() == 1) {
topicName_ = TopicDomain::Persistent + "://public/default/" + pathTokens[0];
} else {
LOG_ERROR(
"Topic name is not valid, short topic name should be in the format of '<topic>' or "
"'<property>/<namespace>/<topic>' - "
<< topicName);
return false;
}
}
isV2Topic_ = parse(topicName_, domain_, property_, cluster_, namespacePortion_, localName_);
if (isV2Topic_ && !cluster_.empty()) {
LOG_ERROR("V2 Topic name is not valid, cluster is not empty - " << topicName_ << " : cluster "
<< cluster_);
return false;
} else if (!isV2Topic_ && cluster_.empty()) {
LOG_ERROR("V1 Topic name is not valid, cluster is empty - " << topicName_);
return false;
}
if (localName_.empty()) {
LOG_ERROR("Topic name is not valid, topic name is empty - " << topicName_);
return false;
}
if (isV2Topic_ && cluster_.empty()) {
namespaceName_ = NamespaceName::get(property_, namespacePortion_);
} else {
namespaceName_ = NamespaceName::get(property_, cluster_, namespacePortion_);
}
partition_ = TopicName::getPartitionIndex(localName_);
return true;
}