int DCPS_IR_Participant::find_subscription_reference(OpenDDS::DCPS::RepoId subId, DCPS_IR_Subscription*& sub) { DCPS_IR_Subscription_Map::iterator where = this->subscriptions_.find(subId); if (where != this->subscriptions_.end()) { sub = where->second; if (OpenDDS::DCPS::DCPS_debug_level > 0) { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter sub_converter(subId); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) DCPS_IR_Participant::find_subscription_reference: ") ACE_TEXT("participant %C found subscription %C at 0x%x.\n"), std::string(part_converter).c_str(), std::string(sub_converter).c_str(), sub)); } return 0; } else { if (OpenDDS::DCPS::DCPS_debug_level > 0) { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter sub_converter(subId); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) DCPS_IR_Participant::find_subscription_reference: ") ACE_TEXT("participant %C could not find subscription %C.\n"), std::string(part_converter).c_str(), std::string(sub_converter).c_str())); } sub = 0; return -1; } }
int DCPS_IR_Participant::remove_subscription(OpenDDS::DCPS::RepoId subId) { DCPS_IR_Subscription_Map::iterator where = this->subscriptions_.find(subId); if (where != this->subscriptions_.end()) { DCPS_IR_Topic* topic = where->second->get_topic(); topic->remove_subscription_reference(where->second); if (0 != where->second->remove_associations(false)) { // N.B. As written today, this branch will never be taken. OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter sub_converter(subId); ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Participant::remove_subscription: ") ACE_TEXT("participant %C unable to remove associations from subscription %C\n"), std::string(part_converter).c_str(), std::string(sub_converter).c_str())); return -1; } this->domain_->dispose_subscription_bit(where->second); delete where->second; topic->release(false); this->subscriptions_.erase(where); if (OpenDDS::DCPS::DCPS_debug_level > 0) { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter sub_converter(subId); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) DCPS_IR_Participant::remove_subscription: ") ACE_TEXT("participant %C removed subscription %C.\n"), std::string(part_converter).c_str(), std::string(sub_converter).c_str())); } return 0; } else { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter sub_converter(subId); ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Participant::remove_subscription: ") ACE_TEXT("participant %C unable to remove subscription %C.\n"), std::string(part_converter).c_str(), std::string(sub_converter).c_str())); return -1; } }
int DCPS_IR_Participant::add_subscription(DCPS_IR_Subscription* sub) { OpenDDS::DCPS::RepoId subId = sub->get_id(); DCPS_IR_Subscription_Map::iterator where = this->subscriptions_.find(subId); if (where == this->subscriptions_.end()) { this->subscriptions_.insert( where, DCPS_IR_Subscription_Map::value_type(subId, sub)); if (isBitPublisher_) { sub->set_bit_status(isBitPublisher_); } if (OpenDDS::DCPS::DCPS_debug_level > 0) { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter sub_converter(subId); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) DCPS_IR_Participant::add_subscription: ") ACE_TEXT("participant %C successfully added subscription %C at 0x%x.\n"), std::string(part_converter).c_str(), std::string(sub_converter).c_str(), sub)); } return 0; } else { if (OpenDDS::DCPS::DCPS_debug_level > 0) { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter sub_converter(subId); ACE_ERROR((LM_NOTICE, ACE_TEXT("(%P|%t) NOTICE: DCPS_IR_Participant::add_subscription: ") ACE_TEXT("participant %C attempted to add existing subscription %C.\n"), std::string(part_converter).c_str(), std::string(sub_converter).c_str())); } return 1; } }
int OpenDDS::DCPS::ReceiveListenerSetMap::insert (RepoId publisher_id, RepoId subscriber_id, TransportReceiveListener* receive_listener) { DBG_ENTRY_LVL("ReceiveListenerSetMap","insert",6); ReceiveListenerSet_rch listener_set = this->find_or_create(publisher_id); if (listener_set.is_nil()) { // find_or_create failure GuidConverter converter(publisher_id); ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ReceiveListenerSetMap::insert: ") ACE_TEXT("failed to find_or_create entry for ") ACE_TEXT("publisher %C.\n"), OPENDDS_STRING(converter).c_str()), -1); } int result = listener_set->insert(subscriber_id, receive_listener); if (result == 0 || result == 1) { return 0; } GuidConverter sub_converter(subscriber_id); GuidConverter pub_converter(publisher_id); ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ReceiveListenerSetMap::insert: ") ACE_TEXT("failed to insert subscriber %C for ") ACE_TEXT("publisher %C.\n"), OPENDDS_STRING(sub_converter).c_str(), OPENDDS_STRING(pub_converter).c_str())); // Deal with possibility that the listener_set just got // created - and just for us. This is to make sure we don't leave any // empty ReceiveListenerSets in our map_. if (listener_set->size() == 0) { listener_set = this->remove_set(publisher_id); if (listener_set.is_nil()) { ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ReceiveListenerSetMap::insert: ") ACE_TEXT("failed to remove (undo create) ReceiveListenerSet ") ACE_TEXT("for publisher %C.\n"), OPENDDS_STRING(pub_converter).c_str())); } } return -1; }
OpenDDS::DCPS::DataLink* OpenDDS::DCPS::TransportImpl::reserve_datalink( RepoId local_id, const AssociationData* remote_association, CORBA::Long priority, TransportReceiveListener* receive_listener) { DBG_ENTRY_LVL("TransportImpl","reserve_datalink",6); // Ask our concrete subclass to find or create a DataLink (actually, a // concrete subclass of DataLink) that matches the supplied criterea. // Since find_or_create() is pure virtual, the concrete subclass must // provide an implementation for us to use. // Note that we pass-in false as the third argument. This means that // if a new DataLink needs to be created (ie, the find operation fails), // then the connection establishment logic will treat the local endpoint // as a subscriber. This knowledge dictates whether a passive or active // connection establishment procedure should be followed. DataLink_rch link = this->find_or_create_datalink(local_id, remote_association, priority, false); if (link.is_nil()) { OpenDDS::DCPS::RepoIdConverter pub_converter(remote_association->remote_id_); OpenDDS::DCPS::RepoIdConverter sub_converter(local_id); ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: TransportImpl::reserve_datalink: ") ACE_TEXT("subclass was unable to find ") ACE_TEXT("or create a DataLink for local subscriber_id %C ") ACE_TEXT("to remote publisher_id %C.\n"), std::string(sub_converter).c_str(), std::string(pub_converter).c_str()),0); } link->make_reservation(remote_association->remote_id_, // publication_id local_id, // subscription_id receive_listener); // This is called on the subscriber side to let the concrete // datalink to do some necessary work such as SimpleTcp will // send the FULLY_ASSOCIATED ack to the publisher. link->fully_associated(); return link._retn(); }
DCPS_IR_Participant::~DCPS_IR_Participant() { for (DCPS_IR_Subscription_Map::const_iterator current = this->subscriptions_.begin(); current != this->subscriptions_.end(); ++current) { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter sub_converter(current->first); ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Participant::~DCPS_IR_Participant: ") ACE_TEXT("domain %d participant %C removing subscription %C.\n"), this->domain_->get_id(), std::string(part_converter).c_str(), std::string(sub_converter).c_str())); remove_subscription(current->first); } for (DCPS_IR_Publication_Map::const_iterator current = this->publications_.begin(); current != this->publications_.end(); ++current) { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter pub_converter(current->first); ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Participant::~DCPS_IR_Participant: ") ACE_TEXT("domain %d participant %C removing publication %C.\n"), this->domain_->get_id(), std::string(part_converter).c_str(), std::string(pub_converter).c_str())); remove_publication(current->first); } for (DCPS_IR_Topic_Map::const_iterator current = this->topicRefs_.begin(); current != this->topicRefs_.end(); ++current) { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter topic_converter(current->first); ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Participant::~DCPS_IR_Participant: ") ACE_TEXT("domain %d participant %C retained topic %C.\n"), this->domain_->get_id(), std::string(part_converter).c_str(), std::string(topic_converter).c_str())); } }
std::string DCPS_IR_Domain::dump_to_string(const std::string& prefix, int depth) const { std::string str; #if !defined (OPENDDS_INFOREPO_REDUCED_FOOTPRINT) for (int i=0; i < depth; i++) str += prefix; std::string indent = str + prefix; std::ostringstream os; os << "DCPS_IR_Domain[" << id_ << "]"; str += os.str(); if (useBIT_) str += " BITS"; str += "\n"; str += indent + "Participants:\n"; for (DCPS_IR_Participant_Map::const_iterator pm = participants_.begin(); pm != participants_.end(); pm++) { str += pm->second->dump_to_string(prefix, depth+1); } str += indent + "Dead Participants:\n"; for (DCPS_IR_Participant_Set::const_iterator dp = deadParticipants_.begin(); dp != deadParticipants_.end(); dp++) { OpenDDS::DCPS::RepoIdConverter sub_converter((*dp)->get_id()); str += indent + std::string(sub_converter); str += "\n"; } str += indent + "Topic Descriptions:\n"; for (DCPS_IR_Topic_Description_Set::const_iterator tdi = topicDescriptions_.begin(); tdi != topicDescriptions_.end(); tdi++) { str += (*tdi)->dump_to_string(prefix, depth+1); } #endif // !defined (OPENDDS_INFOREPO_REDUCED_FOOTPRINT) return str; }
OpenDDS::DCPS::DataLink* OpenDDS::DCPS::TransportImpl::reserve_datalink( RepoId local_id, const AssociationData* remote_association, CORBA::Long priority, TransportSendListener* send_listener) { DBG_ENTRY_LVL("TransportImpl","reserve_datalink",6); // Ask our concrete subclass to find or create a (concrete) DataLink // that matches the supplied criterea. // Note that we pass-in true as the third argument. This means that // if a new DataLink needs to be created (ie, the find operation fails), // then the connection establishment logic will treat the local endpoint // as the publisher. This knowledge dictates whether a passive or active // connection establishment procedure should be followed. DataLink_rch link = this->find_or_create_datalink(local_id, remote_association, priority, true); if (link.is_nil()) { OpenDDS::DCPS::RepoIdConverter pub_converter(local_id); OpenDDS::DCPS::RepoIdConverter sub_converter(remote_association->remote_id_); ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: TransportImpl::reserve_datalink: ") ACE_TEXT("subclass was unable to find ") ACE_TEXT("or create a DataLink for local publisher_id %C ") ACE_TEXT("to remote subscriber_id %C.\n"), std::string(pub_converter).c_str(), std::string(sub_converter).c_str()),0); } link->make_reservation(remote_association->remote_id_, // subscription_id local_id, // publication_id send_listener); return link._retn(); }