summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Metrics/Metrics_UpcallMonitor.h
blob: 538d3d3a3da0b35c9ae9194408d2aa1387d96a5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
// $Id$

#ifndef METRICS_UPCALL_MONITOR_H
#define METRICS_UPCALL_MONITOR_H

#if ! defined (VXWORKS)

// Comment out both of these to disable output
#  define METRICS_MONITOR_ERROR_OUTPUT_ENABLED
#  define METRICS_MONITOR_DEBUG_OUTPUT_ENABLED

#endif /* ! VXWORKS */

#include "ace/Singleton.h"
#include "ace/Hash_Map_Manager.h"

#include "orbsvcs/RtecEventCommS.h"
#include "orbsvcs/Time_Utilities.h"
#include "orbsvcs/MetricsS.h"

#include "Metrics_LocalCache.h"
#include "Metrics_FrameManager.h"
#include "Metrics_Utils.h"

class TAO_ORBSVCS_Export TAO_Metrics_UpcallMonitor
  : public POA_Metrics::QoSMonitor
{
  // = TITLE
  //   This class implements a Metrics QoS monitor.
  //
  // = DESCRIPTION
  //   This class allows clients to monitor QoS, collected
  //   by the rest of the metrics framework.
public:

  typedef ACE_Hash_Map_Manager_Ex<RtecScheduler::handle_t,
	                          CORBA::ULong,
                                  ACE_Hash<RtecScheduler::handle_t>,
                                  ACE_Equal_To<RtecScheduler::handle_t>,
                                  ACE_SYNCH_MUTEX> MONITOR_MAP;
  // Type of map used for O(1) lookup of missed/made deadline counts
  // by operation handles.

  typedef ACE_Hash_Map_Entry<RtecScheduler::handle_t, CORBA::ULong>
    MONITOR_MAP_ENTRY;
  // Type of map used for O(1) lookup of RT_Infos by their handles.

  typedef ACE_Hash_Map_Iterator_Ex<RtecScheduler::handle_t,
	                          CORBA::ULong,
                                  ACE_Hash<RtecScheduler::handle_t>,
                                  ACE_Equal_To<RtecScheduler::handle_t>,
                                  ACE_SYNCH_MUTEX> MONITOR_MAP_ITERATOR;
  // Type of map used for O(1) lookup of missed/made deadline counts
  // by operation handles.


  TAO_Metrics_UpcallMonitor ();
  // Default constructor. 

  ~TAO_Metrics_UpcallMonitor ();
  // Destructor.

  virtual void
  report_made_deadline (RtecScheduler::handle_t handle,
                        CORBA::Environment &ACE_TRY_ENV
                          = CORBA::Environment::default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Metrics::INTERNAL_0));
  // Reports a successful upcall.

  virtual void
  report_missed_deadline (RtecScheduler::handle_t handle,
                          CORBA::Environment &ACE_TRY_ENV
                            = CORBA::Environment::default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Metrics::INTERNAL_1));
  // Reports an unsuccessful upcall.

  virtual void
  get_aggregate_QoS (RtecScheduler::handle_t handle,
                     Metrics::QoSParameter_t_out qos,
                     CORBA::Environment &ACE_TRY_ENV
                       = CORBA::Environment::default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Metrics::INTERNAL_2,
                     Metrics::INTERNAL_3));
  // Get the aggregate QoS statistics collected for the passed handle.

  virtual void get_aggregate_QoS_set (
      const Metrics::Handle_Set_t & handle_set,
      Metrics::QoSParameter_Set_out qos_set,
      CORBA::Environment &ACE_TRY_ENV = 
        TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Metrics::INTERNAL_4,
                     Metrics::INTERNAL_5));
  // Get the aggregate QoS statistics collected for each handle in the
  // passed set.

  virtual void
  reset_statistics (RtecScheduler::handle_t handle,
                    CORBA::Environment &ACE_TRY_ENV
                      = CORBA::Environment::default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Metrics::INTERNAL_7,
                     Metrics::INTERNAL_8));
  // Resets the aggregate QoS information for the given operation.

  MONITOR_MAP &missed_map ();
  // Accessor for map of operation handle to a count of deadlines missed.

  MONITOR_MAP &made_map ();
  // Accessor for map of operation handle to a count of deadlines made.

private:

  // = Implementation members.

  MONITOR_MAP missed_map_;
  // Maps operation handle to a count of deadlines missed.

  MONITOR_MAP made_map_;
  // Maps operation handle to a count of deadlines made.

};


class TAO_ORBSVCS_Export TAO_Metrics_ReportingUpcallMonitor
  : public POA_Metrics::ReportingQoSMonitor
{
  // = TITLE
  //   This class implements a reporting extension for a Metrics QoS monitor.
  //
  // = DESCRIPTION
  //   This class uses delegation to avoid the ugly consequences of
  //   multiple inheritance from a common IDL base class along two
  //   inheritance paths.
public:

  typedef ACE_Hash_Map_Manager_Ex<RtecScheduler::handle_t,
	                          CORBA::ULong,
                                  ACE_Hash<RtecScheduler::handle_t>,
                                  ACE_Equal_To<RtecScheduler::handle_t>,
                                  ACE_SYNCH_MUTEX> MONITOR_MAP;
  // Type of map used for O(1) lookup of missed/made deadline counts
  // by operation handles.

  typedef ACE_Hash_Map_Entry<RtecScheduler::handle_t, CORBA::ULong>
    MONITOR_MAP_ENTRY;
  // Type of map used for O(1) lookup of RT_Infos by their handles.

  typedef ACE_Hash_Map_Iterator_Ex<RtecScheduler::handle_t,
	                          CORBA::ULong,
                                  ACE_Hash<RtecScheduler::handle_t>,
                                  ACE_Equal_To<RtecScheduler::handle_t>,
                                  ACE_SYNCH_MUTEX> MONITOR_MAP_ITERATOR;
  // Type of map used for O(1) lookup of missed/made deadline counts
  // by operation handles.


  TAO_Metrics_ReportingUpcallMonitor ();
  // Default constructor. 

  ~TAO_Metrics_ReportingUpcallMonitor ();
  // Destructor.

  virtual void
  report_made_deadline (RtecScheduler::handle_t handle,
                        CORBA::Environment &ACE_TRY_ENV
                          = CORBA::Environment::default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Metrics::INTERNAL_0));
  // Reports a successful upcall.

  virtual void
  report_missed_deadline (RtecScheduler::handle_t handle,
                          CORBA::Environment &ACE_TRY_ENV
                            = CORBA::Environment::default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Metrics::INTERNAL_1));
  // Reports an unsuccessful upcall.

  virtual void
  get_aggregate_QoS (RtecScheduler::handle_t handle,
                     Metrics::QoSParameter_t_out qos,
                     CORBA::Environment &ACE_TRY_ENV
                       = CORBA::Environment::default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Metrics::INTERNAL_2,
                     Metrics::INTERNAL_3));
  // Get the aggregate QoS statistics collected for the passed handle.

  virtual void get_aggregate_QoS_set (
      const Metrics::Handle_Set_t & handle_set,
      Metrics::QoSParameter_Set_out qos_set,
      CORBA::Environment &ACE_TRY_ENV = 
        TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Metrics::INTERNAL_4,
                     Metrics::INTERNAL_5));
  // Get the aggregate QoS statistics collected for each handle in the
  // passed set.

  virtual void report_aggregate_QoS (
      Metrics::QoSLogger_ptr logger,
      Metrics::Time interval,
      CORBA::Environment &ACE_TRY_ENV = 
        TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Metrics::NIL_LOGGER,
                     Metrics::INTERNAL_6));
  // Report the aggregate QoS statistics to the logger.

  virtual void
  reset_statistics (RtecScheduler::handle_t handle,
                    CORBA::Environment &ACE_TRY_ENV
                      = CORBA::Environment::default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Metrics::INTERNAL_7,
                     Metrics::INTERNAL_8));
  // Resets the aggregate QoS information for the given operation.

private:

  TAO_Metrics_UpcallMonitor monitor_;
  // The monitor we're wrapping.
};


#if defined (__ACE_INLINE__)
#include "Metrics_UpcallMonitor.i"
#endif /* __ACE_INLINE__ */

#include "orbsvcs/Metrics/Metrics_UpcallMonitor_T.h"

typedef TAO_Metrics_UpcallMonitorAdapter<ACE_SYNCH_MUTEX, ACE_New_Allocator>
TAO_METRICS_MONITOR_ADAPTER_TYPE;

typedef TAO_Metrics_ReportingUpcallMonitorAdapter<ACE_SYNCH_MUTEX, ACE_New_Allocator>
TAO_METRICS_REPORTING_MONITOR_ADAPTER_TYPE;

typedef ACE_Singleton<TAO_Metrics_UpcallMonitor, ACE_SYNCH_MUTEX>
TAO_METRICS_MONITOR_SINGLETON_TYPE;

typedef ACE_Singleton<TAO_Metrics_ReportingUpcallMonitor, ACE_SYNCH_MUTEX>
TAO_METRICS_REPORTING_MONITOR_SINGLETON_TYPE;

#if defined (TAO_USES_REPORTING_METRICS)
typedef TAO_METRICS_REPORTING_MONITOR_ADAPTER_TYPE TAO_METRICS_MONITOR_ADAPTER;
typedef TAO_METRICS_REPORTING_MONITOR_SINGLETON_TYPE TAO_METRICS_MONITOR_SINGLETON;
#else
typedef TAO_METRICS_MONITOR_ADAPTER_TYPE TAO_METRICS_MONITOR_ADAPTER;
typedef TAO_METRICS_MONITOR_SINGLETON_TYPE TAO_METRICS_MONITOR_SINGLETON;
#endif


#endif /* METRICS_UPCALL_MONITOR_H */