|
|
|
|
@ -2230,79 +2230,6 @@ SQLite3_result * MySQL_HostGroups_Manager::dump_table_mysql(const string& name)
|
|
|
|
|
return resultset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
/**
|
|
|
|
|
* @brief Create a new MySQL host group container.
|
|
|
|
|
*
|
|
|
|
|
* This function creates a new instance of the MySQL host group container (`MyHGC`) with
|
|
|
|
|
* the specified host group ID and returns a pointer to it.
|
|
|
|
|
*
|
|
|
|
|
* @param _hid The host group ID for the new container.
|
|
|
|
|
* @return A pointer to the newly created `MyHGC` instance.
|
|
|
|
|
*/
|
|
|
|
|
MyHGC * MySQL_HostGroups_Manager::MyHGC_create(unsigned int _hid) {
|
|
|
|
|
MyHGC *myhgc=new MyHGC(_hid);
|
|
|
|
|
return myhgc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Find a MySQL host group container by host group ID.
|
|
|
|
|
*
|
|
|
|
|
* This function searches for a MySQL host group container with the specified host group ID
|
|
|
|
|
* in the list of host groups. If found, it returns a pointer to the container; otherwise,
|
|
|
|
|
* it returns a null pointer.
|
|
|
|
|
*
|
|
|
|
|
* @param _hid The host group ID to search for.
|
|
|
|
|
* @return A pointer to the found `MyHGC` instance if found; otherwise, a null pointer.
|
|
|
|
|
*/
|
|
|
|
|
MyHGC * MySQL_HostGroups_Manager::MyHGC_find(unsigned int _hid) {
|
|
|
|
|
if (MyHostGroups->len < 100) {
|
|
|
|
|
// for few HGs, we use the legacy search
|
|
|
|
|
for (unsigned int i=0; i<MyHostGroups->len; i++) {
|
|
|
|
|
MyHGC *myhgc=(MyHGC *)MyHostGroups->index(i);
|
|
|
|
|
if (myhgc->hid==_hid) {
|
|
|
|
|
return myhgc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// for a large number of HGs, we use the unordered_map
|
|
|
|
|
// this search is slower for a small number of HGs, therefore we use
|
|
|
|
|
// it only for large number of HGs
|
|
|
|
|
std::unordered_map<unsigned int, MyHGC *>::const_iterator it = MyHostGroups_map.find(_hid);
|
|
|
|
|
if (it != MyHostGroups_map.end()) {
|
|
|
|
|
MyHGC *myhgc = it->second;
|
|
|
|
|
return myhgc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* @brief Lookup or create a MySQL host group container by host group ID.
|
|
|
|
|
*
|
|
|
|
|
* This function looks up a MySQL host group container with the specified host group ID. If
|
|
|
|
|
* found, it returns a pointer to the existing container; otherwise, it creates a new container
|
|
|
|
|
* with the specified host group ID, adds it to the list of host groups, and returns a pointer
|
|
|
|
|
* to it.
|
|
|
|
|
*
|
|
|
|
|
* @param _hid The host group ID to lookup or create.
|
|
|
|
|
* @return A pointer to the found or newly created `MyHGC` instance.
|
|
|
|
|
* @note The function assertion fails if a newly created container is not found.
|
|
|
|
|
*/
|
|
|
|
|
MyHGC * MySQL_HostGroups_Manager::MyHGC_lookup(unsigned int _hid) {
|
|
|
|
|
MyHGC *myhgc=NULL;
|
|
|
|
|
myhgc=MyHGC_find(_hid);
|
|
|
|
|
if (myhgc==NULL) {
|
|
|
|
|
myhgc=MyHGC_create(_hid);
|
|
|
|
|
} else {
|
|
|
|
|
return myhgc;
|
|
|
|
|
}
|
|
|
|
|
assert(myhgc);
|
|
|
|
|
MyHostGroups->add(myhgc);
|
|
|
|
|
MyHostGroups_map.emplace(_hid,myhgc);
|
|
|
|
|
return myhgc;
|
|
|
|
|
}
|
|
|
|
|
#endif // 0
|
|
|
|
|
|
|
|
|
|
void MySQL_HostGroups_Manager::increase_reset_counter() {
|
|
|
|
|
wrlock();
|
|
|
|
|
status.myconnpoll_reset++;
|
|
|
|
|
|