Commit 6bd9f0ec authored by Pavel Vainerman's avatar Pavel Vainerman

Сделал имя NameService уникальным для Configure

parent 7a1c5189
#!/bin/sh #!/bin/sh
uniset-start.sh -g ./uniset-plogicproc --schema schema.xml \ uniset-start.sh -f ./uniset-plogicproc --schema schema.xml \
--smemory-id SharedMemory --name LProcessor \ --smemory-id SharedMemory --name LProcessor \
--confile test.xml --unideb-add-levels info,crit,warn,level9,system --confile test.xml --unideb-add-levels info,crit,warn,level9,system
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include <string> #include <string>
#include <omniORB4/internal/initRefs.h>
#include "Configuration.h" #include "Configuration.h"
#include "Exceptions.h" #include "Exceptions.h"
...@@ -47,8 +46,8 @@ using namespace std; ...@@ -47,8 +46,8 @@ using namespace std;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
static const string UniSetDefaultPort = "2809"; static const string UniSetDefaultPort = "2809";
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
static ostream& print_help( ostream& os, int width, const string& cmd, static ostream& print_help( ostream& os, int width, const string cmd,
const string& help, const string& tab="" ) const string help, const string tab="" )
{ {
// чтобы не менчять параметры основного потока // чтобы не менчять параметры основного потока
// создаём свой stream... // создаём свой stream...
...@@ -80,7 +79,7 @@ ostream& UniSetTypes::Configuration::help(ostream& os) ...@@ -80,7 +79,7 @@ ostream& UniSetTypes::Configuration::help(ostream& os)
namespace UniSetTypes namespace UniSetTypes
{ {
DebugStream unideb; DebugStream unideb;
Configuration *conf = 0; Configuration *conf;
Configuration::Configuration(): Configuration::Configuration():
mi(NULL), mi(NULL),
...@@ -93,7 +92,7 @@ Configuration::Configuration(): ...@@ -93,7 +92,7 @@ Configuration::Configuration():
localNode(UniSetTypes::DefaultObjectId), localNode(UniSetTypes::DefaultObjectId),
localNodeName(""), localNodeName(""),
fileConfName(""), fileConfName(""),
heartbeat_msec(5000) heartbeat_msec(10000)
{ {
// unideb[Debug::CRIT] << " configuration FAILED!!!!!!!!!!!!!!!!!" << endl; // unideb[Debug::CRIT] << " configuration FAILED!!!!!!!!!!!!!!!!!" << endl;
// throw Exception(); // throw Exception();
...@@ -199,9 +198,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -199,9 +198,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
getcwd(curdir,FILENAME_MAX); getcwd(curdir,FILENAME_MAX);
rootDir = string(curdir) + "/"; rootDir = string(curdir) + "/";
/*! \todo Надо избавляться от глобального conf (!) */
if( !UniSetTypes::conf )
UniSetTypes::conf = this; UniSetTypes::conf = this;
{ {
...@@ -228,6 +224,10 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -228,6 +224,10 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
throw; throw;
} }
// default value
heartbeat_msec = 5000;
// cerr << "*************** initConfiguration: xmlOpen: " << pt.getCurrent() << " msec " << endl; // cerr << "*************** initConfiguration: xmlOpen: " << pt.getCurrent() << " msec " << endl;
// pt.reset(); // pt.reset();
...@@ -252,7 +252,7 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -252,7 +252,7 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
catch(Exception& ex ) catch(Exception& ex )
{ {
unideb[Debug::CRIT] << "(Configuration:init): INIT FAILED! from " << fileConfName << endl; unideb[Debug::CRIT] << "(Configuration:init): INIT FAILED! from " << fileConfName << endl;
throw; throw ex;
} }
} }
} }
...@@ -274,6 +274,9 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -274,6 +274,9 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
// Настраиваем отладочные логи // Настраиваем отладочные логи
initDebug(unideb, "UniSetDebug"); initDebug(unideb, "UniSetDebug");
// cerr << "*************** initConfiguration: oind: " << pt.getCurrent() << " msec " << endl;
// pt.reset();
// default init... // default init...
transientIOR = false; transientIOR = false;
localIOR = false; localIOR = false;
...@@ -284,14 +287,20 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -284,14 +287,20 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
initParameters(); initParameters();
// help
// if( !getArgParam("--help").empty() )
// help(cout);
initRepSections(); initRepSections();
// localIOR // localIOR
// localIOR = false; // ??. initParameters()
int lior = getArgInt("--localIOR"); int lior = getArgInt("--localIOR");
if( lior ) if( lior )
localIOR = lior; localIOR = lior;
// transientIOR // transientIOR
// transientIOR = false; // ??. initParameters()
int tior = getArgInt("--transientIOR"); int tior = getArgInt("--transientIOR");
if( tior ) if( tior )
transientIOR = tior; transientIOR = tior;
...@@ -299,6 +308,9 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -299,6 +308,9 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
if( imagesDir[0]!='/' && imagesDir[0]!='.' ) if( imagesDir[0]!='/' && imagesDir[0]!='.' )
imagesDir = dataDir + imagesDir + "/"; imagesDir = dataDir + imagesDir + "/";
// cerr << "*************** initConfiguration: parameters...: " << pt.getCurrent() << " msec " << endl;
// pt.reset();
// считываем список узлов // считываем список узлов
createNodesList(); createNodesList();
...@@ -323,20 +335,13 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -323,20 +335,13 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
string name(oind->getRealNodeName(it->id)); string name(oind->getRealNodeName(it->id));
ostringstream param; ostringstream param;
param << this << name; param << this << name << "=corbaname::" << it->host << ":" << it->port;
name = param.str();
param << "=corbaname::" << it->host << ":" << it->port;
new_argv[i+1] = strdup(param.str().c_str()); new_argv[i+1] = strdup(param.str().c_str());
if( unideb.debugging(Debug::INFO) ) if( unideb.debugging(Debug::INFO) )
unideb[Debug::INFO] << "(Configuration): внесли параметр " << param.str() << endl; unideb[Debug::INFO] << "(Configuration): внесли параметр " << param.str() << endl;
i+=2; i+=2;
ostringstream uri;
uri << "corbaname::" << it->host << ":" << it->port;
if( !omni::omniInitialReferences::setFromArgs(name.c_str(), uri.str().c_str()) )
cerr << "**********************!!!! FAILED ADD name=" << name << " uri=" << uri.str() << endl;
assert( i < _argc ); assert( i < _argc );
} }
...@@ -364,15 +369,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -364,15 +369,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
new_argv[i+1] = strdup(param.str().c_str()); new_argv[i+1] = strdup(param.str().c_str());
if( unideb.debugging(Debug::INFO) ) if( unideb.debugging(Debug::INFO) )
unideb[Debug::INFO] << "(Configuration): внесли параметр " << param.str() << endl; unideb[Debug::INFO] << "(Configuration): внесли параметр " << param.str() << endl;
{
ostringstream ns_name;
ns_name << this << "NameService";
ostringstream uri;
uri << "corbaname::" << getProp(nsnode,"host") << ":" << defPort;
if( !omni::omniInitialReferences::setFromArgs(ns_name.str().c_str(), uri.str().c_str()) )
cerr << "**********************!!!! FAILED ADD name=" <<ns_name << " uri=" << uri.str() << endl;
}
} }
_argv = new_argv; _argv = new_argv;
...@@ -580,16 +576,10 @@ void Configuration::initParameters() ...@@ -580,16 +576,10 @@ void Configuration::initParameters()
if( confDir.empty() ) if( confDir.empty() )
confDir = getRootDir(); confDir = getRootDir();
} }
} else if( name == "HeartBeatTime" )
// Heartbeat init...
xmlNode* cnode = conf->getNode("HeartBeatTime");
if( cnode )
{ {
UniXML_iterator hit(cnode); heartbeat_msec = it.getIntProp("name");
heartbeat_msec = hit.getIntProp("msec"); }
if( heartbeat_msec <= 0 )
heartbeat_msec = 5000;
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -772,7 +762,7 @@ void Configuration::createNodesList() ...@@ -772,7 +762,7 @@ void Configuration::createNodesList()
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void Configuration::initNode( UniSetTypes::NodeInfo& ninfo, UniXML_iterator& it ) void Configuration::initNode( UniSetTypes::NodeInfo& ninfo, UniXML_iterator& it )
{ {
if( ninfo.id == getLocalNode() ) if( ninfo.id == conf->getLocalNode() )
ninfo.connected = true; ninfo.connected = true;
else else
ninfo.connected = false; ninfo.connected = false;
...@@ -797,7 +787,7 @@ xmlNode* Configuration::initDebug( DebugStream& deb, const string& _debname ) ...@@ -797,7 +787,7 @@ xmlNode* Configuration::initDebug( DebugStream& deb, const string& _debname )
string debname(_debname); string debname(_debname);
xmlNode* dnode = getNode(_debname); xmlNode* dnode = conf->getNode(_debname);
if( dnode == NULL ) if( dnode == NULL )
deb << "(Configuration)(initDebug): WARNING! Not found conf. section for log '" << _debname << "'" << endl; deb << "(Configuration)(initDebug): WARNING! Not found conf. section for log '" << _debname << "'" << endl;
else else
...@@ -953,7 +943,7 @@ ObjectId Configuration::getSensorID( const std::string name ) ...@@ -953,7 +943,7 @@ ObjectId Configuration::getSensorID( const std::string name )
if( name.empty() ) if( name.empty() )
return DefaultObjectId; return DefaultObjectId;
return oind->getIdByName(getSensorsSection()+"/"+name); return oind->getIdByName(conf->getSensorsSection()+"/"+name);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ObjectId Configuration::getControllerID( const std::string name ) ObjectId Configuration::getControllerID( const std::string name )
...@@ -961,7 +951,7 @@ ObjectId Configuration::getControllerID( const std::string name ) ...@@ -961,7 +951,7 @@ ObjectId Configuration::getControllerID( const std::string name )
if( name.empty() ) if( name.empty() )
return DefaultObjectId; return DefaultObjectId;
return oind->getIdByName(getControllersSection()+"/"+name); return oind->getIdByName(conf->getControllersSection()+"/"+name);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ObjectId Configuration::getObjectID( const std::string name ) ObjectId Configuration::getObjectID( const std::string name )
...@@ -969,7 +959,7 @@ ObjectId Configuration::getObjectID( const std::string name ) ...@@ -969,7 +959,7 @@ ObjectId Configuration::getObjectID( const std::string name )
if( name.empty() ) if( name.empty() )
return DefaultObjectId; return DefaultObjectId;
return oind->getIdByName(getObjectsSection()+"/"+name); return oind->getIdByName(conf->getObjectsSection()+"/"+name);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ObjectId Configuration::getServiceID( const std::string name ) ObjectId Configuration::getServiceID( const std::string name )
...@@ -977,7 +967,7 @@ ObjectId Configuration::getServiceID( const std::string name ) ...@@ -977,7 +967,7 @@ ObjectId Configuration::getServiceID( const std::string name )
if( name.empty() ) if( name.empty() )
return DefaultObjectId; return DefaultObjectId;
return oind->getIdByName(getServicesSection()+"/"+name); return oind->getIdByName(conf->getServicesSection()+"/"+name);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
UniSetTypes::ObjectId Configuration::getNodeID( const std::string name, std::string alias ) UniSetTypes::ObjectId Configuration::getNodeID( const std::string name, std::string alias )
...@@ -1086,7 +1076,7 @@ UniversalIO::IOTypes Configuration::getIOType( const std::string name ) ...@@ -1086,7 +1076,7 @@ UniversalIO::IOTypes Configuration::getIOType( const std::string name )
return UniversalIO::UnknownIOType; return UniversalIO::UnknownIOType;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void uniset_init( int argc, const char* const* argv, const std::string& xmlfile ) void uniset_init( int argc, const char* const* argv, const std::string xmlfile )
{ {
string confile = UniSetTypes::getArgParam( "--confile", argc, argv, xmlfile ); string confile = UniSetTypes::getArgParam( "--confile", argc, argv, xmlfile );
UniSetTypes::conf = new Configuration(argc, argv, confile); UniSetTypes::conf = new Configuration(argc, argv, confile);
......
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