TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_NotifyLogNotification::TAO_NotifyLogNotification ( CosNotifyChannelAdmin::EventChannel_ptr ec) : TAO_LogNotification (), event_channel_ (CosNotifyChannelAdmin::EventChannel::_duplicate (ec)) { CosNotifyComm::PushSupplier_var objref = this->_this (); ACE_ASSERT (!CORBA::is_nil (objref.in ())); CosNotifyChannelAdmin::AdminID adminID; CosNotifyChannelAdmin::SupplierAdmin_var supplier_admin = this->event_channel_->new_for_suppliers (CosNotifyChannelAdmin::OR_OP, adminID); ACE_ASSERT (!CORBA::is_nil (supplier_admin.in ())); CosNotifyChannelAdmin::ProxyConsumer_var proxyconsumer = supplier_admin->obtain_notification_push_consumer (CosNotifyChannelAdmin::ANY_EVENT, proxy_consumer_id_); ACE_ASSERT (!CORBA::is_nil (proxyconsumer.in ())); // narrow this->proxy_consumer_ = CosNotifyChannelAdmin::ProxyPushConsumer::_narrow (proxyconsumer.in ()); ACE_ASSERT (!CORBA::is_nil (this->proxy_consumer_.in ())); proxy_consumer_->connect_any_push_supplier (objref.in ()); }
void TAO_Notify_ThreadPool_Supplier::connect (void) { // Activate the supplier object. CosNotifyComm::StructuredPushSupplier_var objref = this->_this (); CosNotifyChannelAdmin::ProxyConsumer_var proxyconsumer; if (this->proxy_consumer_thread_count_ != 0) { // Narrow to the extended interface. NotifyExt::SupplierAdmin_var admin_ext = NotifyExt::SupplierAdmin::_narrow (this->admin_.in ()); NotifyExt::ThreadPoolParams tp_params = { NotifyExt::CLIENT_PROPAGATED, 0, 0, static_cast<CORBA::ULong> (this->proxy_consumer_thread_count_), 0, 0, 0, 0, 0 }; CosNotification::QoSProperties qos (1); qos.length (1); qos[0].name = CORBA::string_dup (NotifyExt::ThreadPool); qos[0].value <<= tp_params; // Obtain the proxy. The QoS is applied to the POA in which the Proxy is hosted. proxyconsumer = admin_ext->obtain_notification_push_consumer_with_qos (CosNotifyChannelAdmin::STRUCTURED_EVENT , proxy_consumer_id_, qos); } else { // Obtain the proxy. proxyconsumer = this->admin_->obtain_notification_push_consumer (CosNotifyChannelAdmin::STRUCTURED_EVENT , proxy_consumer_id_); } ACE_ASSERT (!CORBA::is_nil (proxyconsumer.in ())); // narrow this->proxy_consumer_ = CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow (proxyconsumer.in ()); ACE_ASSERT (!CORBA::is_nil (proxy_consumer_.in ())); // connect to the proxyconsumer. proxy_consumer_->connect_structured_push_supplier (objref.in ()); ACE_DEBUG ((LM_DEBUG, "(%P,%t) Created Supplier %d with %d threads at the ProxyConsumer\n", proxy_consumer_id_, this->proxy_consumer_thread_count_)); }
void Filter_StructuredPushSupplier::connect (CosNotifyChannelAdmin::SupplierAdmin_ptr supplier_admin) { CosNotifyComm::StructuredPushSupplier_var objref = this->_this (); CosNotifyChannelAdmin::ProxyConsumer_var proxyconsumer = supplier_admin->obtain_notification_push_consumer (CosNotifyChannelAdmin::STRUCTURED_EVENT, proxy_consumer_id_); ACE_ASSERT (!CORBA::is_nil (proxyconsumer.in ())); // narrow this->proxy_consumer_ = CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow (proxyconsumer.in ()); ACE_ASSERT (!CORBA::is_nil (proxy_consumer_.in ())); proxy_consumer_->connect_structured_push_supplier (objref.in ()); }
void TAO_Notify_Lanes_Supplier::connect (void) { // Activate the supplier object. CosNotifyComm::StructuredPushSupplier_var objref = this->_this (); // Obtain the proxy. CosNotifyChannelAdmin::ProxyConsumer_var proxyconsumer = this->admin_->obtain_notification_push_consumer (CosNotifyChannelAdmin::STRUCTURED_EVENT , proxy_consumer_id_); ACE_ASSERT (!CORBA::is_nil (proxyconsumer.in ())); // narrow this->proxy_consumer_ = CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow (proxyconsumer.in ()); ACE_ASSERT (!CORBA::is_nil (proxy_consumer_.in ())); // connect to the proxyconsumer. proxy_consumer_->connect_structured_push_supplier (objref.in ()); }
void Notify_Push_Supplier::_connect ( CosNotifyChannelAdmin::SupplierAdmin_ptr supplier_admin, CosNotifyChannelAdmin::EventChannel_ptr notify_channel, bool useFilter) { CosNotifyComm::StructuredPushSupplier_var objref = this->_this (); CosNotifyChannelAdmin::ProxyConsumer_var proxyconsumer = supplier_admin->obtain_notification_push_consumer ( CosNotifyChannelAdmin::STRUCTURED_EVENT, proxy_id_); if (useFilter) { CosNotifyFilter::FilterFactory_var ffact = notify_channel->default_filter_factory (); CosNotifyFilter::Filter_var filter = ffact->create_filter ("TCL"); ACE_ASSERT(! CORBA::is_nil (filter.in ())); CosNotifyFilter::ConstraintExpSeq constraint_list (1); constraint_list.length (1); constraint_list[0].event_types.length (0); constraint_list[0].constraint_expr = CORBA::string_dup ("group != 0"); filter->add_constraints (constraint_list); proxyconsumer->add_filter (filter.in ()); } this->proxy_ = CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow ( proxyconsumer.in ()); this->proxy_->connect_structured_push_supplier (objref.in ()); // give ownership to POA this->_remove_ref (); }
int ACE_TMAIN (int argc, ACE_TCHAR* argv[]) { #if defined (TAO_HAS_MONITOR_FRAMEWORK) && (TAO_HAS_MONITOR_FRAMEWORK == 1) try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in ()); PortableServer::POAManager_var poa_manager = poa->the_POAManager (); poa_manager->activate (); TAO_Notify_Service* notify_service = TAO_Notify_Service::load_default (); if (notify_service == 0) { error ("Unable to load the Notify Service"); } notify_service->init_service (orb.in ()); ACE_OS::sleep (1); const ACE_CString ecf_name ("MonitoringEventChannelFactory"); CosNotifyChannelAdmin::EventChannelFactory_var ecf = notify_service->create (poa.in (), ecf_name.c_str ()); NotifyMonitoringExt::EventChannelFactory_var monitor_ec_factory = NotifyMonitoringExt::EventChannelFactory::_narrow (ecf.in ()); if (CORBA::is_nil (monitor_ec_factory.in ())) { error ("Unable to create the Monitoring Event Channel Factory"); } CosNotification::QoSProperties qos_prop; CosNotification::AdminProperties admin_prop; CosNotifyChannelAdmin::ChannelID id; const ACE_CString ec_name ("test1"); CosNotifyChannelAdmin::EventChannel_var ec = monitor_ec_factory->create_named_channel (qos_prop, admin_prop, id, ec_name.c_str ()); NotifyMonitoringExt::EventChannel_var mec = NotifyMonitoringExt::EventChannel::_narrow (ec.in ()); if (CORBA::is_nil (mec.in ())) { error ("Unable to narrow the event channel"); } try { CosNotifyChannelAdmin::ChannelID fake_id; CosNotifyChannelAdmin::EventChannel_var fake = monitor_ec_factory->create_named_channel (qos_prop, admin_prop, fake_id, "test1"); error ("Expected a NotifyMonitoringExt::" "NameAlreadyUsed exception"); } catch (const NotifyMonitoringExt::NameAlreadyUsed&) { // This is expected. } Monitor_Point_Registry* instance = Monitor_Point_Registry::instance (); ACE_CString stat_name = ecf_name + "/" + ACE_CString (NotifyMonitoringExt::InactiveEventChannelCount); Monitor_Base* stat = instance->get (stat_name); if (stat == 0) { error ("Could not find InactiveEventChannelCount statistic"); } stat->update (); double count = stat->last_sample (); if (!ACE::is_equal (count, 1.0)) { error ("Invalid inactive event channel count"); } stat_name = ecf_name + "/" + ACE_CString (NotifyMonitoringExt::ActiveEventChannelCount); stat = instance->get (stat_name); if (stat == 0) { error ("Could not find ActiveEventChannelCount statistic"); } stat->update (); count = stat->last_sample (); if (!ACE::is_equal (count, 0.0)) { error ("Invalid active event channel count"); } stat_name = ecf_name + "/" + ACE_CString (NotifyMonitoringExt::InactiveEventChannelNames); stat = instance->get (stat_name); if (stat == 0) { error ("Could not find InactiveEventChannels statistic"); } stat->update (); Monitor_Control_Types::NameList list = stat->get_list (); if (list.size () != 1) { error ("Invalid inactive event channel list"); } ACE_CString full_ec_name (ecf_name + "/" + ec_name); if (list[0] != full_ec_name) { error ("Wrong event channel name"); } CosNotifyChannelAdmin::AdminID aid; CosNotifyChannelAdmin::SupplierAdmin_var admin = mec->named_new_for_suppliers (CosNotifyChannelAdmin::AND_OP, aid, "TestSupplierAdmin"); try { admin = mec->named_new_for_suppliers (CosNotifyChannelAdmin::AND_OP, aid, "TestSupplierAdmin"); error ("Expected a SupplierAdmin " "NotifyMonitoringExt::NameAlreadyUsed exception"); } catch (const NotifyMonitoringExt::NameAlreadyUsed&) { // This is expected. }; // We should be able to create another one with the same name. admin->destroy (); admin = mec->named_new_for_suppliers (CosNotifyChannelAdmin::AND_OP, aid, "TestSupplierAdmin"); NotifyMonitoringExt::SupplierAdmin_var madmin = NotifyMonitoringExt::SupplierAdmin::_narrow (admin.in ()); if (CORBA::is_nil (madmin.in ())) { error ("Could not narrow the supplier admin"); } CosNotifyChannelAdmin::ProxyID pid; CosNotifyChannelAdmin::ProxyConsumer_var conproxy = madmin->obtain_named_notification_push_consumer ( CosNotifyChannelAdmin::STRUCTURED_EVENT, pid, "supplier"); try { CosNotifyChannelAdmin::ProxyConsumer_var fake = madmin->obtain_named_notification_push_consumer (CosNotifyChannelAdmin::STRUCTURED_EVENT, pid, "supplier"); error ("Expected a ProxyConsumer " "NotifyMonitoringExt::NameAlreadyUsed exception"); } catch (const NotifyMonitoringExt::NameAlreadyUsed&) { // This is expected. } stat_name = ecf_name + "/" + ec_name + "/" + ACE_CString (NotifyMonitoringExt::EventChannelSupplierCount); stat = instance->get (stat_name); if (stat == 0) { error ("Could not find the event channel suppliers statistic"); } stat->update (); count = stat->last_sample (); if (!ACE::is_equal (count, 1.0)) { error ("Invalid supplier count"); } CosNotifyChannelAdmin::StructuredProxyPushConsumer_var push_conproxy = CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow ( conproxy.in ()); ACE_ASSERT (!CORBA::is_nil (push_conproxy.in ())); push_conproxy->disconnect_structured_push_consumer (); try { CosNotifyChannelAdmin::ProxyConsumer_var fake = madmin->obtain_named_notification_push_consumer ( CosNotifyChannelAdmin::STRUCTURED_EVENT, pid, "supplier"); } catch (const NotifyMonitoringExt::NameAlreadyUsed&) { error ("Unexpected ProxyConsumer " "NotifyMonitoringExt::NameAlreadyUsed exception"); } CosNotifyChannelAdmin::ConsumerAdmin_var cadmin = mec->named_new_for_consumers (CosNotifyChannelAdmin::AND_OP, aid, "TestConsumerAdmin"); try { cadmin = mec->named_new_for_consumers (CosNotifyChannelAdmin::AND_OP, aid, "TestConsumerAdmin"); error ("Expected a ConsumerAdmin " "NotifyMonitoringExt::NameAlreadyUsed exception"); } catch (const NotifyMonitoringExt::NameAlreadyUsed&) { // This is expected. }; // We should be able to create another one with the same name cadmin->destroy (); cadmin = mec->named_new_for_consumers (CosNotifyChannelAdmin::AND_OP, aid, "TestConsumerAdmin"); NotifyMonitoringExt::ConsumerAdmin_var mcadmin = NotifyMonitoringExt::ConsumerAdmin::_narrow (cadmin.in ()); if (CORBA::is_nil (mcadmin.in ())) { error ("Could not narrow the consumer admin"); } CosNotifyChannelAdmin::ProxySupplier_var supproxy = mcadmin->obtain_named_notification_push_supplier ( CosNotifyChannelAdmin::STRUCTURED_EVENT, pid, "consumer"); try { CosNotifyChannelAdmin::ProxySupplier_var fake = mcadmin->obtain_named_notification_push_supplier ( CosNotifyChannelAdmin::STRUCTURED_EVENT, pid, "consumer"); error ("Expected a ProxySupplier " "NotifyMonitoringExt::NameAlreadyUsed exception"); } catch (const NotifyMonitoringExt::NameAlreadyUsed&) { // This is expected. } stat_name = ecf_name + "/" + ec_name + "/" + ACE_CString (NotifyMonitoringExt::EventChannelConsumerCount); stat = instance->get (stat_name); if (stat == 0) { error ("Could not find the event channel consumers statistic"); } stat->update (); count = stat->last_sample (); if (!ACE::is_equal (count, 1.0)) { error ("Invalid consumer count"); } CosNotifyChannelAdmin::StructuredProxyPushSupplier_var push_supproxy = CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow ( supproxy.in()); ACE_ASSERT (!CORBA::is_nil (push_supproxy.in ())); push_supproxy->disconnect_structured_push_supplier (); try { CosNotifyChannelAdmin::ProxySupplier_var fake = mcadmin->obtain_named_notification_push_supplier ( CosNotifyChannelAdmin::STRUCTURED_EVENT, pid, "consumer"); } catch (const NotifyMonitoringExt::NameAlreadyUsed&) { error ("Unexpected ProxySupplier " "NotifyMonitoringExt::NameAlreadyUsed exception"); } TAO_MonitorManager::shutdown (); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("MonitorControlExt: "); } catch (...) { error ("Caught an unexpected exception type"); } #else /* ACE_HAS_MONITOR_FRAMEWORK==1 */ ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); #endif /* TAO_HAS_MONITOR_FRAMEWORK==1 */ return 0; }
void Supplier_Main::init_any_proxy_consumer (void) { bool ok = false; CosNotifyChannelAdmin::ProxyConsumer_var proxy; if (this->reconnecting_) { try { proxy = this->sa_->get_proxy_consumer( this->any_proxy_id_); ok = ! CORBA::is_nil (proxy.in ()); if (ok && this->verbose_) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Supplier: Reconnect to proxy %d\n"), static_cast<int>(this->any_proxy_id_) )); } } catch (...) { } } if (!ok) { proxy = this->sa_->obtain_notification_push_consumer( CosNotifyChannelAdmin::ANY_EVENT, this->any_proxy_id_); ok = ! CORBA::is_nil (proxy.in ()); if (ok && this->verbose_) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Supplier: Create new proxy %d\n"), static_cast<int>(this->any_proxy_id_) )); } } this->any_proxy_push_consumer_ = CosNotifyChannelAdmin::ProxyPushConsumer::_narrow(proxy.in ()); if (CORBA::is_nil (this->any_proxy_push_consumer_.in ())) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) Supplier: Received wrong type of push consumer proxy %d\n"), static_cast<int>(this->any_proxy_id_) )); throw CORBA::UNKNOWN(); } if (CORBA::is_nil (this->any_push_supplier_ref_.in ())) { PortableServer::ObjectId_var push_supplier_id = this->root_poa_->activate_object ( &(this->any_push_supplier_)); CORBA::Object_var obj = this->root_poa_->id_to_reference (push_supplier_id.in ()); this->any_push_supplier_ref_ = CosNotifyComm::PushSupplier::_narrow (obj.in ()); } if (CORBA::is_nil (any_push_supplier_ref_.in ())) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) Supplier: Received wrong type of push consumer proxy %d\n"), static_cast<int>(this->sequence_proxy_id_) )); throw CORBA::UNKNOWN(); } this->any_proxy_push_consumer_->connect_any_push_supplier ( any_push_supplier_ref_.in ()); }
//----------------------------------------------------------------------------- void Supplier::createSupplier() { ACS_TRACE("Supplier::createSupplier"); // TAO Developer's Guide p. 599 - Create Supplier Admin object if(CORBA::is_nil(notifyChannel_m.in()) == true) { ACS_SHORT_LOG((LM_ERROR, "Supplier::createSupplier error occured for the '%s' channel!", channelName_mp)); CORBAProblemExImpl err = CORBAProblemExImpl(__FILE__,__LINE__,"nc::Supplier::createSupplier"); throw err.getCORBAProblemEx(); } // CosNotifyChannelAdmin::AdminID adminid; // CosNotifyChannelAdmin::ProxyID proxyConsumerID; try { //get a supplier admin SupplierAdmin_m = notifyChannel_m->new_for_suppliers(ifgop_m, adminid); //sanity check on the supplier admin if(CORBA::is_nil(SupplierAdmin_m.in()) == true) { ACS_SHORT_LOG((LM_ERROR, "Supplier::createSupplier error occured for the '%s' channel!", channelName_mp)); CORBAProblemExImpl err = CORBAProblemExImpl(__FILE__,__LINE__,"nc::Supplier::createSupplier"); throw err.getCORBAProblemEx(); } // Check if our admin is a proper TAO extension // so we can create a named proxy consumer bool isAdminExt = false; try { NotifyMonitoringExt::SupplierAdmin_var supplierAdminExt = NotifyMonitoringExt::SupplierAdmin::_narrow(SupplierAdmin_m); isAdminExt = (supplierAdminExt != 0); } catch(...) {} //get a proxy consumer CosNotifyChannelAdmin::ProxyConsumer_var proxyconsumer = 0; if( isAdminExt ) { char *name = 0; if( component_mp != 0 ) name = component_mp->name(); else name = "Unknown"; std::string proxyName(createRandomizedClientName(name)); NotifyMonitoringExt::SupplierAdmin_var supplierAdminExt = NotifyMonitoringExt::SupplierAdmin::_narrow(SupplierAdmin_m); while( proxyconsumer == 0 ) { try { proxyconsumer = supplierAdminExt->obtain_named_notification_push_consumer(CosNotifyChannelAdmin::STRUCTURED_EVENT, proxyConsumerID, proxyName.c_str()); //ACS_SHORT_LOG((LM_INFO,"Consumer::createConsumer Got named proxy supplier '%s' with proxyID %d", proxyName.c_str(), proxyconsumerID)); } catch (NotifyMonitoringExt::NameAlreadyUsed &ex) { // If the original name is already in use, append "-<tries>" and try again // until we find a free name proxyName = createRandomizedClientName(name); } catch (...) { // If any unexpected problem appears, try the unnamed version proxyconsumer = SupplierAdmin_m->obtain_notification_push_consumer(CosNotifyChannelAdmin::STRUCTURED_EVENT, proxyConsumerID); //ACS_SHORT_LOG((LM_INFO,"Consumer::createConsumer Created unnamed proxy supplier")); } } } else { // Just the unnamed version if we don't have the TAO extensions proxyconsumer = SupplierAdmin_m->obtain_notification_push_consumer(CosNotifyChannelAdmin::STRUCTURED_EVENT, proxyConsumerID); } //sanity check on the consumer admin if(CORBA::is_nil(proxyconsumer.in()) == true) { ACS_SHORT_LOG((LM_ERROR, "Supplier::createSupplier error occured for the '%s' channel!", channelName_mp)); CORBAProblemExImpl err = CORBAProblemExImpl(__FILE__,__LINE__,"nc::Supplier::createSupplier"); throw err.getCORBAProblemEx(); } //narrow the consumer to a structured proxy proxyConsumer_m = CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(proxyconsumer.in()); //sanity check if(CORBA::is_nil(proxyConsumer_m.in()) == true) { ACS_SHORT_LOG((LM_ERROR, "Supplier::createSupplier error occured for the '%s' channel!", channelName_mp)); CORBAProblemExImpl err = CORBAProblemExImpl(__FILE__,__LINE__,"nc::Supplier::createSupplier"); throw err.getCORBAProblemEx(); } //activate ourself as a CORBA object reference_m = BACI_CORBA::ActivateTransientCORBAObject<CosNotifyComm::StructuredPushSupplier>(this); if (reference_m.in()==0) { reference_m = this->_this(); } //sanity check if(CORBA::is_nil(reference_m.in()) == true) { ACS_SHORT_LOG((LM_ERROR, "Supplier::createSupplier error occured for the '%s' channel!", channelName_mp)); CORBAProblemExImpl err = CORBAProblemExImpl(__FILE__,__LINE__,"nc::Supplier::createSupplier"); throw err.getCORBAProblemEx(); } //finally attach ourself to the proxy consumer proxyConsumer_m->connect_structured_push_supplier(reference_m.in()); } catch(CORBAProblemEx) { //exception thrown by us...OK to rethrow ACS_SHORT_LOG((LM_TRACE, "Supplier::createSupplier nil pointer error occured for the '%s' channel!", channelName_mp)); throw; } catch(...) { ACS_SHORT_LOG((LM_ERROR, "Supplier::createSupplier unknown error occured for the '%s' channel!", channelName_mp)); CORBAProblemExImpl err = CORBAProblemExImpl(__FILE__,__LINE__,"nc::Supplier::createSupplier"); throw err.getCORBAProblemEx(); } }