diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-11-03 12:32:56 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-11-03 12:32:56 -0700 |
commit | d97adc8789c2a38d0106c83b0f02522f9cf0d7dd (patch) | |
tree | 6cbb85d0f6e36e34f593a49c7d1f7c516e809a38 | |
parent | f5014d7d7179a77311f58f8bd0dced0ea83f2885 (diff) | |
download | infinitytier-d97adc8789c2a38d0106c83b0f02522f9cf0d7dd.tar.gz infinitytier-d97adc8789c2a38d0106c83b0f02522f9cf0d7dd.zip |
Preparing for test.
-rw-r--r-- | controller/EmbeddedNetworkController.cpp | 3 | ||||
-rw-r--r-- | controller/EmbeddedNetworkController.hpp | 2 | ||||
-rw-r--r-- | controller/RethinkDB.cpp | 18 | ||||
-rw-r--r-- | controller/RethinkDB.hpp | 1 |
4 files changed, 20 insertions, 4 deletions
diff --git a/controller/EmbeddedNetworkController.cpp b/controller/EmbeddedNetworkController.cpp index 31448cc3..e8e0f5be 100644 --- a/controller/EmbeddedNetworkController.cpp +++ b/controller/EmbeddedNetworkController.cpp @@ -1064,7 +1064,6 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpDELETE( void EmbeddedNetworkController::handleRemoteTrace(const ZT_RemoteTrace &rt) { - /* static volatile unsigned long idCounter = 0; char id[128],tmp[128]; std::string k,v; @@ -1107,10 +1106,10 @@ void EmbeddedNetworkController::handleRemoteTrace(const ZT_RemoteTrace &rt) d["objtype"] = "trace"; d["ts"] = now; d["nodeId"] = Utils::hex10(rt.origin,tmp); + _db.save(d); } catch ( ... ) { // drop invalid trace messages if an error occurs } - */ } void EmbeddedNetworkController::onNetworkUpdate(const uint64_t networkId) diff --git a/controller/EmbeddedNetworkController.hpp b/controller/EmbeddedNetworkController.hpp index 6a9bf8c3..f16ea121 100644 --- a/controller/EmbeddedNetworkController.hpp +++ b/controller/EmbeddedNetworkController.hpp @@ -19,8 +19,6 @@ #ifndef ZT_SQLITENETWORKCONTROLLER_HPP #define ZT_SQLITENETWORKCONTROLLER_HPP -#define ZT_CONTROLLER_USE_RETHINKDB - #include <stdint.h> #include <string> diff --git a/controller/RethinkDB.cpp b/controller/RethinkDB.cpp index 2d28dab2..ec6aae4e 100644 --- a/controller/RethinkDB.cpp +++ b/controller/RethinkDB.cpp @@ -164,6 +164,9 @@ RethinkDB::RethinkDB(EmbeddedNetworkController *const nc,const Address &myAddres const std::string tmp = (*config)["id"]; deleteId.append(tmp); table = "Member"; + } else if (objtype == "trace") { + record = *config; + table = "RemoteTrace"; } else { continue; } @@ -452,6 +455,21 @@ void RethinkDB::_memberChanged(nlohmann::json &old,nlohmann::json &member) _controller->onNetworkMemberUpdate(networkId,memberId); } + } else if (memberId) { + if (nw) { + std::lock_guard<std::mutex> l(nw->lock); + nw->members.erase(memberId); + } + if (networkId) { + std::lock_guard<std::mutex> l(_networks_l); + auto er = _networkByMember.equal_range(memberId); + for(auto i=er.first;i!=er.second;++i) { + if (i->second == networkId) { + _networkByMember.erase(i); + break; + } + } + } } if ((wasAuth)&&(!isAuth)&&(networkId)&&(memberId)) diff --git a/controller/RethinkDB.hpp b/controller/RethinkDB.hpp index 5708bd65..cb6c061e 100644 --- a/controller/RethinkDB.hpp +++ b/controller/RethinkDB.hpp @@ -132,6 +132,7 @@ private: std::thread _membersDbWatcher; std::unordered_map< uint64_t,std::shared_ptr<_Network> > _networks; + std::unordered_multimap< uint64_t,uint64_t > _networkByMember; mutable std::mutex _networks_l; BlockingQueue< std::unique_ptr<nlohmann::json> > _commitQueue; |