Commit c18305c4 authored by Pavel Vainerman's avatar Pavel Vainerman

(unet2): Добавил возможность делать "подсети"

(т.е. объединять узлы в группы). При помощи --unet-nodes-filter-field и --unet-nodes-filter-value
parent addaafd3
...@@ -32,6 +32,11 @@ sender(0) ...@@ -32,6 +32,11 @@ sender(0)
dlog[Debug::INFO] << myname << "(init): read filter-field='" << s_field dlog[Debug::INFO] << myname << "(init): read filter-field='" << s_field
<< "' filter-value='" << s_fvalue << "'" << endl; << "' filter-value='" << s_fvalue << "'" << endl;
const string n_field(conf->getArgParam("--unet-nodes-filter-field"));
const string n_fvalue(conf->getArgParam("--unet-nodes-filter-value"));
dlog[Debug::INFO] << myname << "(init): read nodes-filter-field='" << n_field
<< "' nodes-filter-value='" << n_fvalue << "'" << endl;
int recvTimeout = conf->getArgPInt("--unet-recv-timeout",it.getProp("recvTimeout"), 5000); int recvTimeout = conf->getArgPInt("--unet-recv-timeout",it.getProp("recvTimeout"), 5000);
int lostTimeout = conf->getArgPInt("--unet-lost-timeout",it.getProp("lostTimeout"), recvTimeout); int lostTimeout = conf->getArgPInt("--unet-lost-timeout",it.getProp("lostTimeout"), recvTimeout);
int recvpause = conf->getArgPInt("--unet-recvpause",it.getProp("recvpause"), 10); int recvpause = conf->getArgPInt("--unet-recvpause",it.getProp("recvpause"), 10);
...@@ -62,7 +67,11 @@ sender(0) ...@@ -62,7 +67,11 @@ sender(0)
continue; continue;
} }
// Если указано поле unet_ip непосредственно у узла - берём его // проверяем заданы ли фильтры для подсетей
if( !n_field.empty() && !check_filter(n_it,n_field,n_fvalue) )
continue;
// Если указано поле unet_broadcast_ip непосредственно у узла - берём его
// если указано общий broadcast ip для всех узлов - берём его // если указано общий broadcast ip для всех узлов - берём его
string h(""); string h("");
if( !default_ip.empty() ) if( !default_ip.empty() )
...@@ -93,7 +102,6 @@ sender(0) ...@@ -93,7 +102,6 @@ sender(0)
continue; continue;
} }
dlog[Debug::INFO] << myname << "(init): add UNetReceiver for " << h << ":" << p << endl; dlog[Debug::INFO] << myname << "(init): add UNetReceiver for " << h << ":" << p << endl;
if( checkExistUNetHost(h,p) ) if( checkExistUNetHost(h,p) )
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/*! \file /*! \file
* \author Pavel Vainerman * \author Pavel Vainerman
* \brief базовые типы библиотеки UniSet * \brief базовые типы и вспомогательные функции библиотеки UniSet
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#ifndef UniSetTypes_H_ #ifndef UniSetTypes_H_
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "UniSetTypes_i.hh" #include "UniSetTypes_i.hh"
#include "IOController_i.hh" #include "IOController_i.hh"
#include "Mutex.h" #include "Mutex.h"
#include "UniXML.h"
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
/*! Задержка в миллисекундах */ /*! Задержка в миллисекундах */
inline void msleep( unsigned int m ) { usleep(m*1000); } inline void msleep( unsigned int m ) { usleep(m*1000); }
...@@ -265,6 +266,11 @@ namespace UniSetTypes ...@@ -265,6 +266,11 @@ namespace UniSetTypes
// Если @node не указано, возвращается node=DefaultObjectId // Если @node не указано, возвращается node=DefaultObjectId
std::list<ParamSInfo> getSInfoList( std::string s, Configuration* conf=UniSetTypes::conf); std::list<ParamSInfo> getSInfoList( std::string s, Configuration* conf=UniSetTypes::conf);
bool is_digit( const std::string s ); bool is_digit( const std::string s );
// Проверка xml-узла на соответсвие <...f_prop="f_val">,
// если не задано f_val, то проверяется, что просто f_prop!=""
bool check_filter( UniXML_iterator& it, const std::string f_prop, const std::string f_val="" );
// -----------------------------------------------------------------------------
} }
#define atoi atoi##_Do_not_use_atoi_function_directly_Use_getIntProp90,_getArgInt_or_uni_atoi #define atoi atoi##_Do_not_use_atoi_function_directly_Use_getIntProp90,_getArgInt_or_uni_atoi
......
...@@ -336,3 +336,18 @@ using namespace UniSetTypes; ...@@ -336,3 +336,18 @@ using namespace UniSetTypes;
<< " sensibility=" << c.sensibility; << " sensibility=" << c.sensibility;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool UniSetTypes::check_filter( UniXML_iterator& it, const std::string f_prop, const std::string f_val )
{
if( f_prop.empty() )
return true;
// просто проверка на не пустой field
if( f_val.empty() && it.getProp(f_prop).empty() )
return false;
// просто проверка что field = value
if( !f_val.empty() && it.getProp(f_prop)!=f_val )
return false;
return true;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment