From: Mika Laitio Date: Thu, 7 Oct 2010 18:53:18 +0000 (+0300) Subject: [http://pilppa.org/home/issues/4] Fix the service creation on new name server instances X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=0fd166a47de97339450927147f81e12b9cf17a40;p=libplpbus.git [http://pilppa.org/home/issues/4] Fix the service creation on new name server instances --- diff --git a/src/plpbus/OrbServerImpl.cc b/src/plpbus/OrbServerImpl.cc index fc0eecc..ea651a9 100644 --- a/src/plpbus/OrbServerImpl.cc +++ b/src/plpbus/OrbServerImpl.cc @@ -236,47 +236,66 @@ CosNaming::NamingContext_var OrbServerImpl::get_service_naming_context(const cha ret_val = NULL; try { // get nameservice reference + log_debug("get_service_naming_context() 1\n"); ns_obj = _orb->resolve_initial_references(CONST_NAME_SERVICE_NAME); - // get nameservice context + log_debug("get_service_naming_context() 2\n"); + // get name service context ns_context = CosNaming::NamingContext::_narrow(ns_obj); + log_debug("get_service_naming_context() 3\n"); if (CORBA::is_nil(ns_context) == false) { context_data.length(1); - context_data[0].id = service_name_param; - context_data[0].kind = service_kind_param; + context_data[0].id = service_name_param; + context_data[0].kind = service_kind_param; + log_debug("get_service_naming_context() 4\n"); try { service_obj = ns_context->resolve(context_data); + } + catch(CosNaming::NamingContext::NotFound& ex) { + log_error("Failed to get context from name service for %s. Context does not yet exist, but will try to create.\n", service_name_param); + } + try { + log_debug("get_service_naming_context() 5\n"); if (CORBA::is_nil(service_obj)) { // not found, try to bind the new context to name service + log_debug("get_service_naming_context() 6\n"); ret_val = ns_context->bind_new_context(context_data); + log_debug("get_service_naming_context() 7\n"); if (CORBA::is_nil(ret_val) ) { - cerr << "Failed to create new context to name service for " << service_name_param << "." << endl; + log_error("Failed to create new context to name service for %s.\n", service_name_param); } } else { + log_debug("get_service_naming_context() 8\n"); ret_val = CosNaming::NamingContext::_narrow(service_obj); + log_debug("get_service_naming_context() 9\n"); if (CORBA::is_nil(ret_val) ) { - cerr << "Failed to get existing context from name service for " << service_name_param << ", narrowing failed." << endl; + log_error("Failed to get existing context from name service for %s, narrowing failed.\n", service_name_param); } } } catch(CosNaming::NamingContext::AlreadyBound& ex) { - cerr << "Could not get context from nameservice for " << service_name_param << ". Context with same name already existed."<< endl; + log_error("Failed to get context from name service for %s. Context with same name already exist.\n", service_name_param); } } } catch (CORBA::ORB::InvalidName&) { // This should not happen! - cerr << "Could not get context from name service for " << service_name_param << ", name service does not exist." << endl; + log_error("Failed to get context from name service for %s, name service does not exist.\n", service_name_param); } catch(CORBA::TRANSIENT& ex) { - cerr << "Could not get context from name service for " << service_name_param << ", verify that name service is running. " << service_name_param << endl; + log_error("Failed to get context from name service for %s, verify that name service is running.\n", service_name_param); } catch (CORBA::NO_RESOURCES&) { - cerr << "Could not get context from name service for " << service_name_param << ". Name service is not running or has configuration problem." << endl; + log_error("Failed to get context from name service for %s, Name service is not running or has configuration problem.\n", service_name_param); + log_error("Things to check:\n", service_name_param); + log_error("If you have OMNIORB_CONFIG environment variable defined, verify that omniORB.cfg file exist in that location.\n", service_name_param); + log_error("If you do not have OMNIORB_CONFIG environment variable defined, verify that you have /etc/omniORB.cfg file\n", service_name_param); + log_error("Verify that InitRef line is defined in omniORB.cfg file.\n", service_name_param); } catch(CORBA::SystemException& ex) { - cerr << "Could not get context from name service for " << service_name_param << ", could not determine reason." << endl; + log_error("Failed to get context from name service for %s, system error.\n", service_name_param); } + log_debug("get_service_naming_context() done\n"); return ret_val; }