コード例 #1
0
CORBA::Object_ptr AutomaticGainControl_i::getPort( const char* portName ) throw (CORBA::SystemException, CF::PortSupplier::UnknownPort)
{
    DEBUG(3, AutomaticGainControl, "getPort() invoked with : " << portName)
    CORBA::Object_var p;

    p = dataOut_0->getPort(portName);
    if (!CORBA::is_nil(p))
        return p._retn();

    p = dataIn_0->getPort(portName);
    if (!CORBA::is_nil(p))
        return p._retn();
    /*exception*/
    throw CF::PortSupplier::UnknownPort();
}
コード例 #2
0
CORBA::Object_ptr
TAO_CEC_ProxyPushSupplier::apply_policy_obj (CORBA::Object_ptr pre)
{
#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
  CORBA::Object_var post = CORBA::Object::_duplicate (pre);
  if (this->timeout_ > ACE_Time_Value::zero)
    {
      CORBA::PolicyList policy_list;
      policy_list.length (1);
#if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
      if (this->typed_event_channel_)
        {
          policy_list[0] = this->typed_event_channel_->
            create_roundtrip_timeout_policy (this->timeout_);
        }
      else
        {
#endif
          policy_list[0] = this->event_channel_->
            create_roundtrip_timeout_policy (this->timeout_);
#if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
        }
#endif
      post = pre->_set_policy_overrides (policy_list, CORBA::ADD_OVERRIDE);

      policy_list[0]->destroy ();
      policy_list.length (0);
    }
  return post._retn ();
#else
  return CORBA::Object::_duplicate (pre);
#endif /* TAO_HAS_CORBA_MESSAGING */
}
コード例 #3
0
ファイル: Basic.cpp プロジェクト: OspreyHub/ATCD
void
Basic::init_CosEC (void)
{
  CosEC_ServantBase *ec = 0;

  ACE_NEW_THROW_EX (ec,
                    CosEC_ServantBase (),
                    CORBA::NO_MEMORY ());

  PortableServer::ServantBase_var ec_var (ec);

  ec->init (this->root_poa_.in(),
            this->root_poa_.in(),
            0,0,0);

  int retval = ec->activate ();

  if (retval == -1)
    throw CORBA::UNKNOWN ();
  // @@ look for more descriptive exception to throw here

  CORBA::Object_var obj =
    this->root_poa_->servant_to_reference (ec);

  this->cos_ec_ =
    CosEventChannelAdmin::EventChannel::_narrow (obj._retn ());
}
コード例 #4
0
const char *
Plan_Launcher_Base_Impl< Manager, AppManager, Application>
::launch_plan (const ::Deployment::DeploymentPlan &plan,
               CORBA::Object_out am_out,
               CORBA::Object_out app_out)
{
  DANCE_TRACE ("Plan_Launcher_Base_Impl::launch_plan");

  try
    {
      CORBA::Object_var app_mgr = this->prepare_plan (plan);

      ::Deployment::Connections_var conns;

      CORBA::Object_var app = this->start_launch (app_mgr.in (),
                                                  0,
                                                  conns.out ());

      this->finish_launch (app.in (),
                           conns,
                           false);

      this->start (app.in ());

      DANCE_DEBUG (DANCE_LOG_MAJOR_EVENT,
                   (LM_DEBUG, DLINFO
                    ACE_TEXT ("Plan_Launcher_Base_Impl::launch_plan - ")
                    ACE_TEXT ("Application Deployed successfully\n")));

      am_out = app_mgr._retn ();
      app_out = app._retn ();
    }
  catch (const CORBA::Exception& ex)
    {
      char buf[1024];
      ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - CORBA EXCEPTION: <%s>\n",
                       ex._info().fast_rep());
      DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
                   (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
      throw Deployment_Failure (buf);
    }
  catch (const Deployment_Failure &)
    {
      throw;
    }
  catch (...)
    {
      char buf[1024];
      ACE_OS::sprintf (buf, "Plan_Launcher_Base_Impl::launch_plan - EXCEPTION: non-CORBA exception\n");
      DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
                   (LM_ERROR, DLINFO ACE_TEXT("%C"), buf));
      throw Deployment_Failure (buf);
    }

  return plan.UUID.in();
}
コード例 #5
0
ファイル: amplifier.cpp プロジェクト: darshanst/opencpi
CORBA::Object_ptr amplifier_i::getPort( const char* portName ) throw (CORBA::SystemException, CF::PortSupplier::UnknownPort)
{
    std::cout << "amplifier_i getPort called with : " << portName << std::endl;

    CORBA::Object_var p;

    p = dataOut_0->getPort(portName);

    if (!CORBA::is_nil(p))
        return p._retn();

    p = dataIn_0->getPort(portName);

    if (!CORBA::is_nil(p))
        return p._retn();

    /*exception*/
    throw CF::PortSupplier::UnknownPort();
}
コード例 #6
0
ファイル: Channel.cpp プロジェクト: nzneer/ossie-june
CORBA::Object_ptr Channel_i::getPort(const char*portName)
throw ( CORBA::SystemException, CF::PortSupplier::UnknownPort)
{
    DEBUG(3, Channel, "getPort() invoked with " << portName)

    CORBA::Object_var p;

    p = dataIn->getPort(portName);

    if (!CORBA::is_nil(p))
        return p._retn();

    p = dataOut->getPort(portName);

    if (!CORBA::is_nil(p))
        return p._retn();

    /*exception*/
    throw CF::PortSupplier::UnknownPort();
}
コード例 #7
0
CORBA::Object_ptr ConnectionManager::resolveComponent(const std::string& identifier)
{
    CORBA::Object_var target = _componentLookup->lookupComponentByInstantiationId(identifier);
    if (CORBA::is_nil(target)) {
        target = _componentLookup->lookupDeviceManagerByInstantiationId(identifier);
    }
    if (CORBA::is_nil(target)) {
        LOG_DEBUG(ConnectionManager, "Could not locate component with instantiation id " << identifier);
    }
    return target._retn();
}
コード例 #8
0
CORBA::Object_ptr
TAO_Notify_RT_StructuredProxyPushSupplier::activate (PortableServer::Servant servant)
{
  CORBA::Object_var object = TAO_Notify_Proxy::activate (servant);

  // Obtain our ref.
  CORBA::Object_var obj = this->ref ();

  this->event_forwarder_ = Event_Forwarder::StructuredProxyPushSupplier::_narrow (obj.in ());

  return object._retn ();
}
コード例 #9
0
ファイル: LookupManager.cpp プロジェクト: OspreyHub/ATCD
CORBA::Object_ptr
TAO_Notify_Tests_LookupManager::resolve_object (const char* obj_name)
{
  CosNaming::Name name (1);
  name.length (1);
  name[0].id = CORBA::string_dup (obj_name);

  CORBA::Object_var obj =
    this->naming_->resolve (name);

  return obj._retn ();
}
コード例 #10
0
CORBA::Object_ptr
HomeServantBase::create_primary_object_reference (const char* rep_id)
{
	Qedo::Key* key = new Qedo::Key();
	CORBA::OctetSeq_var key_seq = key->key_value();

	CORBA::Object_var obj = create_object_reference (&key_seq.in(), rep_id);

	key->_remove_ref();

	return obj._retn();
}
コード例 #11
0
CORBA::Object_ptr TAO::Object_Group_Creator::create_infrastructure_managed_group (
    const char * type_id)
{
  CORBA::Object_var group = CORBA::Object::_nil ();

  if (this->have_replication_manager_)
  {
    // set typeid properties
    PortableGroup::Properties properties (1);
    properties.length (3);

    properties[0].nam.length (1);
    properties[0].nam[0].id = PortableGroup::PG_MEMBERSHIP_STYLE;
    properties[0].val <<= PortableGroup::MEMB_INF_CTRL;

    PortableGroup::InitialNumberMembersValue inm(2);
    properties[1].nam.length (1);
    properties[1].nam[0].id = PortableGroup::PG_INITIAL_NUMBER_MEMBERS;
    properties[1].val <<= inm;

    PortableGroup::MinimumNumberMembersValue mnm(1);
    properties[2].nam.length (1);
    properties[2].nam[0].id = PortableGroup::PG_MINIMUM_NUMBER_MEMBERS;
    properties[2].val <<= mnm;

    this->replication_manager_->set_type_properties (
      type_id,
      properties);

    ::PortableGroup::GenericFactory::FactoryCreationId_var creation_id;
    PortableGroup::Criteria criteria (1);
    criteria.length (1);
    criteria[0].nam.length (1);
    criteria[0].nam[0].id = PortableGroup::PG_MEMBERSHIP_STYLE;
    criteria[0].val <<= PortableGroup::MEMB_APP_CTRL;

    group = this->replication_manager_->create_object (
      type_id,
      criteria,
      creation_id
      );
  }
  else
  {
    ACE_ERROR ((LM_ERROR,
      ACE_TEXT("%T %n (%P|%t): Object_Group_Creator: infrastructure managed group requires Replication Manager\n")
      ));
  }
  return group._retn ();
}
コード例 #12
0
ファイル: WebCamCapture.cpp プロジェクト: nzneer/ossie-june
CORBA::Object_ptr WebCamCapture_i::getPort( const char* portName ) throw (CORBA::SystemException, CF::PortSupplier::UnknownPort)
{
    DEBUG(3, WebCamCapture, "getPort invoked with port name: " << portName)

    CORBA::Object_var p;

    p = dataOut_0->getPort(portName);

    if (!CORBA::is_nil(p))
        return p._retn();

    /*exception*/
    throw CF::PortSupplier::UnknownPort();
}
コード例 #13
0
CORBA::Object_ptr writeBytestoFile_i::getPort( const char* portName ) throw (
    CORBA::SystemException, CF::PortSupplier::UnknownPort)
{
    DEBUG(3, writeBytestoFile, "getPort() invoked with " << portName)

    CORBA::Object_var p;

    p = dataIn_0->getPort(portName);

    if (!CORBA::is_nil(p))
        return p._retn();

    /*exception*/
    throw CF::PortSupplier::UnknownPort();
}
コード例 #14
0
ファイル: CorbaGC.cpp プロジェクト: RedhawkSDR/framework-core
CORBA::Object* ossie::corba::activateGCObject(PortableServer::POA_ptr poa,
                                              PortableServer::Servant servant,
                                              boost::posix_time::time_duration ttl,
                                              const std::string& destroy)
{
    PortableServer::ServantManager_var manager = poa->get_servant_manager();
    PortableServer::Servant mgr_servant = ossie::corba::RootPOA()->reference_to_servant(manager);
    GCServantLocator* gc_manager = dynamic_cast<GCServantLocator*>(mgr_servant);
    if (!gc_manager) {
        throw PortableServer::POA::WrongPolicy();
    }
    CORBA::Object_var obj = poa->create_reference(servant->_mostDerivedRepoId());
    PortableServer::ObjectId_var oid = poa->reference_to_id(obj);
    gc_manager->register_servant(oid, servant, ttl, destroy);
    return obj._retn();
}
コード例 #15
0
ファイル: AppHelper.cpp プロジェクト: chenbk85/ACE-Middleware
CORBA::Object_ptr
AppHelper::activate_servant(PortableServer::POA_ptr poa,
                            PortableServer::Servant servant)
{
  // Activate the servant using the Child POA.
  PortableServer::ObjectId_var oid
    = poa->activate_object(servant);

  CORBA::Object_var obj
    = poa->servant_to_reference(servant);

  if (CORBA::is_nil(obj.in()))
    {
      ACE_ERROR((LM_ERROR,
                 "(%P|%t) Failed to convert servant_to_ref.\n"));
      throw TestAppException();
    }

  return obj._retn();
}
コード例 #16
0
  ::CORBA::Object_ptr
  Connector_Servant_Impl_Base::provide_facet (const char *name)
  {
    CIAO_TRACE("Connector_Servant_Impl_Base::provide_facet (const char *name)");

    if (0 == name)
      {
        CIAO_ERROR (1, (LM_ERROR, CLINFO "Connector_Servant_Impl_Base::provide_facet - Got nil name"));

        throw ::Components::InvalidName ();
      }

    CORBA::Object_var retval = this->lookup_facet (name);

    if ( ::CORBA::is_nil (retval. in()))
      {
        throw ::Components::InvalidName ();
      }

    return retval._retn ();
  }
コード例 #17
0
ファイル: PG_Object_Group.cpp プロジェクト: akostrikov/ATCD
CORBA::Object_ptr
TAO::PG_Object_Group::get_member_reference (
    const PortableGroup::Location & the_location)
{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->internals_,
                    CORBA::Object::_nil ());

  CORBA::Object_var result;

  MemberInfo * info = 0;
  if (this->members_.find (the_location, info) == 0)
    {
      result = CORBA::Object::_duplicate (info->member_.in ());
    }
  else
    {
      throw PortableGroup::MemberNotFound();
    }
  return result._retn ();
}
コード例 #18
0
CORBA::Object_ptr
ImR_Locator_i::set_timeout_policy (CORBA::Object_ptr obj, const ACE_Time_Value& to)
{
  CORBA::Object_var ret (CORBA::Object::_duplicate (obj));

  try
    {
      TimeBase::TimeT timeout;
      ORBSVCS_Time::Time_Value_to_TimeT (timeout, to);
      CORBA::Any tmp;
      tmp <<= timeout;

      CORBA::PolicyList policies (1);
      policies.length (1);
      policies[0] = orb_->create_policy (Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
                                         tmp);

      ret = obj->_set_policy_overrides (policies, CORBA::ADD_OVERRIDE);

      policies[0]->destroy ();

      if (CORBA::is_nil (ret.in ()))
        {
          if (debug_ > 0)
            {
              ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) ImR: Unable to set timeout policy.\n")));
            }
          ret = CORBA::Object::_duplicate (obj);
        }
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (
        ACE_TEXT ("(%P|%t) ImR_Locator_i::set_timeout_policy ()"));
    }

  return ret._retn ();
}
コード例 #19
0
ファイル: Monitor.cpp プロジェクト: OspreyHub/ATCD
CORBA::Object_ptr
TAO_Monitor_Init::create_object (CORBA::ORB_ptr orb,
                                 int,
                                 ACE_TCHAR *[])
{
  try
    {
      CORBA::Object_var obj =
        orb->resolve_initial_references ("RootPOA");

      PortableServer::POA_var poa =
        PortableServer::POA::_narrow (obj.in ());

      PortableServer::POAManager_var mgr =
        poa->the_POAManager ();

      mgr->activate ();

      Monitor_Impl *servant = 0;
      ACE_NEW_RETURN (servant,
                      Monitor_Impl (orb),
                      CORBA::Object::_nil ());

      PortableServer::ObjectId_var id =
        poa->activate_object (servant);

      PortableServer::ServantBase_var safe_servant = servant;
      obj = servant->_this ();

      return obj._retn ();
    }
  catch (const CORBA::Exception&)
    {
    }

  return CORBA::Object::_nil ();
}
コード例 #20
0
CORBA::Object_ptr
AssemblyImpl::getRef (ReferenceData data)
throw(Components::CreateFailure)
{
    CORBA::Object_var obj;

	switch(data.kind)
	{
	case COMPONENTID:
		obj = getInstance(data.name);
		break;
	case HOMEID:
		obj = getInstance(data.name);
		break;
	case NAMING:
		obj = resolveName(data.name);
        if ( CORBA::is_nil(obj))
        {
			throw Components::CreateFailure();
        }
		break;
	case OBJECTREF:
		// todo
		break;
	case TRADER:
		// todo
		break;
	case FINDER:
		// todo
		break;
	default:
		break;
	}

	return obj._retn();
}
コード例 #21
0
ファイル: Hash_Naming_Context.cpp プロジェクト: binary42/OCI
CORBA::Object_ptr
TAO_Hash_Naming_Context::resolve (const CosNaming::Name& n)
{
  // Check to make sure this object didn't have <destroy> method
  // invoked on it.
  if (this->destroyed_)
    throw CORBA::OBJECT_NOT_EXIST ();

  // Get the length of the name.
  CORBA::ULong const name_len = n.length ();

  // Check for invalid name.
  if (name_len == 0)
    throw CosNaming::NamingContext::InvalidName();

  // Resolve the first component of the name.

  // Stores the binding type for the first name component.
  CosNaming::BindingType type;

  // Stores the object reference bound to the first name component.
  CORBA::Object_var result;

  {
    ACE_READ_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX, ace_mon, this->lock_,
                             CORBA::INTERNAL ());
    if (this->context_->find (n[0].id,
                              n[0].kind,
                              result.out (),
                              type) == -1)
      throw CosNaming::NamingContext::NotFound
        (CosNaming::NamingContext::missing_node, n);
  }
  // If the name we have to resolve is a compound name, we need to
  // resolve it recursively.
  if (name_len > 1)
    {
      CosNaming::NamingContext_var context =
        CosNaming::NamingContext::_nil ();

      if (type == CosNaming::ncontext)
        {
          // Narrow to NamingContext.
          context = CosNaming::NamingContext::_narrow (result.in ());
        }
      else
        // The first name component wasn't bound to a NamingContext.
        throw CosNaming::NamingContext::NotFound(
          CosNaming::NamingContext::not_context,
          n);

      // If narrow failed...
      if (CORBA::is_nil (context.in ()))
        throw CosNaming::NamingContext::NotFound(
          CosNaming::NamingContext::not_context,
          n);
      else
        {
          // Successfully resolved the first name component, need to
          // recursively call resolve on <n> without the first component.

          // We need a name just like <n> but without the first
          // component.  Instead of copying data we can reuse <n>'s
          // buffer since we will only be using it for 'in' parameters
          // (no modifications).
          CosNaming::Name rest_of_name
            (n.maximum () - 1,
             n.length () - 1,
             const_cast<CosNaming::NameComponent*> (n.get_buffer ())
             + 1);

          // If there are any exceptions, they will propagate up.
          try
            {
              CORBA::Object_ptr resolved_ref;
              resolved_ref = context->resolve (rest_of_name);
              return resolved_ref;
            }
          catch (const CORBA::SystemException&)
            {
              throw CosNaming::NamingContext::CannotProceed
                (context.in (), rest_of_name);
            }
        }
    }
  else
    {
      ACE_READ_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX, ace_mon,
                               this->lock_,
                               CORBA::INTERNAL ());

      if (this->context_->find (n[0].id,
                                n[0].kind,
                                result.out (),
                                type) == -1)
        throw CosNaming::NamingContext::NotFound
          (CosNaming::NamingContext::missing_node, n);
    }

  // If the name we had to resolve was simple, we just need to return
  // the result.
  return result._retn ();
}
コード例 #22
0
CORBA::Object_ptr
NameServiceBase::resolveName(std::string name)
{
    if (name.empty())
    {
        return 0;
    }

    // build a Name
    CosNaming::Name aName;
    std::string binding = name;
    std::string::size_type delimiter_pos;
    int index = 0;

    while (binding.length())
    {
        aName.length(index + 1);
        delimiter_pos = binding.find_first_of("/");
        if (delimiter_pos != std::string::npos)
        {
            aName[index].id = CORBA::string_dup(binding.substr(0, delimiter_pos).c_str());
            aName[index].kind = CORBA::string_dup("");
            binding = binding.replace(0, delimiter_pos + 1, "");
        }
        else
        {
            aName[index].id = CORBA::string_dup(binding.c_str());
            aName[index].kind = CORBA::string_dup("");
            binding = "";
        }

        index++;
    }

    // resolve name
    CORBA::Object_var obj;
    try
	{
	    obj = nameService_->resolve(aName);
	}
	catch(const CosNaming::NamingContext::NotFound&)
	{
		std::cerr << "NameServiceBase: Name binding not found : " << name << std::endl;
		return 0;
	}
	catch(const CosNaming::NamingContext::CannotProceed&)
	{
		std::cerr << "Got a `CannotProceed' exception : " << std::endl;
		return 0;
	}
	catch(const CosNaming::NamingContext::InvalidName&)
	{
	    std::cerr << "Got a `InvalidName' exception : " << std::endl;
		return 0;
	}

    if (CORBA::is_nil(obj))
    {
        return 0;
    }

    return obj._retn();
}
コード例 #23
0
ファイル: server.cpp プロジェクト: OspreyHub/ATCD
CORBA::Object_ptr
join_object_group (CORBA::ORB_ptr orb,
                   CosLoadBalancing::LoadManager_ptr lm,
                   const PortableGroup::Location & location)
{
  CORBA::Object_var ns_object =
    orb->resolve_initial_references ("NameService");

  CosNaming::NamingContext_var nc =
    CosNaming::NamingContext::_narrow (ns_object.in ());

  CosNaming::Name name (1);
  name.length (1);

  name[0].id = "RoundtripObjectGroup";
  name[0].kind = "Object Group";

  CORBA::Object_var group;

  try
    {
      group = nc->resolve (name);
    }
  catch (const CosNaming::NamingContext::NotFound& )
    {
      // Object group not created.  Create one.
      const char repository_id[] = "IDL:Test/Roundtrip:1.0";

      PortableGroup::Criteria criteria (1);
      criteria.length (1);

      PortableGroup::Property & property = criteria[0];
      property.nam.length (1);

      property.nam[0].id =
        CORBA::string_dup ("org.omg.PortableGroup.MembershipStyle");

      PortableGroup::MembershipStyleValue msv =
        PortableGroup::MEMB_APP_CTRL;
      property.val <<= msv;

      PortableGroup::GenericFactory::FactoryCreationId_var fcid;

      group = lm->create_object (repository_id,
                                 criteria,
                                 fcid.out ());

      try
        {
          nc->bind (name,
                    group.in ());

          PortableGroup::Properties props (1);
          props.length (1);
          props[0].nam.length (1);
          props[0].nam[0].id =
            CORBA::string_dup ("org.omg.CosLoadBalancing.StrategyInfo");

          CosLoadBalancing::StrategyInfo strategy_info;

          strategy_info.name = CORBA::string_dup (strategy);

          if (ACE_OS::strcasecmp (strategy, "LeastLoaded") == 0
              && (reject_threshold != 0
                  || critical_threshold != 0
                  || dampening != 0))
            {
              CORBA::ULong len = 1;

              PortableGroup::Properties & props =
                strategy_info.props;

              if (reject_threshold != 0)
                {
                  const CORBA::ULong i = len - 1;

                  props.length (len++);

                  props[i].nam.length (1);
                  props[i].nam[0].id =
                    CORBA::string_dup ("org.omg.CosLoadBalancing.Strategy.LeastLoaded.RejectThreshold");
                  props[i].val <<= reject_threshold;
                }

              if (critical_threshold != 0)
                {
                  const CORBA::ULong i = len - 1;

                  props.length (len++);

                  props[i].nam.length (1);
                  props[i].nam[0].id =
                    CORBA::string_dup ("org.omg.CosLoadBalancing.Strategy.LeastLoaded.CriticalThreshold");
                  props[i].val <<= critical_threshold;
                }

              if (dampening != 0)
                {
                  const CORBA::ULong i = len - 1;

                  props.length (len++);

                  props[i].nam.length (1);
                  props[i].nam[0].id =
                    CORBA::string_dup ("org.omg.CosLoadBalancing.Strategy.LeastLoaded.Dampening");
                  props[i].val <<= dampening;
                }

            }

          props[0].val <<= strategy_info;

          lm->set_default_properties (props);
        }
      catch (const CosNaming::NamingContext::AlreadyBound& )
        {
          // Somebody beat us to creating the object group.  Clean up
          // the one we created.
          lm->delete_object (fcid.in ());

          group = nc->resolve (name);
        }
    }

  Roundtrip * roundtrip_impl;
  ACE_NEW_THROW_EX (roundtrip_impl,
                    Roundtrip (orb),
                    CORBA::NO_MEMORY ());

  PortableServer::ServantBase_var owner_transfer (roundtrip_impl);

  Test::Roundtrip_var roundtrip =
    roundtrip_impl->_this ();

  group = lm->add_member (group.in (),
                          location,
                          roundtrip.in ());

  return group._retn ();
}
コード例 #24
0
ファイル: LB_RoundRobin.cpp プロジェクト: OspreyHub/ATCD
CORBA::Object_ptr
TAO_LB_RoundRobin::next_member (
    PortableGroup::ObjectGroup_ptr object_group,
    CosLoadBalancing::LoadManager_ptr load_manager)
{
  if (CORBA::is_nil (load_manager))
    throw CORBA::BAD_PARAM ();

  const PortableGroup::ObjectGroupId id =
    load_manager->get_object_group_id (object_group);

  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    monitor,
                    this->lock_,
                    CORBA::Object::_nil ());

  // Since this is "built-in" strategy, the LoadManager is collocated.
  // There is no need to release the lock during the following
  // invocation.
  //
  // There is a race condition here.  The
  PortableGroup::Locations_var locations =
    load_manager->locations_of_members (object_group);

  const CORBA::ULong len = locations->length ();

  if (len == 0)
    throw CORBA::TRANSIENT ();

  TAO_LB_Location_Index_Map::ENTRY * entry;
  if (this->location_index_map_.find (id, entry) == 0)
    {
      CORBA::ULong & i = entry->int_id_;

      // The suggested location from previous next_member call
      // based on the previous location list. It may be invalid
      // if the list of locations are changed since then.
      // We need verify if the suggested location is still exist.
      // if it does, use it. Otherwise we need look the previous
      // location backwards one by one until we find an existing
      // one in current list then use the next location. If not
      // find a match, then start with 0 index.
      bool found = false;

      for (CORBA::ULong k = i; k > 0 && !found; --k)
      {
        for (CORBA::ULong j = 0; j < len && !found; ++j)
        {
          if (ACE_OS::strcmp (this->last_locations_[k][0].id.in (),
                              locations[j][0].id.in ()) == 0)
          {
            if (k == i)
            {
              i = j;
            }
            else
            {
              i = j + 1;
            }

            found = true;
          }
        }
      }

      if (!found)
        i = 0;

      if (len <= i)
        i = 0;  // Reset, i.e. wrap around

      // No need to release the lock since the LoadManager is
      // collocated.
      CORBA::Object_var member =
        load_manager->get_member_ref (object_group,
                                      locations[i]);

      // Increment index to point to next location.
      i++;

      // Keep a copy of location list for use in next next_member call.
      this->copy_locations (locations);
      return member._retn ();
    }

  // The first time through this method.  Set up for the next time
  // around, and return the object reference residing at the first
  // location in the "locations of members" sequence.

  // Note that it is safe to set the next_index below to 1 even if the
  // length of the sequence is 1 since the above code handles the
  // boundary case correctly by wrapping around.

  const CORBA::ULong index = 0;
  if (this->location_index_map_.bind (id, index + 1) != 0)
    throw CORBA::INTERNAL ();

  this->copy_locations (locations);
  return load_manager->get_member_ref (object_group,
                                       locations[index]);
}
コード例 #25
0
CORBA::Object_ptr
TAO_LB_ObjectReferenceFactory::make_object (
    const char * repository_id,
    const PortableInterceptor::ObjectId & id)
{
  if (repository_id == 0)
    throw CORBA::BAD_PARAM ();

  CORBA::Object_var obj =
    this->old_orf_->make_object (repository_id,
                                 id);

  PortableGroup::ObjectGroup_var object_group;

  CORBA::ULong index = 0;

  CORBA::Boolean const found_group =
    this->find_object_group (repository_id,
                             index,
                             object_group.out ());

  if (found_group)
    {
      // Be careful not to attempt duplicate registrations on
      // subsequent object reference creation calls.
      if (!this->registered_members_[index])
        {
          try
            {
              object_group =
                this->lm_->add_member (object_group.in (),
                                       this->location_,
                                       obj.in ());
            }
          catch (const PortableGroup::ObjectGroupNotFound& ex)
            {
              if (TAO_debug_level > 0)
                ex._tao_print_exception (
                  "TAO_LB_ObjectReferenceFactory::""make_object");

              throw CORBA::BAD_PARAM ();
            }
          catch (const PortableGroup::MemberAlreadyPresent& ex)
            {
              if (TAO_debug_level > 0)
                ex._tao_print_exception (
                  "TAO_LB_ObjectReferenceFactory::""make_object");

              throw CORBA::BAD_INV_ORDER ();

            }
          catch (const PortableGroup::ObjectNotAdded& ex)
            {
              if (TAO_debug_level > 0)
                ex._tao_print_exception (
                  "TAO_LB_ObjectReferenceFactory::""make_object");

              throw CORBA::UNKNOWN ();
            }

          this->registered_members_[index] = 1;
        }

      // Return the object group reference instead.
      return object_group._retn ();
    }

  // Not a load managed object.  Simply return the object's actual
  // object reference.
  return obj._retn ();
}