Go to the documentation of this file.00001
00002
00003 #ifndef MONITORPROXYSUPPLIER_T_CPP
00004 #define MONITORPROXYSUPPLIER_T_CPP
00005
00006 #include "orbsvcs/Notify/MonitorControlExt/MonitorProxySupplier_T.h"
00007 #include "orbsvcs/Notify/MonitorControlExt/MonitorConsumerAdmin.h"
00008 #include "orbsvcs/Notify/MonitorControlExt/MonitorEventChannel.h"
00009 #include "orbsvcs/Notify/ThreadPool_Task.h"
00010 #include "ace/Monitor_Base.h"
00011
00012 #if defined (TAO_HAS_MONITOR_FRAMEWORK) && (TAO_HAS_MONITOR_FRAMEWORK == 1)
00013
00014 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00015 #pragma once
00016 #endif
00017
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019
00020 template <typename ProxyPushSupplier>
00021 TAO_MonitorProxySupplier_T<ProxyPushSupplier>::TAO_MonitorProxySupplier_T (void)
00022 : queue_item_stat_name_ ()
00023 , overflow_stat_name_ ()
00024 , queue_item_count_ (0)
00025 , overflows_ (0)
00026 , event_channel_ (0)
00027 , admin_ (0)
00028 {
00029 }
00030
00031 template <typename ProxyPushSupplier>
00032 TAO_MonitorProxySupplier_T<ProxyPushSupplier>::~TAO_MonitorProxySupplier_T (void)
00033 {
00034 if (this->admin_ != 0)
00035 {
00036 this->admin_->unregister_child (this);
00037 }
00038 if (this->event_channel_ != 0)
00039 {
00040 this->event_channel_->unregister_statistic (this->queue_item_stat_name_);
00041 }
00042 }
00043
00044 template <typename ProxyPushSupplier>
00045 void
00046 TAO_MonitorProxySupplier_T<ProxyPushSupplier>::update_queue_count (size_t count)
00047 {
00048 if (this->queue_item_count_ != 0)
00049 {
00050
00051 size_t pending = 0;
00052 if (TAO_Notify_ProxySupplier::consumer() != 0)
00053 {
00054 pending = this->TAO_Notify_ProxySupplier::consumer()->pending_count();
00055 }
00056 this->queue_item_count_->receive (count + pending);
00057 }
00058 if (this->child_ != 0)
00059 {
00060 this->child_->update_queue_count (count);
00061 }
00062 }
00063
00064 template <typename ProxyPushSupplier>
00065 void
00066 TAO_MonitorProxySupplier_T<ProxyPushSupplier>::count_queue_overflow (
00067 bool local_overflow,
00068 bool global_overflow)
00069 {
00070
00071
00072 if (this->overflows_ != 0)
00073 {
00074 this->overflows_->receive ((size_t)1);
00075 }
00076 if (this->child_ != 0)
00077 {
00078 this->child_->count_queue_overflow (local_overflow, global_overflow);
00079 }
00080 }
00081
00082 template <typename ProxyPushSupplier>
00083 void
00084 TAO_MonitorProxySupplier_T<ProxyPushSupplier>::configure(
00085 TAO_Notify_ConsumerAdmin & admin,
00086 CosNotifyChannelAdmin::ProxyID_out proxy_id)
00087 {
00088 admin_ = dynamic_cast<TAO_MonitorConsumerAdmin *> (& admin);
00089 if (admin_ == 0)
00090 {
00091 throw CORBA::INTERNAL();
00092 }
00093 event_channel_ = admin_->get_ec ();
00094
00095 TAO_Notify_Buffering_Strategy* bs = 0;
00096 TAO_Notify_Worker_Task * worker_task = this->TAO_Notify_Object::get_worker_task ();
00097 TAO_Notify_ThreadPool_Task* tpt =
00098 dynamic_cast<TAO_Notify_ThreadPool_Task*> (worker_task);
00099 if (tpt != 0)
00100 {
00101 bs = tpt->buffering_strategy ();
00102 }
00103 if (bs != 0)
00104 {
00105 bs->set_tracker (admin_);
00106 }
00107 else
00108 {
00109 ACE_DEBUG ((LM_DEBUG, "Warning MC cannot enable statistics for buffering strategy.\n"));
00110 }
00111
00112 this->base_stat_name_ = admin_->stat_name ();
00113 char name[64];
00114 ACE_OS::sprintf(name, "%d", proxy_id);
00115 this->base_stat_name_ += name;
00116 this->base_stat_name_ += "/";
00117
00118 this->queue_item_stat_name_ = base_stat_name_;
00119 this->queue_item_stat_name_ += NotifyMonitoringExt::EventChannelQueueElementCount;
00120 ACE_NEW_THROW_EX (this->queue_item_count_,
00121 Monitor_Base (this->queue_item_stat_name_.c_str (),
00122 Monitor_Control_Types::MC_NUMBER),
00123 CORBA::NO_MEMORY ());
00124 if (!event_channel_->register_statistic (this->queue_item_stat_name_, this->queue_item_count_))
00125 {
00126 delete this->queue_item_count_;
00127 this->queue_item_count_ = 0;
00128 throw NotifyMonitoringExt::NameAlreadyUsed ();
00129 }
00130
00131 this->overflow_stat_name_ = base_stat_name_;
00132 this->overflow_stat_name_ += NotifyMonitoringExt::EventChannelQueueOverflows;
00133 ACE_NEW_THROW_EX (this->overflows_,
00134 Monitor_Base (this->overflow_stat_name_.c_str (),
00135 Monitor_Control_Types::MC_COUNTER),
00136 CORBA::NO_MEMORY ());
00137 if (!event_channel_->register_statistic (this->overflow_stat_name_, this->overflows_))
00138 {
00139 delete this->overflows_;
00140 this->overflows_ = 0;
00141 throw NotifyMonitoringExt::NameAlreadyUsed ();
00142 }
00143
00144 admin_->register_child (this);
00145 }
00146
00147
00148 template <typename ProxyPushSupplier>
00149 ACE_CString &
00150 TAO_MonitorProxySupplier_T<ProxyPushSupplier>::queue_item_stat_name(void)
00151 {
00152 return this->queue_item_stat_name_;
00153 }
00154
00155
00156 template <typename ProxyPushSupplier>
00157 ACE_CString &
00158 TAO_MonitorProxySupplier_T<ProxyPushSupplier>::overflow_stat_name(void)
00159 {
00160 return this->overflow_stat_name_;
00161 }
00162
00163
00164 TAO_END_VERSIONED_NAMESPACE_DECL
00165
00166 #endif // TAO_HAS_MONITOR_FRAMEWORK == 1
00167
00168 #endif // MONITORPROXYSUPPLIER_T_CPP