MXS-2219 Replace for_each with regular for loops
In this context the former provides no advantage.
This commit is contained in:
		@ -230,10 +230,11 @@ void ClustrixMonitor::update_cluster_nodes(MXS_MONITORED_SERVER& ms)
 | 
				
			|||||||
            mxb_assert(mysql_field_count(ms.con) == 4);
 | 
					            mxb_assert(mysql_field_count(ms.con) == 4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            set<int> nids;
 | 
					            set<int> nids;
 | 
				
			||||||
            for_each(m_nodes.begin(), m_nodes.end(),
 | 
					            for (const auto& element : m_nodes)
 | 
				
			||||||
                     [&nids](const pair<int, ClustrixNode>& element) {
 | 
					            {
 | 
				
			||||||
                         nids.insert(element.first);
 | 
					                const ClustrixNode& node = element.second;
 | 
				
			||||||
                     });
 | 
					                nids.insert(node.id());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            MYSQL_ROW row;
 | 
					            MYSQL_ROW row;
 | 
				
			||||||
            while ((row = mysql_fetch_row(pResult)) != nullptr)
 | 
					            while ((row = mysql_fetch_row(pResult)) != nullptr)
 | 
				
			||||||
@ -292,7 +293,8 @@ void ClustrixMonitor::update_cluster_nodes(MXS_MONITORED_SERVER& ms)
 | 
				
			|||||||
                            const ClustrixMembership& membership = mit->second;
 | 
					                            const ClustrixMembership& membership = mit->second;
 | 
				
			||||||
                            int health_check_threshold = m_config.health_check_threshold();
 | 
					                            int health_check_threshold = m_config.health_check_threshold();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            ClustrixNode node(membership, ip, mysql_port, health_port, health_check_threshold, pServer);
 | 
					                            ClustrixNode node(membership, ip, mysql_port, health_port,
 | 
				
			||||||
 | 
					                                              health_check_threshold, pServer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            m_nodes.insert(make_pair(id, node));
 | 
					                            m_nodes.insert(make_pair(id, node));
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
@ -321,23 +323,23 @@ void ClustrixMonitor::update_cluster_nodes(MXS_MONITORED_SERVER& ms)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            mysql_free_result(pResult);
 | 
					            mysql_free_result(pResult);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    for_each(nids.begin(), nids.end(),
 | 
					            for (const auto nid : nids)
 | 
				
			||||||
		     [this](int nid) {
 | 
					            {
 | 
				
			||||||
		       auto it = m_nodes.find(nid);
 | 
					                auto it = m_nodes.find(nid);
 | 
				
			||||||
		       mxb_assert(it != m_nodes.end());
 | 
					                mxb_assert(it != m_nodes.end());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		       ClustrixNode& node = it->second;
 | 
					                ClustrixNode& node = it->second;
 | 
				
			||||||
                       node.set_running(false, ClustrixNode::APPROACH_OVERRIDE);
 | 
					                node.set_running(false, ClustrixNode::APPROACH_OVERRIDE);
 | 
				
			||||||
		     });
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            vector<string> health_urls;
 | 
					            vector<string> health_urls;
 | 
				
			||||||
            for_each(m_nodes.begin(), m_nodes.end(),
 | 
					            for (const auto& element : m_nodes)
 | 
				
			||||||
                     [&health_urls](const pair<int, ClustrixNode>& element) {
 | 
					            {
 | 
				
			||||||
                         const ClustrixNode& node = element.second;
 | 
					                const ClustrixNode& node = element.second;
 | 
				
			||||||
                         string url = "http://" + node.ip() + ":" + std::to_string(node.health_port());
 | 
					                string url = "http://" + node.ip() + ":" + std::to_string(node.health_port());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                         health_urls.push_back(url);
 | 
					                health_urls.push_back(url);
 | 
				
			||||||
                     });
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            m_health_urls.swap(health_urls);
 | 
					            m_health_urls.swap(health_urls);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -398,10 +400,11 @@ bool ClustrixMonitor::check_cluster_membership(MXS_MONITORED_SERVER& ms,
 | 
				
			|||||||
            mxb_assert(mysql_field_count(ms.con) == 4);
 | 
					            mxb_assert(mysql_field_count(ms.con) == 4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            set<int> nids;
 | 
					            set<int> nids;
 | 
				
			||||||
            for_each(m_nodes.begin(), m_nodes.end(),
 | 
					            for (const auto& element : m_nodes)
 | 
				
			||||||
                     [&nids](const pair<int, ClustrixNode>& element) {
 | 
					            {
 | 
				
			||||||
                         nids.insert(element.first);
 | 
					                const ClustrixNode& node = element.second;
 | 
				
			||||||
                     });
 | 
					                nids.insert(node.id());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            MYSQL_ROW row;
 | 
					            MYSQL_ROW row;
 | 
				
			||||||
            while ((row = mysql_fetch_row(pResult)) != nullptr)
 | 
					            while ((row = mysql_fetch_row(pResult)) != nullptr)
 | 
				
			||||||
@ -444,15 +447,15 @@ bool ClustrixMonitor::check_cluster_membership(MXS_MONITORED_SERVER& ms,
 | 
				
			|||||||
            mysql_free_result(pResult);
 | 
					            mysql_free_result(pResult);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Deactivate all servers that are no longer members.
 | 
					            // Deactivate all servers that are no longer members.
 | 
				
			||||||
	    for_each(nids.begin(), nids.end(),
 | 
					            for (const auto nid : nids)
 | 
				
			||||||
		     [this](int nid) {
 | 
					            {
 | 
				
			||||||
		       auto it = m_nodes.find(nid);
 | 
					                auto it = m_nodes.find(nid);
 | 
				
			||||||
		       mxb_assert(it != m_nodes.end());
 | 
					                mxb_assert(it != m_nodes.end());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		       ClustrixNode& node = it->second;
 | 
					                ClustrixNode& node = it->second;
 | 
				
			||||||
		       node.deactivate_server();
 | 
					                node.deactivate_server();
 | 
				
			||||||
		       m_nodes.erase(it);
 | 
					                m_nodes.erase(it);
 | 
				
			||||||
		     });
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            rv = true;
 | 
					            rv = true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user