提交 ac05ab42 authored 作者: blu's avatar blu

big refacting of communitation architect

上级 1455e1eb
...@@ -99,7 +99,6 @@ private: ...@@ -99,7 +99,6 @@ private:
pid_t pid; pid_t pid;
for(auto &[k,v]:data.items()) { for(auto &[k,v]:data.items()) {
if(k == this->devSn) { if(k == this->devSn) {
// startup evmgr
peerId = v["sn"].get<string>() + ":evmgr:0"; peerId = v["sn"].get<string>() + ":evmgr:0";
this->peerData["config"][peerId] = v; this->peerData["config"][peerId] = v;
if(this->peerData["status"].count(peerId) == 0) { if(this->peerData["status"].count(peerId) == 0) {
...@@ -107,6 +106,7 @@ private: ...@@ -107,6 +106,7 @@ private:
}else{ }else{
// nop // nop
} }
this->peerData["enabled"][peerId] = 1;
} }
// startup other submodules // startup other submodules
...@@ -313,7 +313,7 @@ private: ...@@ -313,7 +313,7 @@ private:
this->peerData["status"][selfId] = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count(); this->peerData["status"][selfId] = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
// msg to peer // msg to peer
string myId = devSn + ":0:0"; string myId = devSn + ":evmgr:0";
int minLen = std::min(body[1].size(), myId.size()); int minLen = std::min(body[1].size(), myId.size());
if(memcmp((void*)(body[1].data()), myId.data(), minLen) != 0) { if(memcmp((void*)(body[1].data()), myId.data(), minLen) != 0) {
// message to other peer // message to other peer
......
...@@ -176,7 +176,7 @@ private: ...@@ -176,7 +176,7 @@ private:
this->peerData["status"][selfId] = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count(); this->peerData["status"][selfId] = chrono::duration_cast<chrono::seconds>(chrono::system_clock::now().time_since_epoch()).count();
// msg to peer // msg to peer
string myId = devSn + ":0:0"; string myId = devSn + ":evmgr:0";
int minLen = std::min(body[1].size(), myId.size()); int minLen = std::min(body[1].size(), myId.size());
if(memcmp((void*)(body[1].data()), myId.data(), minLen) != 0) { if(memcmp((void*)(body[1].data()), myId.data(), minLen) != 0) {
// message to other peer // message to other peer
......
...@@ -235,7 +235,7 @@ private: ...@@ -235,7 +235,7 @@ private:
int ret = 0; int ret = 0;
vector<vector<uint8_t> >body; vector<vector<uint8_t> >body;
// since identity is auto set // since identity is auto set
body.push_back(str2body(mgrSn+":0:0")); body.push_back(str2body(mgrSn+":evmgr:0"));
body.push_back(str2body(EV_MSG_META_PING)); // blank meta body.push_back(str2body(EV_MSG_META_PING)); // blank meta
body.push_back(str2body(MSG_HELLO)); body.push_back(str2body(MSG_HELLO));
......
...@@ -132,7 +132,7 @@ private: ...@@ -132,7 +132,7 @@ private:
int ping() int ping()
{ {
int ret = 0; int ret = 0;
vector<vector<uint8_t> >body = {str2body(mgrSn + ":0:0"), str2body(EV_MSG_META_PING), str2body(MSG_HELLO)}; vector<vector<uint8_t> >body = {str2body(mgrSn + ":evmgr:0"), str2body(EV_MSG_META_PING), str2body(MSG_HELLO)};
ret = z_send_multiple(pDealer, body); ret = z_send_multiple(pDealer, body);
if(ret < 0) { if(ret < 0) {
......
...@@ -146,7 +146,7 @@ private: ...@@ -146,7 +146,7 @@ private:
{ {
// send hello to router // send hello to router
int ret = 0; int ret = 0;
vector<vector<uint8_t> >body = {str2body(mgrSn+":0:0"), str2body(EV_MSG_META_PING),str2body(MSG_HELLO)}; vector<vector<uint8_t> >body = {str2body(mgrSn+":evmgr:0"), str2body(EV_MSG_META_PING),str2body(MSG_HELLO)};
ret = z_send_multiple(pDealer, body); ret = z_send_multiple(pDealer, body);
if(ret < 0) { if(ret < 0) {
spdlog::error("evpusher {} {} failed to send multiple: {}", devSn, iid, zmq_strerror(zmq_errno())); spdlog::error("evpusher {} {} failed to send multiple: {}", devSn, iid, zmq_strerror(zmq_errno()));
......
...@@ -148,7 +148,7 @@ private: ...@@ -148,7 +148,7 @@ private:
} }
numSlices = 24 * days * 60 /minutes; numSlices = 24 * days * 60 /minutes;
spdlog::info("evslicer mkdir -p {}", selfId, urlOut); spdlog::info("evslicer mkdir -p {}", selfId, urlOut);
ret = system((string("mkdir -p ") + urlOut).c_str()); ret = system((string("mkdir -p ") + urlOut).c_str());
// if(ret == -1) { // if(ret == -1) {
...@@ -209,7 +209,7 @@ private: ...@@ -209,7 +209,7 @@ private:
// send hello to router // send hello to router
int ret = 0; int ret = 0;
/// identity is auto set /// identity is auto set
vector<vector<uint8_t> >body = {str2body(mgrSn+":0:0"), str2body(EV_MSG_META_PING), str2body(MSG_HELLO)}; vector<vector<uint8_t> >body = {str2body(mgrSn+":evmgr:0"), str2body(EV_MSG_META_PING), str2body(MSG_HELLO)};
ret = z_send_multiple(pDealer, body); ret = z_send_multiple(pDealer, body);
if(ret < 0) { if(ret < 0) {
spdlog::error("evslicer {} failed to send multiple: {}", selfId, zmq_strerror(zmq_errno())); spdlog::error("evslicer {} failed to send multiple: {}", selfId, zmq_strerror(zmq_errno()));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论