Commit 72d78171 authored by Pavel Vainerman's avatar Pavel Vainerman Committed by Pavel Vainerman

[unet-multicast]: configure refactoring

parent 26347ffb
...@@ -299,7 +299,14 @@ std::unique_ptr<MulticastSendTransport> MulticastSendTransport::createFromXml( U ...@@ -299,7 +299,14 @@ std::unique_ptr<MulticastSendTransport> MulticastSendTransport::createFromXml( U
if( numChan > 0 ) if( numChan > 0 )
ipField << numChan; ipField << numChan;
const string ip = it.getProp2(ipField.str(), "0.0.0.0"); const string ip = it.getProp(ipField.str());
if( ip.empty() )
{
ostringstream err;
err << "(MulticastSendTransport): Undefined " << ipField.str() << " for " << it.getProp("name");
throw SystemError(err.str());
}
int ttl = it.getPIntProp("unet_multicast_ttl", 1); int ttl = it.getPIntProp("unet_multicast_ttl", 1);
return unisetstd::make_unique<MulticastSendTransport>(ip, p, h, p, ttl); return unisetstd::make_unique<MulticastSendTransport>(ip, p, h, p, ttl);
......
...@@ -66,17 +66,6 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const ...@@ -66,17 +66,6 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
logserv_port = conf->getArgPInt("--" + prefix + "-logserver-port", it.getProp("logserverPort"), getId()); logserv_port = conf->getArgPInt("--" + prefix + "-logserver-port", it.getProp("logserverPort"), getId());
} }
// определяем фильтр
s_field = conf->getArgParam("--" + prefix + "-filter-field");
s_fvalue = conf->getArgParam("--" + prefix + "-filter-value");
unetinfo << myname << "(init): read filter-field='" << s_field
<< "' filter-value='" << s_fvalue << "'" << endl;
const string n_field(conf->getArgParam("--" + prefix + "-nodes-filter-field"));
const string n_fvalue(conf->getArgParam("--" + prefix + "-nodes-filter-value"));
unetinfo << myname << "(init): read nodes-filter-field='" << n_field
<< "' nodes-filter-value='" << n_fvalue << "'" << endl;
int recvTimeout = conf->getArgPInt("--" + prefix + "-recv-timeout", it.getProp("recvTimeout"), 5000); int recvTimeout = conf->getArgPInt("--" + prefix + "-recv-timeout", it.getProp("recvTimeout"), 5000);
int prepareTime = conf->getArgPInt("--" + prefix + "-prepare-time", it.getProp("prepareTime"), 2000); int prepareTime = conf->getArgPInt("--" + prefix + "-prepare-time", it.getProp("prepareTime"), 2000);
int evrunTimeout = conf->getArgPInt("--" + prefix + "-evrun-timeout", it.getProp("evrunTimeout"), 60000); int evrunTimeout = conf->getArgPInt("--" + prefix + "-evrun-timeout", it.getProp("evrunTimeout"), 60000);
...@@ -124,7 +113,18 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const ...@@ -124,7 +113,18 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
UniXML::iterator n_it(nodes); UniXML::iterator n_it(nodes);
const string unet_transport = conf->getArg2Param("--" + prefix + "-transport", n_it.getProp("unet_transport"), "udp"); // определяем фильтр
s_field = conf->getArg2Param("--" + prefix + "-filter-field", n_it.getProp("filter_field"));
s_fvalue = conf->getArg2Param("--" + prefix + "-filter-value", n_it.getProp("filter_value"));
unetinfo << myname << "(init): read filter-field='" << s_field
<< "' filter-value='" << s_fvalue << "'" << endl;
const string n_field = conf->getArg2Param("--" + prefix + "-nodes-filter-field", n_it.getProp("nodes_filter_field"));
const string n_fvalue = conf->getArg2Param("--" + prefix + "-nodes-filter-value", n_it.getProp("nodes_filter_value"));
unetinfo << myname << "(init): read nodes-filter-field='" << n_field
<< "' nodes-filter-value='" << n_fvalue << "'" << endl;
const string unet_transport = conf->getArg2Param("--" + prefix + "-transport", n_it.getProp("unet_transport"), "broadcast");
if( unet_transport == "multicast" ) if( unet_transport == "multicast" )
initMulticastTransport(n_it, n_field, n_fvalue, prefix); initMulticastTransport(n_it, n_field, n_fvalue, prefix);
...@@ -847,7 +847,7 @@ void UNetExchange::initUDPTransport( UniXML::iterator n_it, ...@@ -847,7 +847,7 @@ void UNetExchange::initUDPTransport( UniXML::iterator n_it,
if( n == conf->getLocalNodeName() ) if( n == conf->getLocalNodeName() )
{ {
if( no_sender ) if( no_sender || n_it.getIntProp("nosedner") > 0 )
{ {
unetinfo << myname << "(init): sender OFF for this node...(" unetinfo << myname << "(init): sender OFF for this node...("
<< n_it.getProp("name") << ")" << endl; << n_it.getProp("name") << ")" << endl;
...@@ -1121,7 +1121,7 @@ void UNetExchange::initMulticastTransport( UniXML::iterator n_it, ...@@ -1121,7 +1121,7 @@ void UNetExchange::initMulticastTransport( UniXML::iterator n_it,
continue; continue;
} }
if( no_sender ) if( no_sender || n_it.getIntProp("nosedner") > 0 )
{ {
unetinfo << myname << "(init): " << n_it.getProp("name") << " sender DISABLED." << endl; unetinfo << myname << "(init): " << n_it.getProp("name") << " sender DISABLED." << endl;
break; break;
......
...@@ -62,10 +62,10 @@ namespace uniset ...@@ -62,10 +62,10 @@ namespace uniset
или каждый на своём потоке. Это определяется параметром \b unet_update_strategy. или каждый на своём потоке. Это определяется параметром \b unet_update_strategy.
В текущей версии поддерживается два протокола для обмена udp и multicast. Какой использовать протокол В текущей версии поддерживается два протокола для обмена udp и multicast. Какой использовать протокол
определяется в настроечной секции параметром \b unet_transport="udp" или \b unet_transport="multicast". определяется в настроечной секции параметром \b unet_transport="broadcast" или \b unet_transport="multicast".
По умолчанию "udp". По умолчанию "broadcast".
\code \code
<UNetExchange name=".." unet_transport="udp" /> <UNetExchange name=".." unet_transport="broadcast" />
\endcode \endcode
В зависимости от заданного протокола, будут использованы те или иные настройки. В зависимости от заданного протокола, будут использованы те или иные настройки.
...@@ -100,6 +100,10 @@ namespace uniset ...@@ -100,6 +100,10 @@ namespace uniset
\note Имеется возможность задавать отдельную настроечную секцию для "списка узлов" при помощи параметра \note Имеется возможность задавать отдельную настроечную секцию для "списка узлов" при помощи параметра
--prefix-nodes-confnode name. По умолчанию настройка ведётся по секции <nodes> --prefix-nodes-confnode name. По умолчанию настройка ведётся по секции <nodes>
Чтобы отключить запуск "sender", можно указать \b nosender="1" в \b <item> конкретного узла
или непосредственно в настройках \b <UNetExchange nosender="1"...>
\section pgUNetUDP_ConfMulticast Пример конфигурирования (Multicast) \section pgUNetUDP_ConfMulticast Пример конфигурирования (Multicast)
По умолчанию при считывании используется \b unet_multicast_ip и \b id узла - в качестве порта. По умолчанию при считывании используется \b unet_multicast_ip и \b id узла - в качестве порта.
Но можно переопределиять эти параметры, при помощи указания \b unet_multicast_port и/или \b unet_multicast_ip, Но можно переопределиять эти параметры, при помощи указания \b unet_multicast_port и/или \b unet_multicast_ip,
...@@ -115,6 +119,9 @@ namespace uniset ...@@ -115,6 +119,9 @@ namespace uniset
В данной реализации поддерживается работа в два канала. Соответствующие настройки для второго канала имеют индекс "2". В данной реализации поддерживается работа в два канала. Соответствующие настройки для второго канала имеют индекс "2".
unet_multicast_ip2, unet_multicast_port2, unet_multicast_iface2 unet_multicast_ip2, unet_multicast_port2, unet_multicast_iface2
Чтобы отключить запуск "sender", можно указать \b nosender="1" в \b <item> конкретного узла
или непосредственно в настройках \b <UNetExchange nosender="1"...>
\code \code
<nodes port="2809" unet_broadcast_ip="192.168.56.255"> <nodes port="2809" unet_broadcast_ip="192.168.56.255">
<item ip="127.0.0.1" name="LocalhostNode" textname="Локальный узел" unet_ignore="10"> <item ip="127.0.0.1" name="LocalhostNode" textname="Локальный узел" unet_ignore="10">
...@@ -124,14 +131,18 @@ namespace uniset ...@@ -124,14 +131,18 @@ namespace uniset
</item> </item>
<item id="3001" ip="192.168.56.10" name="Node1" textname="Node1" unet_update_strategy="evloop" <item id="3001" ip="192.168.56.10" name="Node1" textname="Node1" unet_update_strategy="evloop"
unet_multicast_ip="224.0.0.1" unet_multicast_ip="224.0.0.1"
unet_multicast_sender_ip="192.168.1.1"
unet_multicast_port2="3031" unet_multicast_port2="3031"
unet_multicast_ip2="225.0.0.1"> unet_multicast_ip2="225.0.0.1"
unet_multicast_sender_ip2="192.168.2.1">
... ...
</item> </item>
<item id="3002" ip="192.168.56.11" name="Node2" textname="Node2"> <item id="3002" ip="192.168.56.11" name="Node2" textname="Node2">
unet_multicast_ip="224.0.0.2" unet_multicast_ip="224.0.0.2"
unet_multicast_sender_ip="192.168.1.2"
unet_multicast_port2="3032" unet_multicast_port2="3032"
unet_multicast_ip2="225.0.0.2"> unet_multicast_ip2="225.0.0.2"
unet_multicast_sender_ip2="192.168.2.2">
... ...
</item> </item>
</nodes> </nodes>
......
...@@ -35,17 +35,23 @@ ...@@ -35,17 +35,23 @@
<nodes port="2809" unet_broadcast_ip="127.255.255.255" unet_broadcast_ip2="badip"> <nodes port="2809" unet_broadcast_ip="127.255.255.255" unet_broadcast_ip2="badip">
<item id="3000" ip="127.0.0.1" name="localhost" textname="Локальный узел" unet_ignore="0" unet_port="3000" <item id="3000" ip="127.0.0.1" name="localhost" textname="Локальный узел" unet_ignore="0" unet_port="3000"
unet_multicast_ip="224.0.0.1" unet_multicast_ip="224.0.0.1"
unet_multicast_sender_ip="0.0.0.0"
unet_multicast_ip2="225.0.0.1" unet_multicast_ip2="225.0.0.1"
unet_multicast_port2="3030"/> unet_multicast_port2="3030"
unet_multicast_sender_ip2="0.0.0.0"/>
<item id="3001" ip="127.0.0.1" name="localhost1" textname="Локальный узел" unet_ignore="1" unet_port="3001"/> <item id="3001" ip="127.0.0.1" name="localhost1" textname="Локальный узел" unet_ignore="1" unet_port="3001"/>
<item id="3002" ip="192.168.56.10" name="Node1" textname="Node1" unet_ignore="0" unet_respond_id="Node1_Not_Respond_S" unet_respond_invert="1" unet_channelswitchcount_id="Node1_ChannelSwitchCount_AS" <item id="3002" ip="192.168.56.10" name="Node1" textname="Node1" unet_ignore="0" unet_respond_id="Node1_Not_Respond_S" unet_respond_invert="1" unet_channelswitchcount_id="Node1_ChannelSwitchCount_AS"
unet_multicast_ip="224.0.0.2" unet_multicast_ip="224.0.0.2"
unet_multicast_sender_ip="0.0.0.0"
unet_multicast_ip2="225.0.0.2" unet_multicast_ip2="225.0.0.2"
unet_multicast_port2="3032"/> unet_multicast_port2="3032"
unet_multicast_sender_ip2="0.0.0.0"/>
<item id="3003" ip="192.168.56.11" name="Node2" textname="Node2" unet_ignore="0" unet_respond_id="Node2_Respond_S" unet_lostpackets_id="Node2_LostPackets_AS" unet_numchannel_id="Node2_NumChannel_AS" <item id="3003" ip="192.168.56.11" name="Node2" textname="Node2" unet_ignore="0" unet_respond_id="Node2_Respond_S" unet_lostpackets_id="Node2_LostPackets_AS" unet_numchannel_id="Node2_NumChannel_AS"
unet_multicast_ip="224.0.0.3" unet_multicast_ip="224.0.0.3"
unet_multicast_sender_ip="0.0.0.0"
unet_multicast_ip2="225.0.0.3" unet_multicast_ip2="225.0.0.3"
unet_multicast_port2="3033"/> unet_multicast_port2="3033"
unet_multicast_sender_ip2="0.0.0.0"/>
</nodes> </nodes>
<!-- ************************ Датчики ********************** --> <!-- ************************ Датчики ********************** -->
<sensors name="Sensors"> <sensors name="Sensors">
......
...@@ -362,7 +362,6 @@ int main(int argc, char* argv[]) ...@@ -362,7 +362,6 @@ int main(int argc, char* argv[])
if( addr.isMulticast() && groups.empty() ) if( addr.isMulticast() && groups.empty() )
groups.push_back(addr); groups.push_back(addr);
if( groups.empty() ) if( groups.empty() )
{ {
cerr << "(send): Unknown multicast group address for send ..." << endl; cerr << "(send): Unknown multicast group address for send ..." << endl;
......
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