summaryrefslogtreecommitdiff
path: root/netconf-service
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-10-17 05:37:01 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-10-17 05:37:01 -0400
commit7e7e28f5f7d53df8f4897b243088d2f664651ae6 (patch)
treecfd11f8f81409e87c0a73ef6b8e422faa8ab2962 /netconf-service
parent46f868bd4fb2fd7b0816ded98974935aacddf5e6 (diff)
downloadinfinitytier-7e7e28f5f7d53df8f4897b243088d2f664651ae6.tar.gz
infinitytier-7e7e28f5f7d53df8f4897b243088d2f664651ae6.zip
Add support for pushing network config refresh hints from a MEMORY queue table. That ways it will be possible for network changes to take effect almost immediately across all active peers.
Diffstat (limited to 'netconf-service')
-rw-r--r--netconf-service/netconf.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/netconf-service/netconf.cpp b/netconf-service/netconf.cpp
index 2596a6f9..7c8bcb6e 100644
--- a/netconf-service/netconf.cpp
+++ b/netconf-service/netconf.cpp
@@ -158,6 +158,40 @@ int main(int argc,char **argv)
return -1;
}
+ // Check QNetworkConfigRefresh (MEMORY table) and push network
+ // config refreshes to queued peer/network pairs.
+ try {
+ Dictionary to;
+ {
+ Query q = dbCon->query();
+ q << "SELECT LOWER(HEX(Node_id)) AS Node_id,LOWER(HEX(Network_id)) AS Network_id FROM QNetworkConfigRefresh";
+ StoreQueryResult rs = q.store();
+ for(unsigned long i=0;i<rs.num_rows();++i) {
+ std::string &nwids = to[rs[i]["Node_id"]];
+ if (nwids.length())
+ nwids.push_back(',');
+ nwids.append(rs[i]["Network_id"]);
+ }
+ }
+
+ {
+ Query q = dbCon->query();
+ q << "DELETE FROM QNetworkConfigRefresh";
+ q.exec();
+ }
+
+ Dictionary response;
+ response["type"] = "netconf-push";
+ response["to"] = to.toString();
+ std::string respm = response.toString();
+ uint32_t respml = (uint32_t)htonl((uint32_t)respm.length());
+
+ stdoutWriteLock.lock();
+ write(STDOUT_FILENO,&respml,4);
+ write(STDOUT_FILENO,respm.data(),respm.length());
+ stdoutWriteLock.unlock();
+ } catch ( ... ) {}
+
try {
const std::string &reqType = request.get("type");
if (reqType == "netconf-request") { // NETWORK_CONFIG_REQUEST packet