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(
//							"rebalanced allocate source.  group={}, topic={}, mqAllSize={}, cidAllSize={}, mqAll={}, cidAll={}",
//							m_consumerGroup, topic, mqSet.size(), cidAll.size(), mqSet, cidAll);
//					Logger::get_logger()->info(
//							"rebalanced result changed., group={}, topic={}, ConsumerId={}, rebalanceSize={},{},{} rebalanceMqSet={}",
//							m_consumerGroup, topic, m_pMQClientFactory->getClientId(),
//							allocateResultSet.size(), mqAll.size(), cidAll.size(), allocateResultSet);

                messageQueueChanged(topic, mqSet, allocateResultSet);

            }
        }
        break;
    }
    default:
        break;
    }
}