📄 metrics_logger.cpp
字号:
ACE_Message_Block ((char *) data,
sizeof (TAO_Metrics_Logger_Data)));
if (this->putq (mb) < 0)
{
#if defined (METRICS_LOGGER_ERROR_OUTPUT_ENABLED)
ACE_ERROR ((LM_ERROR,
"TAO_Metrics_Logger::log_aggregate_QoS putq failed"));
#endif
}
#endif
}
// Processes the aggregate QoS information for all operations
// to the passed QoS logger.
void
TAO_Metrics_Logger::process_aggregate_QoS (const Metrics::QoSParameter_Set & qos_params,
Metrics::Time interval)
{
//Added to remove Linux warning (Boeing Extension)
ACE_UNUSED_ARG(interval);
if (this->generate_log_)
{
if (log_filename_)
{
// log_file_ = ACE_OS::fopen (log_filename_, "a+");
}
ACE_OS::fprintf (log_file_,
"\nName missed made cancelled\n");
ACE_OS::fprintf (export_file_,
"\n\n Name \t missed \t made \t cancelled\n");
}
#if defined (METRICS_LOGGER_SENDS_EVENTS)
if (this->generate_events_)
{
this->qos_data_.hrt_deadlines_missed = 0;
this->qos_data_.hrt_deadlines_made = 0;
this->qos_data_.hrt_operations_cancelled = 0;
this->qos_data_.srt_deadlines_missed = 0;
this->qos_data_.srt_deadlines_made = 0;
this->qos_data_.srt_operations_cancelled = 0;
}
#endif /* METRICS_LOGGER_SENDS_EVENTS */
for (u_long i = 0; i < qos_params.length (); ++i)
{
#if defined (METRICS_LOGGER_SENDS_EVENTS)
if (this->generate_events_)
{
if (qos_params [i].is_hrt)
{
this->qos_data_.hrt_deadlines_missed +=
qos_params [i].deadlines_missed;
this->qos_data_.hrt_deadlines_made +=
qos_params [i].deadlines_made;
this->qos_data_.hrt_operations_cancelled +=
qos_params [i].operations_cancelled;
}
else
{
this->qos_data_.srt_deadlines_missed +=
qos_params [i].deadlines_missed;
this->qos_data_.srt_deadlines_made +=
qos_params [i].deadlines_made;
this->qos_data_.srt_operations_cancelled +=
qos_params [i].operations_cancelled;
}
}
#endif /* METRICS_LOGGER_SENDS_EVENTS */
if (this->generate_log_)
{
ACE_OS::fprintf (log_file_,
"%-50s %8lu %8lu %8lu\n",
(const char *)qos_params [i].entry_point,
qos_params [i].deadlines_missed,
qos_params [i].deadlines_made,
qos_params [i].operations_cancelled);
ACE_OS::fprintf (export_file_,
" %s \t %lu \t %lu \t %lu\n",
(const char *)qos_params [i].entry_point,
qos_params [i].deadlines_missed,
qos_params [i].deadlines_made,
qos_params [i].operations_cancelled);
}
}
#if defined (METRICS_LOGGER_SENDS_EVENTS)
if (this->generate_events_)
{
// Push an event to the visualization browser.
CORBA::Any any;
ACE_TRY_NEW_ENV
{
any.replace (Metrics::_tc_QoSData, &qos_data_, 0, ACE_TRY_ENV);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
#if defined (METRICS_LOGGER_ERROR_OUTPUT_ENABLED)
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "TAO_Metrics_Logger::process_aggregate_QoS");
#endif
return;
}
ACE_ENDTRY;
this->dove_supplier_.notify (any);
}
#endif /* METRICS_LOGGER_SENDS_EVENTS */
if (this->generate_log_)
{
if (log_filename_)
{
ACE_OS::fflush (log_file_);
// ACE_OS::fclose (log_file_);
}
}
}
// Binds the names of various timeprobes to their identifiers so
// that ids alone can be used (for efficiency) in passing data.
void
TAO_Metrics_Logger::set_identities (const Metrics::ProbeIdentity_Set &
probe_identities
ACE_ENV_ARG_DECL)
throw (CORBA::SystemException)
{
for (u_long i = 0; i < probe_identities.length (); ++i)
{
this->set_identity (probe_identities [i]
ACE_ENV_ARG_DECL);
ACE_CHECK;
}
}
void
TAO_Metrics_Logger::set_identity (const Metrics::ProbeIdentity_t & probe_identity
ACE_ENV_ARG_DECL)
throw (CORBA::SystemException)
{
// Look up the existing name that is bound, creating one if there is
// not one there already.
CORBA::String_var *name = 0;
if (probe_name_map_.find (probe_identity.probe_id, name) != 0
|| name == 0)
{
ACE_NEW_THROW_EX (name,
CORBA::String_var (probe_identity.probe_name),
CORBA::NO_MEMORY ());
ACE_CHECK;
// What is this used for? BRM
auto_ptr<CORBA::String_var> name_ptr (name);
if (probe_name_map_.rebind (probe_identity.probe_id, name) < 0)
{
#if defined (METRICS_LOGGER_ERROR_OUTPUT_ENABLED)
ACE_ERROR ((LM_ERROR, "TAO_Metrics_Logger::set_identity bind failed.\n"));
#endif
return;
}
// DEBUG
const char * name_cstr = name->in ();
ACE_DEBUG ((LM_DEBUG,
"Logger registered name [%s] with id [%u]\n",
name_cstr, probe_identity.probe_id));
name_ptr.release ();
}
else
{
// DEBUG
const char * old_name_cstr = name->in ();
// Unconditionally set the name to the new name.
*name = probe_identity.probe_name;
// DEBUG
const char * new_name_cstr = name->in ();
ACE_DEBUG ((LM_DEBUG,
"Logger CHANGED name from [%s] to [%s] for id [%u]\n",
old_name_cstr, new_name_cstr, probe_identity.probe_id));
}
}
// Reports timeprobe data collected since last run.
void
TAO_Metrics_Logger::log_timeprobe_data (const Metrics::TimeprobeParameter_Set &
timeprobe_params,
Metrics::Time interval
ACE_ENV_ARG_DECL)
throw (CORBA::SystemException)
{
// Package up the data and put it on the task queue.
TAO_Metrics_Logger_Data *data;
ACE_NEW (data,
TAO_Metrics_Logger_Data (TAO_Metrics_Logger_Data::TIMEPROBE_TYPE,
interval));
ACE_NEW (data->timeprobe_params_,
Metrics::TimeprobeParameter_Set (timeprobe_params));
ACE_Message_Block *mb;
ACE_NEW (mb,
ACE_Message_Block ((char *) data,
sizeof (TAO_Metrics_Logger_Data)));
if (this->putq (mb) < 0)
{
#if defined (METRICS_LOGGER_ERROR_OUTPUT_ENABLED)
ACE_ERROR ((LM_ERROR,
"TAO_Metrics_Logger::log_timeprobe_data putq failed"));
#endif
}
}
// Processes timeprobe data collected since last run.
void
TAO_Metrics_Logger::process_timeprobe_data (const Metrics::TimeprobeParameter_Set & timeprobe_params,
Metrics::Time interval)
{
if (this->generate_log_)
{
if (log_filename_)
{
// log_file_ = ACE_OS::fopen (log_filename_, "a+");
}
ACE_OS::fprintf (log_file_,
"\n\n\n"
"Interval (usec): %9lu \n\n"
"Probe elapsed_time(usec) Start Time (usecs) Stop Time (usec)\n\n",
// Modified by BAP. This really should be corrected since we are truncating the interval here.
// We can get away with it here for now since the intervals are small enough to not roll over.
(u_long) ACE_U64_TO_U32(interval)/10 );
ACE_OS::fprintf (export_file_,
"\n\n\n"
"Interval (usec): \t %9lu \t \n\n"
"Probe \t elapsed_time(usec) \tStart Time (usecs) \t Stop Time (usec)\n\n",
// Modified by BAP. This really should be corrected since we are truncating the interval here.
// We can get away with it here for now since the intervals are small enough to not roll over.
(u_long) ACE_U64_TO_U32(interval)/10 );
}
#if defined (METRICS_LOGGER_SENDS_EVENTS)
Metrics::Time queue_time = 0;
Metrics::Time hrt_op_time = 0;
Metrics::Time srt_op_time = 0;
#endif /* METRICS_LOGGER_SENDS_EVENTS */
for (u_long i = 0; i < timeprobe_params.length (); ++i)
{
#if defined (METRICS_LOGGER_SENDS_EVENTS)
if (! timeprobe_params [i].is_full_interval)
{
if (timeprobe_params [i].is_operation)
{
if (timeprobe_params [i].is_hrt)
{
hrt_op_time += timeprobe_params [i].interval;
}
else
{
srt_op_time += timeprobe_params [i].interval;
}
}
else
{
queue_time += timeprobe_params [i].interval;
}
}
#endif /* METRICS_LOGGER_SENDS_EVENTS */
if (this->generate_log_)
{
// Look up the name of the probe in the hash map.
// If successful, use the name, and if not just use the probe id.
CORBA::String_var *probe_name = 0;
char format_spec[255];
char export_spec[255];
if (probe_name_map_.find (timeprobe_params [i].probe_id, probe_name) == 0
&& probe_name != 0)
{
if (timeprobe_params [i].cross_thread_probe &&
timeprobe_params [i].is_full_interval)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -