int DCPS_IR_Participant::find_publication_reference(OpenDDS::DCPS::RepoId pubId, DCPS_IR_Publication* & pub) { DCPS_IR_Publication_Map::iterator where = this->publications_.find(pubId); if (where != this->publications_.end()) { pub = where->second; if (OpenDDS::DCPS::DCPS_debug_level > 0) { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter pub_converter(pubId); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) DCPS_IR_Participant::find_publication_reference: ") ACE_TEXT("participant %C found publication %C at 0x%x.\n"), std::string(part_converter).c_str(), std::string(pub_converter).c_str(), pub)); } return 0; } else { if (OpenDDS::DCPS::DCPS_debug_level > 0) { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter pub_converter(pubId); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) DCPS_IR_Participant::find_publication_reference: ") ACE_TEXT("participant %C could not find publication %C.\n"), std::string(part_converter).c_str(), std::string(pub_converter).c_str())); } pub = 0; return -1; } }
int DCPS_IR_Participant::remove_publication(OpenDDS::DCPS::RepoId pubId) { DCPS_IR_Publication_Map::iterator where = this->publications_.find(pubId); if (where != this->publications_.end()) { DCPS_IR_Topic* topic = where->second->get_topic(); topic->remove_publication_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 pub_converter(pubId); ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Participant::remove_publication: ") ACE_TEXT("participant %C unable to remove associations from publication %C\n"), std::string(part_converter).c_str(), std::string(pub_converter).c_str())); return -1; } this->domain_->dispose_publication_bit(where->second); delete where->second; topic->release(false); this->publications_.erase(where); if (OpenDDS::DCPS::DCPS_debug_level > 0) { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter pub_converter(pubId); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) DCPS_IR_Participant::remove_publication: ") ACE_TEXT("participant %C removed publication %C.\n"), std::string(part_converter).c_str(), std::string(pub_converter).c_str())); } return 0; } else { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter pub_converter(pubId); ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Participant::remove_publication: ") ACE_TEXT("participant %C unable to remove publication %C.\n"), std::string(part_converter).c_str(), std::string(pub_converter).c_str())); return -1; } }
int DCPS_IR_Participant::add_publication(DCPS_IR_Publication* pub) { OpenDDS::DCPS::RepoId pubId = pub->get_id(); DCPS_IR_Publication_Map::iterator where = this->publications_.find(pubId); if (where == this->publications_.end()) { this->publications_.insert( where, DCPS_IR_Publication_Map::value_type(pubId, pub)); if (isBitPublisher_) { pub->set_bit_status(isBitPublisher_); } if (OpenDDS::DCPS::DCPS_debug_level > 0) { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter pub_converter(pubId); ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) DCPS_IR_Participant::add_publication: ") ACE_TEXT("participant %C successfully added publication %C at 0x%x.\n"), std::string(part_converter).c_str(), std::string(pub_converter).c_str(), pub)); } return 0; } else { if (OpenDDS::DCPS::DCPS_debug_level > 0) { OpenDDS::DCPS::RepoIdConverter part_converter(id_); OpenDDS::DCPS::RepoIdConverter pub_converter(pubId); ACE_ERROR((LM_NOTICE, ACE_TEXT("(%P|%t) NOTICE: DCPS_IR_Participant::add_publication: ") ACE_TEXT("participant %C attempted to add existing publication %C.\n"), std::string(part_converter).c_str(), std::string(pub_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())); } }
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(); }