322{
325 try
326 {
328 }
329 catch(SALOME_Exception& e)
330 {
331 throw Exception(
"SalomeContainer::start : Unable to contact the SALOME Naming Service");
332 }
333 CORBA::Object_var obj(ns.
Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS));
334 Engines::ContainerManager_var contManager(Engines::ContainerManager::_narrow(obj));
335
336 bool isEmptyName;
339
340
341
342 for(std::vector<std::string>::const_iterator iter=compoNames.begin();iter!=compoNames.end();iter++)
344
346 {
348 myparams.mode=CORBA::string_dup(dftLauchMode.c_str());
349 }
350
351
352
354 {
355 myparams.mode=CORBA::string_dup("getorstart");
356 }
357
358 if (isEmptyName)
359 {
360 shutdownLevel=1;
361 }
362
364 Engines::Container_var trueCont(Engines::Container::_nil());
365 if(!isEmptyName && shutdownLevel==999)
366 {
367
368
369
370
371 myparams.mode="get";
372 try
373 {
375 trueCont=contManager->GiveContainer(myparams);
376 }
377 catch(
const SALOME::SALOME_Exception&
ex )
378 {
379 std::string msg="SalomeContainer::start : no existing container : ";
380 msg += '\n';
381 msg +=
ex.details.text.in();
383 }
384 catch(...)
385 {
386 }
387
388 if(!CORBA::is_nil(trueCont))
389 {
390 shutdownLevel=3;
392 }
393 else
394 {
395 shutdownLevel=2;
396 myparams.mode="start";
397 DEBUG_YACSTRACE(
"container not found: " << str <<
" " << shutdownLevel);
398 }
399 }
400
401 int nbTries=0;
402 while(CORBA::is_nil(trueCont))
403 {
404 try
405 {
406
407
409 trueCont=contManager->GiveContainer(myparams);
410 }
411 catch(
const SALOME::SALOME_Exception&
ex )
412 {
413 std::string msg="SalomeContainer::start : Unable to launch container in Salome : ";
414 msg += '\n';
415 msg +=
ex.details.text.in();
417 }
418 catch(CORBA::COMM_FAILURE&)
419 {
420
421 DEBUG_YACSTRACE(
"SalomeContainer::start :" << str <<
" :CORBA Comm failure detected. Make another try!");
422 nbTries++;
423 if(nbTries > 5)
424 {
425 std::ostringstream oss; oss << "SalomeContainer::start : Unable to launch container " << myparams.container_name << " in Salome : CORBA Comm failure detected";
427 }
428 }
429 catch(CORBA::Exception&)
430 {
431 std::ostringstream oss; oss << "SalomeContainer::start : Unable to launch container " << myparams.container_name << " in Salome : Unexpected CORBA failure detected";
433 }
434 }
435
436 if(CORBA::is_nil(trueCont))
437 {
438 std::ostringstream oss; oss << "SalomeContainer::start : Unable to launch container " << myparams.container_name << " in Salome. Check your CatalogResources.xml file";
440 }
441
442
444
445 CORBA::String_var containerName(trueCont->name()),hostName(trueCont->getHostName());
446
447 DEBUG_YACSTRACE(
"SalomeContainer launched : NS entry : " << containerName <<
" PID : " << trueCont->getPID() );
448}
void init_orb(CORBA::ORB_ptr orb=0) override
CORBA::Object_ptr Resolve(const char *Path) override
virtual std::string getDftLaunchMode() const =0
virtual void setContainer(const Task *askingNode, Engines::Container_var cont)=0
YACSRUNTIMESALOME_EXPORT RuntimeSALOME * getSALOMERuntime()