Commit 23520fb8 authored by Pavel Vainerman's avatar Pavel Vainerman

(UObject): добавлены попытки регистрации и активации объекта

parent f66ca1fe
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
Name: libuniset2 Name: libuniset2
Version: 2.6 Version: 2.6
Release: alt8 Release: alt9
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
License: LGPL License: LGPL
...@@ -507,6 +507,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -507,6 +507,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# history of current unpublished changes # history of current unpublished changes
%changelog %changelog
* Fri Dec 16 2016 Pavel Vainerman <pv@altlinux.ru> 2.6-alt9
- UObject: added attempts to activate the object
* Wed Dec 14 2016 Pavel Vainerman <pv@altlinux.ru> 2.6-alt8 * Wed Dec 14 2016 Pavel Vainerman <pv@altlinux.ru> 2.6-alt8
- SM: terminate if read dump (configuration) failed - SM: terminate if read dump (configuration) failed
......
...@@ -221,9 +221,9 @@ namespace uniset ...@@ -221,9 +221,9 @@ namespace uniset
//! Непосредственная активизация объекта //! Непосредственная активизация объекта
bool activate(); bool activate();
/* регистрация в репозитории объектов */ /* регистрация в репозитории объектов */
void registered(); void registration();
/* удаление ссылки из репозитория объектов */ /* удаление ссылки из репозитория объектов */
void unregister(); void unregistration();
void initObject(); void initObject();
......
...@@ -851,7 +851,7 @@ namespace uniset ...@@ -851,7 +851,7 @@ namespace uniset
string nodeName(s.str()); string nodeName(s.str());
string bname(nodeName); // сохраняем базовое название string bname(nodeName); // сохраняем базовое название
for(unsigned int curNet = 1; curNet <= uconf->getCountOfNet(); curNet++) for( size_t curNet = 1; curNet <= uconf->getCountOfNet(); curNet++)
{ {
try try
{ {
......
...@@ -224,13 +224,13 @@ namespace uniset ...@@ -224,13 +224,13 @@ namespace uniset
return receiveMessage(); return receiveMessage();
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void UniSetObject::registered() void UniSetObject::registration()
{ {
ulogrep << myname << ": registration..." << endl; ulogrep << myname << ": registration..." << endl;
if( myid == uniset::DefaultObjectId ) if( myid == uniset::DefaultObjectId )
{ {
ulogrep << myname << "(registered): Don`t registration. myid=DefaultObjectId \n"; ulogrep << myname << "(registration): Don`t registration. myid=DefaultObjectId \n";
return; return;
} }
...@@ -238,7 +238,7 @@ namespace uniset ...@@ -238,7 +238,7 @@ namespace uniset
if( !m ) if( !m )
{ {
uwarn << myname << "(registered): unknown my manager" << endl; uwarn << myname << "(registration): unknown my manager" << endl;
string err(myname + ": unknown my manager"); string err(myname + ": unknown my manager");
throw ORepFailed(err); throw ORepFailed(err);
} }
...@@ -248,18 +248,20 @@ namespace uniset ...@@ -248,18 +248,20 @@ namespace uniset
if( !oref ) if( !oref )
{ {
ucrit << myname << "(registered): oref is NULL!..." << endl; uwarn << myname << "(registration): oref is NULL!..." << endl;
return; return;
} }
} }
try auto conf = uniset_conf();
{ regOK = false;
for( unsigned int i = 0; i < 2; i++ )
for( size_t i = 0; i < conf->getRepeatCount(); i++ )
{ {
try try
{ {
ui->registered(myid, getRef(), true); ui->registered(myid, getRef(), true);
regOK = true;
break; break;
} }
catch( ObjectNameAlready& al ) catch( ObjectNameAlready& al )
...@@ -274,29 +276,30 @@ namespace uniset ...@@ -274,29 +276,30 @@ namespace uniset
если заменяемый объект "жив" и завершит свою работу, то он может почистить за собой ссылку и это тогда наш(новый) если заменяемый объект "жив" и завершит свою работу, то он может почистить за собой ссылку и это тогда наш(новый)
объект станет недоступен другим, а знать об этом не будет!!! объект станет недоступен другим, а знать об этом не будет!!!
*/ */
ucrit << myname << "(registered): replace object (ObjectNameAlready)" << endl; uwarn << myname << "(registration): replace object (ObjectNameAlready)" << endl;
regOK = true; unregistration();
unregister();
}
} }
} catch( uniset::ORepFailed )
catch( ORepFailed )
{ {
string err(myname + ": don`t registration in object reposotory"); uwarn << myname << "(registration): don`t registration in object reposotory " << endl;
uwarn << myname << "(registered): " << err << endl;
throw ORepFailed(err);
} }
catch( const uniset::Exception& ex ) catch( const uniset::Exception& ex )
{ {
uwarn << myname << "(registered): " << ex << endl; uwarn << myname << "(registration): " << ex << endl;
string err(myname + ": don`t registration in object reposotory");
throw ORepFailed(err);
} }
regOK = true; msleep(conf->getRepeatTimeout());
}
if( !regOK )
{
string err(myname + "(registration): don`t registration in object reposotory");
ucrit << err << endl;
throw ORepFailed(err);
}
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void UniSetObject::unregister() void UniSetObject::unregistration()
{ {
if( myid < 0 ) // || !reg ) if( myid < 0 ) // || !reg )
return; return;
...@@ -529,7 +532,7 @@ namespace uniset ...@@ -529,7 +532,7 @@ namespace uniset
uwarn << myname << "(deactivate): " << ex.what() << endl; uwarn << myname << "(deactivate): " << ex.what() << endl;
} }
unregister(); unregistration();
PortableServer::ObjectId_var oid = poamngr->servant_to_id(static_cast<PortableServer::ServantBase*>(this)); PortableServer::ObjectId_var oid = poamngr->servant_to_id(static_cast<PortableServer::ServantBase*>(this));
poamngr->deactivate_object(oid); poamngr->deactivate_object(oid);
uinfo << myname << "(disacivate): finished..." << endl; uinfo << myname << "(disacivate): finished..." << endl;
...@@ -587,12 +590,18 @@ namespace uniset ...@@ -587,12 +590,18 @@ namespace uniset
throw ORepFailed(err); throw ORepFailed(err);
} }
bool actOK = false;
auto conf = uniset_conf();
for( size_t i = 0; i < conf->getRepeatCount(); i++ )
{
try try
{ {
if( uniset_conf()->isTransientIOR() ) if( conf->isTransientIOR() )
{ {
// activate witch generate id // activate witch generate id
poa->activate_object(static_cast<PortableServer::ServantBase*>(this)); poa->activate_object(static_cast<PortableServer::ServantBase*>(this));
actOK = true;
break;
} }
else else
{ {
...@@ -600,7 +609,7 @@ namespace uniset ...@@ -600,7 +609,7 @@ namespace uniset
// то myname = noname. ВСЕГДА! // то myname = noname. ВСЕГДА!
if( myid == uniset::DefaultObjectId ) if( myid == uniset::DefaultObjectId )
{ {
ucrit << myname << "(activate): Не задан ID!!! activate failure..." << endl; uwarn << myname << "(activate): Не задан ID!!! IGNORE ACTIVATE..." << endl;
// вызываем на случай если она переопределена в дочерних классах // вызываем на случай если она переопределена в дочерних классах
// Например в UniSetManager, если здесь не вызвать, то не будут инициализированы подчинённые объекты. // Например в UniSetManager, если здесь не вызвать, то не будут инициализированы подчинённые объекты.
// (см. UniSetManager::activateObject) // (см. UniSetManager::activateObject)
...@@ -609,13 +618,12 @@ namespace uniset ...@@ -609,13 +618,12 @@ namespace uniset
} }
// Always use the same object id. // Always use the same object id.
PortableServer::ObjectId_var oid = PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId(myname.c_str());
PortableServer::string_to_ObjectId(myname.c_str());
// cerr << myname << "(activate): " << _refcount_value() << endl;
// Activate object... // Activate object...
poa->activate_object_with_id(oid, this); poa->activate_object_with_id(oid, this);
actOK = true;
break;
} }
} }
catch( const CORBA::Exception& ex ) catch( const CORBA::Exception& ex )
...@@ -631,12 +639,24 @@ namespace uniset ...@@ -631,12 +639,24 @@ namespace uniset
uwarn << myname << "(activate): IGNORE.. catch " << ex._name() << endl; uwarn << myname << "(activate): IGNORE.. catch " << ex._name() << endl;
} }
msleep( conf->getRepeatTimeout() );
}
if( !actOK )
{
ostringstream err;
err << myname << "(activate): DON`T ACTIVATE..";
ucrit << myname << "(activate): " << err.str() << endl;
throw uniset::SystemError(err.str());
}
{ {
uniset::uniset_rwmutex_wrlock lock(refmutex); uniset::uniset_rwmutex_wrlock lock(refmutex);
oref = poa->servant_to_reference(static_cast<PortableServer::ServantBase*>(this) ); oref = poa->servant_to_reference(static_cast<PortableServer::ServantBase*>(this) );
} }
registered(); registration();
// Запускаем поток обработки сообщений // Запускаем поток обработки сообщений
setActive(true); setActive(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