void FT_ReplicaFactory_i::delete_object ( const PortableGroup::GenericFactory::FactoryCreationId & factory_creation_id) { METHOD_ENTRY(FT_ReplicaFactory_i::delete_object); ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_); CORBA::ULong factoryId; factory_creation_id >>= factoryId; if (factoryId < this->replicas_.size()) { if(this->replicas_[factoryId] != 0) { this->replicas_[factoryId]->request_quit(); } else { throw ::PortableGroup::ObjectNotFound(); } } else { throw ::PortableGroup::ObjectNotFound(); } METHOD_RETURN(FT_ReplicaFactory_i::delete_object); }
::PortableGroup::FactoryInfos * TAO::PG_FactoryRegistry::list_factories_by_role ( const char * role, CORBA::String_out type_id) { METHOD_ENTRY(TAO::PG_FactoryRegistry::list_factories_by_role); // allocate stucture to be returned. PortableGroup::FactoryInfos_var result = 0; ACE_NEW_THROW_EX (result, ::PortableGroup::FactoryInfos(), CORBA::NO_MEMORY (TAO::VMCID, CORBA::COMPLETED_NO)); RoleInfo * role_info = 0; if (this->registry_.find(role, role_info) == 0) { type_id = CORBA::string_dup(role_info->type_id_.c_str()); (*result) = role_info->infos_; } else { type_id = CORBA::string_dup(""); ORBSVCS_ERROR(( LM_INFO, "%s: list_factories_by_role: unknown role %s\n", this->identity_.c_str(), role )); } METHOD_RETURN(TAO::PG_FactoryRegistry::list_factories_by_role) result._retn(); }
FT::FaultNotifier::ConsumerId TAO::FT_FaultNotifier_i::connect_sequence_fault_consumer ( CosNotifyComm::SequencePushConsumer_ptr push_consumer, CosNotifyFilter::Filter_ptr filter ) { METHOD_ENTRY(TAO::FT_FaultNotifier_i::connect_sequence_fault_consumer); ///////////////////////// // find a ProxyInfo entry // use the first nil entry or a new entry if no nils found size_t infoPos = 0; int looking = 1; for ( size_t pos = 0; looking && pos < this->proxy_infos_.size (); ++pos) { ProxyInfo & pi = this->proxy_infos_[pos]; if (CORBA::is_nil(pi.proxyVar_.in ())) { infoPos = pos; looking = 0; } } if (looking) { infoPos = this->proxy_infos_.size(); this->proxy_infos_.push_back(ProxyInfo()); } /////////////////////////////////////// // Assign an ID, populate the ProxyInfo FT::FaultNotifier::ConsumerId result = infoPos; ProxyInfo & info = this->proxy_infos_[infoPos]; info.proxyVar_ = this->consumer_admin_->obtain_notification_push_supplier ( ::CosNotifyChannelAdmin::SEQUENCE_EVENT, info.proxyId_); this->consumer_connects_ += 1; ::CosNotifyChannelAdmin::SequenceProxyPushSupplier_var proxySupplier = ::CosNotifyChannelAdmin::SequenceProxyPushSupplier::_narrow(info.proxyVar_.in ()); if ( CORBA::is_nil (proxySupplier.in ())) { // this is a shoould-not-occur situation. The consumer admin returned // the wrong kind of object. ORBSVCS_ERROR(( LM_ERROR, "%T %n (%P|%t) Unexpected result: Wrong type of object returned from obtain_notification_push_supplier\n" )); } else { proxySupplier->connect_sequence_push_consumer ( push_consumer); if (! CORBA::is_nil (filter)) { proxySupplier->add_filter(filter); } } METHOD_RETURN(TAO::FT_FaultNotifier_i::connect_sequence_fault_consumer) result; }
void FT_ReplicaFactory_i::shutdown (void) { METHOD_ENTRY(FT_FaultDetectorFactory_i::shutdown); ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_); shutdown_i (); this->quit_requested_ = 1; METHOD_RETURN(FT_FaultDetectorFactory_i::shutdown); }
void TAO::FT_FaultNotifier_i::push_sequence_fault ( const CosNotification::EventBatch & events ) { METHOD_ENTRY(TAO::FT_FaultNotifier_i::push_sequence_fault); this->sequence_proxy_push_consumer_->push_structured_events (events); METHOD_RETURN(TAO::FT_FaultNotifier_i::push_sequence_fault); }
void TAO::FT_FaultNotifier_i::push_structured_fault ( const CosNotification::StructuredEvent & event ) { METHOD_ENTRY(TAO::FT_FaultNotifier_i::push_structured_fault); this->structured_proxy_push_consumer_->push_structured_event (event); METHOD_RETURN(TAO::FT_FaultNotifier_i::push_structured_fault); }
::CosNotifyFilter::Filter_ptr TAO::FT_FaultNotifier_i::create_subscription_filter ( const char * constraint_grammar ) { METHOD_ENTRY(TAO::FT_FaultNotifier_i::create_subscription_filter); ACE_UNUSED_ARG (constraint_grammar); //@@todo CosNotifyFilter::Filter_var filter = this->filter_factory_->create_filter ("ETCL"); METHOD_RETURN(TAO::FT_FaultNotifier_i::create_subscription_filter) filter._retn (); }
void TAO::PG_FactoryRegistry::unregister_factory_by_role ( const char * role ) { METHOD_ENTRY(TAO::PG_FactoryRegistry::unregister_factory_by_role); RoleInfo * role_info = 0; if (this->registry_.unbind(role, role_info) == 0) { ORBSVCS_DEBUG(( LM_DEBUG, "%s: Unregistering all factories for role %s\n", this->identity_.c_str(), role )); // delete the entire set of factories for this location. delete role_info; } else { ORBSVCS_ERROR(( LM_INFO, "%s: Unregister_factory_by_role: unknown role: %s\n", this->identity_.c_str(), role )); } ///////////////////// // Function complete // check quit options if (registry_.current_size() == 0 && quit_state_ == LIVE) { ORBSVCS_ERROR(( LM_INFO, "%s is idle\n", identity() )); if (quit_on_idle_) { this->poa_->deactivate_object (this->object_id_.in ()); quit_state_ = DEACTIVATED; } } METHOD_RETURN(TAO::PG_FactoryRegistry::unregister_factory_by_role); }
::PortableGroup::FactoryInfos * TAO::PG_FactoryRegistry::list_factories_by_location ( const PortableGroup::Location & location ) { METHOD_ENTRY(TAO::PG_FactoryRegistry::list_factories_by_location); ::PortableGroup::FactoryInfos_var result; ACE_NEW_THROW_EX ( result, ::PortableGroup::FactoryInfos( static_cast<CORBA::ULong> (this->registry_.current_size())), CORBA::NO_MEMORY (TAO::VMCID, CORBA::COMPLETED_NO)); size_t result_length = 0; // iterate through the registery for (RegistryType_Iterator it = this->registry_.begin(); it != this->registry_.end(); ++it) { RegistryType_Entry & entry = *it; RoleInfo * role_info = entry.int_id_; PortableGroup::FactoryInfos & found_infos = role_info->infos_; // iterate through the entry for this type int found = 0; CORBA::ULong length = found_infos.length(); for (CORBA::ULong nInfo = 0u; !found && nInfo < length; ++nInfo) { PortableGroup::FactoryInfo & info = found_infos[nInfo]; if (info.the_location == location) { found = 1; result_length += 1; result->length (static_cast<CORBA::ULong> (result_length)); (*result)[static_cast<CORBA::ULong> (result_length-1u)] = info; } } } METHOD_RETURN(TAO::PG_FactoryRegistry::list_factories_by_location) result._retn(); }
CORBA::Boolean TAO::FT_FaultNotifier_i::is_alive (void) { METHOD_RETURN(TAO::FT_FaultNotifier_i::is_alive) 1; }
void TAO::FT_FaultNotifier_i::disconnect_consumer ( FT::FaultNotifier::ConsumerId connection ) { METHOD_ENTRY(TAO::FT_FaultNotifier_i::disconnect_consumer); size_t index = static_cast<size_t> (connection); if (index < this->proxy_infos_.size()) { ProxyInfo & info = this->proxy_infos_[index]; if (CORBA::is_nil(info.proxyVar_.in ()) ) { throw CosEventComm::Disconnected(); } else { ::CosNotifyChannelAdmin::StructuredProxyPushSupplier_var proxySupplier = ::CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow(info.proxyVar_.in ()); if (! CORBA::is_nil (proxySupplier.in ())) { proxySupplier->disconnect_structured_push_supplier (); info.proxyVar_ = ::CosNotifyChannelAdmin::ProxySupplier::_nil(); } else { ::CosNotifyChannelAdmin::SequenceProxyPushSupplier_var proxySupplier = ::CosNotifyChannelAdmin::SequenceProxyPushSupplier::_narrow(info.proxyVar_.in ()); if (! CORBA::is_nil (proxySupplier.in ())) { proxySupplier->disconnect_sequence_push_supplier (); info.proxyVar_ = ::CosNotifyChannelAdmin::ProxySupplier::_nil(); } else { ORBSVCS_ERROR((LM_ERROR, "%T %n (%P|%t) Unexpected proxy supplier type\n" )); throw CosEventComm::Disconnected(); } } } } else { throw CosEventComm::Disconnected(); } this->consumer_disconnects_ += 1; if (this->quit_on_idle_) { if (! this->quitting_ && this->consumer_connects_ == this->consumer_disconnects_) { ORBSVCS_ERROR((LM_ERROR, "FaultNotifier (%P|%t) quit on idle: connects %d, disconnects %d\n", static_cast<unsigned int> (this->consumer_connects_), static_cast<unsigned int> (this->consumer_disconnects_) )); this->poa_->deactivate_object (this->object_id_.in ()); this->quitting_ = 1; } } METHOD_RETURN(TAO::FT_FaultNotifier_i::disconnect_consumer); }
CORBA::Boolean FT_ReplicaFactory_i::is_alive (void) { METHOD_RETURN(FT_ReplicaFactory_i::is_alive) true; }
CORBA::Object_ptr FT_ReplicaFactory_i::create_object ( const char * type_id, const PortableGroup::Criteria & the_criteria, PortableGroup::GenericFactory::FactoryCreationId_out factory_creation_id) { METHOD_ENTRY(FT_ReplicaFactory_i::create_object); ACE_UNUSED_ARG (type_id); ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->internals_, CORBA::Object::_nil ()); ::TAO::PG_Property_Set decoder (the_criteria); // boolean, becomes true if a required parameter is missing int missingParameter = 0; const char * missingParameterName = 0; CORBA::Long initialValue = 0; if (! ::TAO::find (decoder, criterion_initial_value, initialValue) ) { // not required. Otherwise: // missingParameter = 1; // missingParameterName = criterion_initial_value; } const char * role = "replica"; if (! ::TAO::find (decoder, PortableGroup::role_criterion, role) ) { ACE_ERROR((LM_INFO, "Property \"%s\" not found?\n", PortableGroup::role_criterion )); // not required. Otherwise: // missingParameter = 1; // missingParameterName = PortableGroup::role_criterion; } if (missingParameter) { ACE_ERROR ((LM_ERROR, "Throwing 'InvalidCriteria' due to missing %s\n", missingParameterName )); throw PortableGroup::InvalidCriteria(); } FT_TestReplica_i * replica = create_replica(role); if (replica == 0) { ACE_ERROR ((LM_ERROR, "New Replica_i returned NULL. Throwing ObjectNotCreated.\n" )); throw PortableGroup::ObjectNotCreated(); } ACE_NEW_THROW_EX ( factory_creation_id, PortableGroup::GenericFactory::FactoryCreationId, PortableGroup::ObjectNotCreated()); CORBA::ULong factory_id = replica->factory_id(); (*factory_creation_id) <<= factory_id; ACE_ERROR ((LM_INFO, "Created %s@%C#%d.\n", role, this->location_.c_str (), static_cast<int> (factory_id) )); ::CORBA::Object_ptr replica_obj = replica->_default_POA()->servant_to_reference(replica); METHOD_RETURN(FT_ReplicaFactory_i::create_object) replica_obj->_duplicate(replica_obj); }
void TAO::PG_FactoryRegistry::unregister_factory_by_location ( const PortableGroup::Location & location) { METHOD_ENTRY(TAO::PG_FactoryRegistry::unregister_factory_by_location); //////////////////////////////////////////// // a vector of roles that need to be deleted. ACE_Vector<ACE_CString> emptyRoles; // iterate through the registery for (RegistryType_Iterator it = this->registry_.begin(); it != this->registry_.end(); ++it) { RegistryType_Entry & entry = *it; ACE_CString & role = entry.ext_id_; RoleInfo * role_info = entry.int_id_; PortableGroup::FactoryInfos & infos = role_info->infos_; // ORBSVCS_ERROR((LM_INFO, "unregister_factory_by_location: Checking role %s\n", role.c_str() )); int found = 0; CORBA::ULong length = infos.length(); for (CORBA::ULong nInfo = 0u; !found && nInfo < length; ++nInfo) { PortableGroup::FactoryInfo & info = infos[nInfo]; if (info.the_location == location) { ORBSVCS_ERROR((LM_INFO, "%s: Unregister_factory_by_location: Removing: [%d] %s@%s\n", this->identity_.c_str(), static_cast<int> (nInfo), role.c_str(), static_cast<const char *> (location[0].id) )); found = 1; if (length > 1) { while (nInfo + 1 < length) { ORBSVCS_ERROR((LM_INFO, "%s: Unregister_factory_by_location: Move: [%d] %s to [%d]\n", this->identity_.c_str(), (int)nInfo + 1, role.c_str(), (int)nInfo )); infos[nInfo] = infos[nInfo + 1]; nInfo += 1; } ORBSVCS_ERROR((LM_INFO, "%s: unregister_factory_by_location: New length [%d] %s\n", this->identity_.c_str(), (int)nInfo, role.c_str() )); infos.length(nInfo); } else { ORBSVCS_ERROR((LM_INFO, "%s: Removed all entries for %s\n", this->identity_.c_str(), role.c_str() )); ACE_ASSERT ( length == 1 ); // remember entries to be deleted emptyRoles.push_back(entry.ext_id_); } } } } // now remove any roles that became empty for (size_t nRole = 0; nRole < emptyRoles.size(); ++nRole) { ORBSVCS_ERROR((LM_INFO, "%s: Remove role %s\n", this->identity_.c_str(), emptyRoles[nRole].c_str() )); RoleInfo * role_info; if (this->registry_.unbind(emptyRoles[nRole], role_info) == 0) { delete role_info; } else { ORBSVCS_ERROR ((LM_ERROR, "%s: LOGIC ERROR AT " __FILE__ " (%d): Role to be deleted disappeared\n", this->identity_.c_str(), __LINE__)); } } ////////////////////////// // If all types are gone... if (registry_.current_size() == 0 && quit_state_ == LIVE) { ORBSVCS_ERROR(( LM_INFO, "%s is idle\n", identity() )); if (quit_on_idle_) { this->poa_->deactivate_object (this->object_id_.in ()); quit_state_ = DEACTIVATED; } } METHOD_RETURN(TAO::PG_FactoryRegistry::unregister_factory_by_location); }
void TAO::PG_FactoryRegistry::unregister_factory ( const char * role, const PortableGroup::Location & location) { METHOD_ENTRY(TAO::PG_FactoryRegistry::unregister_factory); RoleInfo * role_info = 0; if (this->registry_.find(role, role_info) == 0) { PortableGroup::FactoryInfos & infos = role_info->infos_; int found = 0; CORBA::ULong length = infos.length(); for (CORBA::ULong nInfo = 0u; !found && nInfo < length; ++nInfo) { PortableGroup::FactoryInfo & info = infos[nInfo]; if (info.the_location == location) { found = 1; ORBSVCS_ERROR(( LM_INFO, "%s: Unregistering factory %s@%s\n", this->identity_.c_str(), role, static_cast<const char *> (location[0].id) )); if (length > 1) { // if this is not the last entry if (nInfo + 1 < length) { // move last entry into newly-emptied slot infos[nInfo] = infos[length - 1]; nInfo = length -1; } infos.length(nInfo); } else { ACE_ASSERT ( length == 1 ); if (this->registry_.unbind (role) == 0) { ORBSVCS_DEBUG(( LM_INFO, "%s: No more factories registered for %s\n", this->identity_.c_str(), role )); delete role_info; } else { ORBSVCS_ERROR ((LM_ERROR, "%s: LOGIC ERROR AT " __FILE__ " (%d): Entry to be deleted disappeared\n", this->identity_.c_str(), __LINE__)); } } } } } else { ORBSVCS_ERROR(( LM_ERROR, "%s, Attempt to unregister factory for unknown role %s\n", this->identity_.c_str(), role )); throw PortableGroup::MemberNotFound(); } ////////////////////// // request complete // check quit-on-idle if (registry_.current_size() == 0 && quit_state_ == LIVE) { ORBSVCS_ERROR(( LM_INFO, "%s is idle\n", identity() )); if (quit_on_idle_) { this->poa_->deactivate_object (this->object_id_.in ()); quit_state_ = DEACTIVATED; } } METHOD_RETURN(TAO::PG_FactoryRegistry::unregister_factory); }
void TAO::PG_FactoryRegistry::register_factory ( const char * role, const char * type_id, const PortableGroup::FactoryInfo & factory_info) { METHOD_ENTRY(TAO::PG_FactoryRegistry::register_factory); RoleInfo * role_info = 0; auto_ptr<RoleInfo> safe_entry; if (this->registry_.find(role, role_info) != 0) { ORBSVCS_DEBUG(( LM_DEBUG, "%s: adding new role: %s:%s\n", this->identity_.c_str(), role, type_id)); // Note the 5. It's a guess about the number of factories // that might exist for any particular role object. // todo: make it a parameter. ACE_NEW_THROW_EX (role_info, RoleInfo(5), CORBA::NO_MEMORY()); ACE_auto_ptr_reset (safe_entry, role_info); role_info->type_id_ = type_id; } else { if (role_info->type_id_ != type_id) { throw PortableGroup::TypeConflict(); } } PortableGroup::FactoryInfos & infos = role_info->infos_;; CORBA::ULong length = infos.length(); for (CORBA::ULong nInfo = 0u; nInfo < length; ++nInfo) { PortableGroup::FactoryInfo & info = infos[nInfo]; if (info.the_location == factory_info.the_location) { ORBSVCS_ERROR(( LM_ERROR, "%s: Attempt to register duplicate location %s for role: %s\n" , this->identity_.c_str(), static_cast<const char *> (info.the_location[0].id), role)); throw PortableGroup::MemberAlreadyPresent(); } } infos.length(length + 1); infos[length] = factory_info; if (safe_entry.get() != 0) { this->registry_.bind(role, safe_entry.release()); } ORBSVCS_DEBUG(( LM_DEBUG, "%s: Added factory: [%d] %s@%s\n", this->identity_.c_str(), static_cast<int> (length + 1), role, static_cast<const char *> (factory_info.the_location[0].id) )); METHOD_RETURN(TAO::PG_FactoryRegistry::register_factory); }