| | |
| | | |
| | | namespace |
| | | { |
| | | const std::string &kTopicQueryProc = "@center_query_procs"; |
| | | const std::string &kTopicQueryProc = "#center_query_procs"; |
| | | |
| | | std::string ToJson(const MsgQueryProcReply &qpr) |
| | | { |
| | |
| | | } // namespace |
| | | |
| | | CenterTopicNode::CenterTopicNode(CenterPtr center, SharedMemory &shm) : |
| | | pscenter_(center), pnode_(new TopicNode(shm)), run_(false) {} |
| | | pscenter_(center), pnode_(new TopicNode(shm, 200)), run_(false) {} |
| | | |
| | | CenterTopicNode::~CenterTopicNode() { Stop(); } |
| | | |
| | |
| | | MsgCommonReply reply; |
| | | |
| | | ProcInfo info; |
| | | info.set_proc_id("#center.node"); |
| | | info.set_proc_id("@center.node"); |
| | | info.set_name("center node"); |
| | | if (!pnode_->UniRegister(true, info, reply, timeout)) { |
| | | Json jinfo; |
| | | jinfo.put("description", "some center services. Other nodes may use topics to use them."); |
| | | info.set_public_info(jinfo.dump()); |
| | | if (!pnode_->DoRegister(true, info, reply, timeout)) { |
| | | throw std::runtime_error("center node register failed."); |
| | | } |
| | | |
| | | MsgTopicList topics; |
| | | topics.add_topic_list(kTopicQueryProc); |
| | | if (!pnode_->ServerRegisterRPC(topics, reply, timeout)) { |
| | | if (!pnode_->DoServerRegisterRPC(true, topics, reply, timeout)) { |
| | | throw std::runtime_error("center node register topics failed."); |
| | | } |
| | | |
| | |
| | | *reply.mutable_errmsg() = data.errmsg(); |
| | | reply.set_data(ToJson(data)); |
| | | } else { |
| | | SetError(*reply.mutable_errmsg(), eInvalidInput, "not supported topic" + request.topic()); |
| | | SetError(*reply.mutable_errmsg(), eInvalidInput, "invalid topic: " + request.topic()); |
| | | } |
| | | pnode_->ServerSendReply(src_info, reply); |
| | | }; |