Esempio n. 1
0
Server_Info_Ptr
Locator_Repository::get_active_server (const ACE_CString& name, int pid)
{
  sync_load ();
  ACE_CString key;
  Server_Info_Ptr si;
  if (name.length() == 0)
    {
      return si;
    }
  Server_Info::fqname_to_key (name.c_str(), key);
  servers ().find (key, si);
  if (si.null())
    {
      if (this->opts_.debug() > 5)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) get_active_server could not find %C\n"),
                          name.c_str()));
        }
      si = find_by_poa (key);
      if (si.null())
        {
          if (name.find ("JACORB:") == ACE_CString::npos)
            {
              ACE_CString jo_key ("JACORB:");
              ACE_CString::size_type pos = name.find (':');
              if (pos == ACE_CString::npos)
                {
                  jo_key += name;
                }
              else
                {
                  jo_key += name.substring (0, pos);
                  jo_key += '/';
                  jo_key += name.substring (pos+1);
                }
              return this->get_active_server (jo_key, pid);
            }
          else
            {
              return si;
            }
        }
    }

  if (pid != 0 && si->pid != 0 && si->pid != pid)
    {
      if (this->opts_.debug() > 5)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) get_active_server could not")
                          ACE_TEXT (" find %C, %d != %d\n"),
                          name.c_str(), pid, si->pid));
        }
      si.reset ();
    }
  return si;
}
void
AsyncListManager::init_list (void)
{
  CORBA::ULong len =
    static_cast<CORBA::ULong> (this->repo_->servers ().current_size ());
  Locator_Repository::SIMap::ENTRY* entry = 0;
  Locator_Repository::SIMap::CONST_ITERATOR it (this->repo_->servers ());
  this->server_list_.length (len);
  this->waiters_ = 0;
  for (CORBA::ULong i = 0; i < len; i++)
    {
      it.next (entry);
      it.advance ();

      Server_Info_Ptr info = entry->int_id_;
      info->setImRInfo (&this->server_list_[i]);
      if (this->pinger_ != 0)
        {
          ListLiveListener *l = 0;
          ACE_NEW (l, ListLiveListener (info->ping_id (),
                                        info->pid,
                                        i,
                                        this,
                                        *this->pinger_));

          LiveListener_ptr llp (l);
          if (!l->start ())
            {
              this->server_list_[i].activeStatus =
                ImplementationRepository::ACTIVE_NO;
              l->cancel ();
            }
          else
            {
              if (!evaluate_status (i, l->status(), info->pid))
                {
                  this->waiters_++;
                }
              else
                {
                  l->cancel ();
                }
            }
        }
     }

  if (ImR_Locator_i::debug() > 4)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t) AsyncListManager(%@)::init_list, %d waiters")
                      ACE_TEXT (" out of %d regsitered servers\n"),
                      this, this->waiters_, len));
    }
}
void
ImR_Locator_i::link_servers
(ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr _tao_rh,
 const char * name,
 const CORBA::StringSeq & peers)
{
  Server_Info_Ptr root_si = this->repository_->get_active_server (name);
  if (root_si.null())
    {
      CORBA::Exception *ex =
        new ImplementationRepository::NotFound;
      ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex);
      _tao_rh->link_servers_excep (&h);
      return;
    }
  else if (!root_si->alt_info_.null())
    {
      ACE_CString errstr = name;
      errstr += " is not a base POA";
      CORBA::Exception *ex =
        new ImplementationRepository::CannotComplete (errstr.c_str());
      ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex);
      _tao_rh->link_servers_excep (&h);
      return;
    }

  for (CORBA::ULong i = 0; i < peers.length(); i++)
    {
      ACE_CString peer(peers[i]);
      Server_Info_Ptr si = this->repository_->get_active_server (peer);
      if (!si.null ())
        {
          ACE_CString errstr(peers[i]);
          errstr += " is already registered";
          CORBA::Exception *ex =
            new ImplementationRepository::CannotComplete (errstr.c_str());
          ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex);
          _tao_rh->link_servers_excep (&h);
          return;
        }
    }

  this->repository_->link_peers (root_si, peers);

  _tao_rh->link_servers ();
  return;
}
void
ImR_Locator_i::find
  (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
   const char* id)
{
  Server_Info_Ptr si = this->repository_->get_active_server (id);
  ImplementationRepository::ServerInformation_var imr_info;
  try
    {
      if (! si.null ())
        {
          imr_info = si->createImRServerInfo ();

          if (debug_ > 1)
            ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) ImR: Found server %C.\n"), id));
        }
      else
        {
          ACE_NEW_THROW_EX (imr_info,
                            ImplementationRepository::ServerInformation,
                            CORBA::NO_MEMORY ());
          imr_info->startup.activation= ImplementationRepository::NORMAL;
          if (debug_ > 1)
            ORBSVCS_DEBUG ((LM_DEBUG,
                        ACE_TEXT ("(%P|%t) ImR: Cannot find server <%C>\n"),
                        id));
        }
    }
  catch (const CORBA::Exception &ex)
    {
      ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate());
      _tao_rh->find_excep (&h);
      return;
    }
  _tao_rh->find (imr_info.in());
}
Esempio n. 5
0
void
Config_Backing_Store::loadServers ()
{
  ACE_Configuration_Section_Key root;
  int err =
    config_.open_section (config_.root_section (), SERVERS_ROOT_KEY, 0, root);
  if (err == 0)
    {
      int index = 0;
      ACE_TString name;
      Server_Info *si = 0;
      u_int tmp_int = 0;
      ACE_CString tmp;

      while (config_.enumerate_sections (root, index, name) == 0)
        {
          Server_Info_Ptr info;
          if (this->servers ().find (name, info) != 0)
            {
              ACE_NEW (si, Server_Info);
              info.reset (si);
              si->key_name_ = name;
            }

          ACE_Configuration_Section_Key key;

          // Can't fail, because we're enumerating
          config_.open_section (root, name.c_str(), 0, key);
          if (!config_.get_string_value (key, POA, si->poa_name))
            {
              si->poa_name = si->key_name_;
            }

          // Ignore any missing values. Server name is enough on its own.
          config_.get_string_value (key, SERVER_ID, si->server_id);
          config_.get_string_value (key, JACORB_SERVER, tmp);
          si->is_jacorb = (tmp == "1");
          config_.get_string_value (key, ACTIVATOR, si->activator);
          config_.get_string_value (key, STARTUP_COMMAND, si->cmdline);
          config_.get_string_value (key, WORKING_DIR, si->dir);
          config_.get_string_value (key, ENVIRONMENT, tmp);
          ImR_Utils::stringToEnvList (tmp, si->env_vars);
          config_.get_integer_value (key, ACTIVATION, tmp_int);
          si->activation_mode_ =
            static_cast <ImplementationRepository::ActivationMode> (tmp_int);
          config_.get_string_value (key, PARTIAL_IOR, si->partial_ior);
          config_.get_string_value (key, IOR, si->ior);
          config_.get_integer_value (key, START_LIMIT, tmp_int);
          si->start_limit_ = tmp_int;
          config_.get_integer_value (key, PID, tmp_int);
          si->pid = tmp_int;
          if (config_.get_string_value (key, ALTKEY, tmp))
            {
              if (tmp.length () > 0 &&
                  this->servers ().find (tmp, si->alt_info_) != 0)
                {
                  Server_Info *base_si = 0;
                  ACE_NEW (base_si, Server_Info);
                  base_si->key_name_ = tmp;
                  si->alt_info_.reset (base_si);
                  this->servers ().bind (tmp, si->alt_info_);
                }
            }
          config_.get_string_value (key, PEERS, tmp);
          ImR_Utils::stringToPeerList (tmp, si->peers);
          this->servers ().bind (name, info);
          si = 0;
          ++index;
        }
    }
}
Esempio n. 6
0
int
Locator_Repository::unregister_if_address_reused (const ACE_CString& fqname,
                                                  const char* partial_ior,
                                                  ImR_Locator_i* imr_locator)

{
  if (this->opts_.debug() > 0)
  {
    ORBSVCS_DEBUG ((LM_DEBUG,
                    ACE_TEXT ("(%P|%t)ImR: checking reuse address ")
                    ACE_TEXT ("for server \"%C\" ior \"%C\"\n"),
                    fqname.c_str(),
                    partial_ior));
  }

  ACE_CString key;
  Server_Info_Ptr si;

  Server_Info::fqname_to_key (fqname.c_str(), key);
  servers ().find (key, si);
  ACE_CString poa_name;
  ACE_CString server_id;
  if (si.null())
    {
      Server_Info::parse_id (fqname.c_str(), server_id, poa_name);
    }
  else
    {
      server_id = si->active_info ()->server_id;
      poa_name = si->active_info ()->poa_name;
    }

  Locator_Repository::SIMap::ENTRY* sientry = 0;
  Locator_Repository::SIMap::ITERATOR siit (servers ());
  for (; siit.next (sientry); siit.advance() )
  {
    Server_Info *info = sientry->int_id_->active_info ();

    if (this->opts_.debug() > 0)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t)ImR: iterating - registered server")
                      ACE_TEXT ("\"%C:%C\" key = <%C> ior \"%C\"\n"), info->server_id.c_str(),
                      info->poa_name.c_str (), info->key_name_.c_str(), info->partial_ior.c_str ()));
    }
    bool same_server = info->server_id == server_id;
    if (same_server && (server_id.length () == 0))
      {
        same_server = info->poa_name == poa_name;
      }
    if (info->partial_ior == partial_ior && !same_server)
      {
        if (this->opts_.debug() > 0)
          {
            ORBSVCS_DEBUG ((LM_DEBUG,
                            ACE_TEXT ("(%P|%t)ImR: reuse address %C so remove server %C \n"),
                            info->partial_ior.c_str (), info->poa_name.c_str ()));
          }
        imr_locator->pinger ().remove_server (info->key_name_.c_str());
        AsyncAccessManager_ptr aam = imr_locator->find_aam (info->key_name_.c_str ());
        if (!aam.is_nil())
          {
            aam->server_is_shutting_down ();
          }
        info->reset_runtime ();
      }
  }

  return 0;
}
void
ImR_Locator_i::remove_server
(ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
 const char* id)
{
  if (this->opts_->readonly ())
    {
      ORBSVCS_ERROR ((LM_ERROR,
                  ACE_TEXT ("(%P|%t) ImR: Can't remove server <%C> due to locked database.\n"),
                  id));
      CORBA::Exception *ex =
        new CORBA::NO_PERMISSION (CORBA::SystemException::_tao_minor_code
                                  (TAO_IMPLREPO_MINOR_CODE, 0),
                                  CORBA::COMPLETED_NO);
      ImplementationRepository::AMH_AdministrationExceptionHolder h (ex);
      _tao_rh->remove_server_excep (&h);
      return;
    }

  Server_Info_Ptr info = this->repository_->get_active_server (id);
  if (! info.null ())
    {
      AsyncAccessManager_ptr aam(this->find_aam  (info->key_name_.c_str()));
      if (!aam.is_nil())
        {
          if (debug_ > 0)
            ORBSVCS_DEBUG ((LM_DEBUG,
                            ACE_TEXT ("(%P|%t) ImR: Can't remove active server <%C>.\n"),
                            info->key_name_.c_str()));
          CORBA::Exception *ex =
            new CORBA::NO_PERMISSION (CORBA::SystemException::_tao_minor_code
                                      (TAO_IMPLREPO_MINOR_CODE, EBUSY),
                                      CORBA::COMPLETED_NO);
          ImplementationRepository::AMH_AdministrationExceptionHolder h (ex);
          _tao_rh->remove_server_excep (&h);
          return;
        }
      if (debug_ > 1)
        ORBSVCS_DEBUG ((LM_DEBUG,
                        ACE_TEXT ("(%P|%t) ImR: Removing Server <%C>...\n"),
                        info->key_name_.c_str()));

      ACE_CString poa_name = info->poa_name;
      if (this->repository_->remove_server (info->key_name_, this) == 0)
        {
          this->destroy_poa (poa_name);
          if (debug_ > 0)
            ORBSVCS_DEBUG ((LM_DEBUG,
                        ACE_TEXT ("(%P|%t) ImR: Removed Server <%C>.\n"),
                        id));
        }
    }
  else
    {
      ORBSVCS_ERROR ((LM_ERROR,
                  ACE_TEXT ("(%P|%t) ImR: Can't remove unknown server <%C>.\n"), id));
      CORBA::Exception *ex = new ImplementationRepository::NotFound;
      ImplementationRepository::AMH_AdministrationExceptionHolder h (ex);
      _tao_rh->remove_server_excep (&h);
      return;
    }
  _tao_rh->remove_server ();
}
bool
ImR_Locator_i::get_info_for_name (const char* name, Server_Info_Ptr &si)
{
  si = this->repository_->get_active_server (name);
  return !si.null();
}
void
ImR_Locator_i::server_is_running
(ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
 const char* id,
 const char* partial_ior,
 ImplementationRepository::ServerObject_ptr server_object)
{
  if (debug_ > 0)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t) ImR: Server %C is running at %C.\n"),
                      id, partial_ior));
    }
  CORBA::String_var sior = orb_->object_to_string (server_object);

  if (debug_ > 1)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t) ImR: Server %C callback at %C.\n"),
                      id, sior.in ()));
    }

  if (this->opts_->unregister_if_address_reused ())
    this->repository_->unregister_if_address_reused (id, partial_ior, this);

  CORBA::Object_var obj = this->set_timeout_policy (server_object, this->opts_->ping_timeout ());
  ImplementationRepository::ServerObject_var srvobj =
    ImplementationRepository::ServerObject::_narrow (obj.in());

  UpdateableServerInfo info (this->repository_, id);
  if (info.null ())
    {
      if (debug_ > 0)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t) ImR: Auto adding NORMAL server <%C>.\n"),
                          id));
        }

      Server_Info_Ptr si;
      if (this->repository_->add_server (id, partial_ior, sior.in (), srvobj.in ()) == 0)
        {
          si = this->repository_->get_active_server (id);
        }

      if (si.null ())
        {
          if (debug_ > 0)
            {
              ORBSVCS_DEBUG ((LM_DEBUG,
                              ACE_TEXT ("(%P|%t) ImR: Auto adding failed, giving up <%C>\n"),
                              id));
            }
          CORBA::NO_MEMORY ex;
          ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate());
          _tao_rh->server_is_running_excep (&h);
          return;
        }
      info.server_info (si);
      this->pinger_.add_server (si->ping_id (), this->opts_->ping_external (), srvobj.in());

      ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
      AsyncAccessManager_ptr aam (this->create_aam (info, true));
    }
  else
    {
      if (!info->is_mode(ImplementationRepository::PER_CLIENT))
        {
          info.edit ()->set_contact (partial_ior, sior.in(), srvobj.in());

          info.update_repo();
          this->pinger_.add_server (info->ping_id(), true, srvobj.in());
        }

      AsyncAccessManager_ptr aam(this->find_aam (info->ping_id ()));
      if (!aam.is_nil())
        {
          if (ImR_Locator_i::debug () > 4)
            {
              ORBSVCS_DEBUG ((LM_DEBUG,
                              ACE_TEXT ("(%P|%t) ImR_Locator_i::server_is_running aam is not nil\n")));
            }
          aam->server_is_running (partial_ior, srvobj.in());
        }
      else
        {
          if (ImR_Locator_i::debug () > 4)
            {
              ORBSVCS_DEBUG ((LM_DEBUG,
                              ACE_TEXT ("(%P|%t) ImR_Locator_i::server_is_running aam is nil\n")));
            }
          if (!info->is_mode(ImplementationRepository::PER_CLIENT))
            {
              ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
              aam = this->create_aam (info, true);
            }
        }
    }
  _tao_rh->server_is_running ();
}