本文整理汇总了C++中MessageQueue::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageQueue::toString方法的具体用法?C++ MessageQueue::toString怎么用?C++ MessageQueue::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageQueue
的用法示例。
在下文中一共展示了MessageQueue::toString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rebalanceByTopic
void RebalanceImpl::rebalanceByTopic(const std::string& topic)
{
switch (m_messageModel)
{
case BROADCASTING:
{
std::map<std::string, std::set<MessageQueue> >::iterator it = m_topicSubscribeInfoTable.find(topic);
if (it != m_topicSubscribeInfoTable.end())
{
std::set<MessageQueue> mqSet = it->second;
bool changed = updateProcessQueueTableInRebalance(topic, mqSet);
if (changed)
{
messageQueueChanged(topic, mqSet, mqSet);
//TODO log.info("messageQueueChanged {} {} {} {}",//
// consumerGroup,//
// topic,//
// mqSet,//
// mqSet);
}
}
else
{
//TODO log.warn("doRebalance, {}, but the topic[{}] not exist.", consumerGroup, topic);
}
break;
}
case CLUSTERING:
{
std::map<std::string, std::set<MessageQueue> >::iterator it = m_topicSubscribeInfoTable.find(topic);
if (it == m_topicSubscribeInfoTable.end())
{
if (topic.find(MixAll::RETRY_GROUP_TOPIC_PREFIX) !=0 )
{
Logger::get_logger()->warn("doRebalance, {}, but the topic[{}] not exist.", m_consumerGroup, topic);
}
}
// std::cout<<"findConsumerIdList::::"<<topic<<","<<m_consumerGroup<<std::endl;
std::list<std::string> cidAll = m_pMQClientFactory->findConsumerIdList(topic, m_consumerGroup);
// std::cout<<"cidAll::::"<<cidAll.size()<<std::endl;
if (cidAll.empty())
{
Logger::get_logger()->warn("doRebalance, {} {}, get consumer id list failed", m_consumerGroup, topic);
}
else
Logger::get_logger()->warn("doRebalance, {} {}, get consumer id list succeed doRebalance ", m_consumerGroup, topic);
if (it != m_topicSubscribeInfoTable.end() && !cidAll.empty())
{
std::vector<MessageQueue> mqAll;
std::set<MessageQueue> mqSet = it->second;
std::set<MessageQueue>::iterator its = mqSet.begin();
//set 本身已经排序
for (; its != mqSet.end(); its++)
{
mqAll.push_back(*its);
}
// 排序
cidAll.sort();
AllocateMessageQueueStrategy* strategy = m_pAllocateMessageQueueStrategy;
// 执行分配算法
std::vector<MessageQueue>* allocateResult;
try
{
allocateResult = strategy->allocate(m_pMQClientFactory->getClientId(), mqAll, cidAll);
std::cout<<allocateResult->size()<<std::endl;
std::vector<MessageQueue>::iterator it = allocateResult->begin();
for(; it!=allocateResult->end(); it++) {
MessageQueue ms = *it;
std::cout<<ms.toString()<<std::endl;
}
}
catch (...)
{
Logger::get_logger()->error("AllocateMessageQueueStrategy.allocate Exception");
}
std::set<MessageQueue> allocateResultSet;
if (allocateResult != NULL)
{
for(size_t i=0; i<allocateResult->size(); i++)
{
allocateResultSet.insert(allocateResult->at(i));
}
delete allocateResult;
}
// 更新本地队列
bool changed = updateProcessQueueTableInRebalance(topic, allocateResultSet);
if (changed)
{
// Logger::get_logger()->info(
//.........这里部分代码省略.........