예제 #1
0
int
Locator_Repository::remove_activator (const ACE_CString& name)
{
  int err = sync_load ();
  if (err != 0)
    {
      return err;
    }

  int ret = activators().unbind (lcase(name));
  if (ret != 0)
    {
      return ret;
    }

  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 (info->death_notify && info->activator == name)
      {
        info->death_notify = false;
      }
  }

  return persistent_remove(name, true);
}
예제 #2
0
int
XML_Backing_Store::persist ()
{
  FILE* fp = ACE_OS::fopen (this->filename_.c_str (), "w");
  if (fp == 0)
    {
      ORBSVCS_ERROR ((LM_ERROR, ACE_TEXT ("Couldn't write to file %C\n"),
        this->filename_.c_str()));
      return -1;
    }
  ACE_OS::fprintf (fp,"<?xml version=\"1.0\"?>\n");
  ACE_OS::fprintf (fp,"<%s>\n", Locator_XMLHandler::ROOT_TAG);

  // Save servers
  Locator_Repository::SIMap::ENTRY* sientry = 0;
  Locator_Repository::SIMap::ITERATOR siit (this->servers ());
  for (; siit.next (sientry); siit.advance() )
    {
      persist(fp, *sientry->int_id_, "\t");
    }

  // Save Activators
  Locator_Repository::AIMap::ENTRY* aientry = 0;
  Locator_Repository::AIMap::ITERATOR aiit (this->activators ());
  for (; aiit.next (aientry); aiit.advance ())
    {
      ACE_CString aname = aientry->ext_id_;
      persist(fp, *aientry->int_id_, "\t");
    }

  ACE_OS::fprintf (fp,"</%s>\n", Locator_XMLHandler::ROOT_TAG);
  ACE_OS::fclose (fp);

  return 0;
}
예제 #3
0
Server_Info_Ptr
Locator_Repository::find_by_poa (const ACE_CString & name)
{
  Locator_Repository::SIMap::ENTRY* sientry = 0;
  Locator_Repository::SIMap::ITERATOR siit (servers ());
  for (; siit.next (sientry); siit.advance() )
  {
    Server_Info_Ptr& info = sientry->int_id_;
    if (info->poa_name == name)
      {
        return info;
      }
  }
  return Server_Info_Ptr();
}
예제 #4
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;
}
int
ImR_Locator_i::init_with_orb (CORBA::ORB_ptr orb)
{
  this->orb_ = CORBA::ORB::_duplicate (orb);
  ImR_Locator_i::debug_ = this->opts_->debug ();
  CORBA::Object_var obj =
    this->orb_->resolve_initial_references ("RootPOA");
  this->root_poa_ = PortableServer::POA::_narrow (obj.in ());
  ACE_ASSERT (! CORBA::is_nil (this->root_poa_.in ()));

  this->dsi_forwarder_.init (orb);
  this->adapter_.init (& this->dsi_forwarder_);
  this->pinger_.init (orb, this->opts_->ping_interval ());

  this->opts_->pinger (&this->pinger_);

  // Register the Adapter_Activator reference to be the RootPOA's
  // Adapter Activator.
  root_poa_->the_activator (&this->adapter_);

  // Use a persistent POA so that any IOR
  this->imr_poa_ = createPersistentPOA (this->root_poa_.in (),
                                        "ImplRepo_Service");
  ACE_ASSERT (! CORBA::is_nil (this->imr_poa_.in ()));

  PortableServer::ObjectId_var id =
    PortableServer::string_to_ObjectId ("ImplRepo_Service");
  this->imr_poa_->activate_object_with_id (id.in (), this);

  obj = this->imr_poa_->id_to_reference (id.in ());
  ImplementationRepository::Locator_var locator =
    ImplementationRepository::Locator::_narrow (obj.in ());
  ACE_ASSERT(! CORBA::is_nil (locator.in ()));
  const CORBA::String_var ior = this->orb_->object_to_string (obj.in ());

  // create the selected Locator_Repository with backing store
  switch (this->opts_->repository_mode ())
    {
    case Options::REPO_REGISTRY:
      {
        repository_.reset(new Registry_Backing_Store(*this->opts_, orb));
        break;
      }
    case Options::REPO_HEAP_FILE:
      {
        repository_.reset(new Heap_Backing_Store(*this->opts_, orb));
        break;
      }
    case Options::REPO_XML_FILE:
      {
        repository_.reset(new XML_Backing_Store(*this->opts_, orb));
        break;
      }
    case Options::REPO_SHARED_FILES:
      {
        repository_.reset(new Shared_Backing_Store(*this->opts_, orb, this));
        break;
      }
    case Options::REPO_NONE:
      {
        repository_.reset(new No_Backing_Store(*this->opts_, orb));
        break;
      }
    default:
      {
        bool invalid_rmode_specified = false;
        ACE_ASSERT (invalid_rmode_specified);
        ACE_UNUSED_ARG (invalid_rmode_specified);
        ORBSVCS_ERROR_RETURN ((
          LM_ERROR, ACE_TEXT ("Repository failed to initialize\n")), -1);
      }
    }

  // Register the ImR for use with INS
  obj = orb->resolve_initial_references ("AsyncIORTable");
  IORTable::Table_var ior_table = IORTable::Table::_narrow (obj.in ());
  ACE_ASSERT (! CORBA::is_nil (ior_table.in ()));
  ior_table->set_locator (this->ins_locator_.in ());

  // initialize the repository. This will load any values that
  // may have been persisted before.
  int result = this->repository_->init(this->root_poa_.in (),
                                       this->imr_poa_.in (),
                                       ior);
  if (result != 0)
    {
      return result;
    }

  Locator_Repository::SIMap::ENTRY* entry = 0;
  Locator_Repository::SIMap::ITERATOR it (this->repository_->servers ());

  for (;it.next (entry) != 0; it.advance ())
    {
      UpdateableServerInfo info (this->repository_, entry->int_id_);
      bool is_alive = this->server_is_alive (info);
      Server_Info *active = info.edit()->active_info ();
      if (this->debug_ > 0)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("server %C is_alive = %d\n"),
                          active->ping_id(), is_alive));
        }

      if (!is_alive)
        {
          info.edit()->reset_runtime ();
          active->reset_runtime ();
          continue;
        }

      active->death_notify = false;
      if (active->pid > 0)
        {
          Activator_Info_Ptr ainfo =
            this->get_activator (active->activator);

          if (!(ainfo.null () || CORBA::is_nil (ainfo->activator.in ())))
            {
              ImplementationRepository::ActivatorExt_var actx =
                ImplementationRepository::ActivatorExt::_narrow (ainfo->activator.in ());
              try
                {
                  active->death_notify =
                    !CORBA::is_nil (actx.in ()) && actx->still_alive (active->pid);
                }
              catch (const CORBA::Exception &)
                {
                }
              if (this->debug_ > 0)
                {
                  ORBSVCS_DEBUG ((LM_DEBUG,
                                  ACE_TEXT ("activator says death_notify = %d\n"),
                                  active->death_notify));
                }
            }
        }
    }

  //only after verifying do we report the IOR and become open for business
  return this->repository_->report_ior(this->imr_poa_.in ());
}