CMS 3D CMS Logo

ELlimitsTable.cc
Go to the documentation of this file.
1 // ----------------------------------------------------------------------
2 //
3 // ELlimitsTable.cc
4 //
5 // History:
6 // 7/6/98 mf Created
7 // 6/10/99 jvr Corrected initialization for severityLimits and
8 // timespans to -1 instead of 0.
9 // 6/17/99 jvr setLimit(id,n) works w/ setTimespan(sev||"*",n)
10 // and setTimespan(id,n) w/ setLimit(sev||"*",n)
11 // 6/15/00 web using -> USING
12 // 11/01/01 web Fixed mixed-type comparisons
13 // 5/18/06 mf setInterval
14 // 11/2/07 mf add: Changed ivl = wildcardLimit to wildcardInterval.
15 // Probably moot and never reached, but a clear correction.
16 // 9/29/10 mf,ql Fix savanah bug 65284 where two messages of same
17 // category but different severity, if limits were not
18 // take from category, first severity sets the limit
19 // for both of those xid's.
20 //
21 // ----------------------------------------------------------------------
22 
24 
25 // Posible traces
26 //#include <iostream>
27 //using std::cerr;
28 //#define ELlimitsTableCONSTRUCTOR_TRACE
29 //#define ELlimitsTableATRACE
30 
31 namespace edm {
32  namespace service {
33 
34  // ----------------------------------------------------------------------
35  // Constructor, destructor:
36  // ----------------------------------------------------------------------
37 
39  : wildcardLimit(-1), wildcardInterval(-1), wildcardTimespan(-1), tableLimit(-1), limits(), counts() {
40 #ifdef ELlimitsTableCONSTRUCTOR_TRACE
41  std::cerr << "Constructor for ELlimitsTable\n";
42 #endif
43 
44  for (int k = 0; k < ELseverityLevel::nLevels; ++k) {
45  severityLimits[k] = -1; // JvR 99-06-10
46  severityIntervals[k] = -1;
47  severityTimespans[k] = -1;
48  }
49 
50  } // ELlimitsTable()
51 
53 #ifdef ELlimitsTableCONSTRUCTOR_TRACE
54  std::cerr << "Destructor for ELlimitsTable\n";
55 #endif
56 
57  } // ~ELlimitsTable()
58 
59  // ----------------------------------------------------------------------
60  // Methods invoked by the logger:
61  // ----------------------------------------------------------------------
62 
64 
65  bool ELlimitsTable::add(const ELextendedID& xid) {
66 #ifdef ELlimitsTableATRACE
67  std::cerr << "&&&--- adding to limits table: " << xid.id << '\n';
68 #endif
69 
70  ELmap_counts::iterator c = counts.find(xid);
71 
72  if (c == counts.end()) { // no such entry yet
73 
74 #ifdef ELlimitsTableATRACE
75  std::cerr << "&&& no such entry yet in counts \n";
76 #endif
77 
78  // if the counts table is "full", then this will never be rejected
79  // and info will not be kept so why go through significant work:
80  if (tableLimit > 0 && static_cast<int>(counts.size()) >= tableLimit) {
81  return true;
82  }
83  int lim;
84  int ivl;
85  int ts;
86  ELmap_limits::iterator l = limits.find(xid.id);
87 
88  if (l != limits.end()) { // use limits previously established for this id
89  lim = (*l).second.limit;
90  ivl = (*l).second.interval;
91  ts = (*l).second.timespan;
92  if (lim < 0) { // jvr 6/17/99
93  lim = severityLimits[xid.severity.getLevel()];
94  if (lim < 0) {
95  lim = wildcardLimit;
96  }
97  }
98  if (ivl < 0) {
99  ivl = severityIntervals[xid.severity.getLevel()];
100  if (ivl < 0) {
101  ivl = wildcardInterval; // mf 11/02/07
102  }
103  }
104  if (ts < 0) {
105  ts = severityTimespans[xid.severity.getLevel()];
106  if (ts < 0) {
107  ts = wildcardTimespan;
108  }
109  limits[xid.id] = LimitAndTimespan(lim, ts);
110  }
111 #ifdef ELlimitsTableATRACE
112  std::cerr << "&&& Entry found in limits: limit = " << lim << " interval = " << ivl << " timespan = " << ts
113  << '\n';
114 #endif
115  // change log 9/29/10: Do not put this into limits table
116  } else { // establish and use limits new to this id
117  lim = severityLimits[xid.severity.getLevel()];
118  ivl = severityIntervals[xid.severity.getLevel()];
119  ts = severityTimespans[xid.severity.getLevel()];
120 #ifdef ELlimitsTableATRACE
121  std::cerr << "&&& Limit taken from severityLimits: " << lim << '\n'
122  << "&&& Interval taken from severityLimits: " << ivl << '\n';
123 #endif
124  if (lim < 0) {
125  lim = wildcardLimit;
126 #ifdef ELlimitsTableATRACE
127  std::cerr << "&&& Limit reset to wildcard limit: " << lim << '\n';
128 #endif
129  }
130  if (ivl < 0) {
131  ivl = wildcardInterval;
132 #ifdef ELlimitsTableATRACE
133  std::cerr << "&&& Interval reset to wildcard interval: " << ivl << '\n';
134 #endif
135  }
136 #ifdef ELlimitsTableATRACE
137  std::cerr << "&&& Timespan taken from severityTimespans: " << ts << '\n';
138 #endif
139  if (ts < 0) {
140  ts = wildcardTimespan;
141 #ifdef ELlimitsTableATRACE
142  std::cerr << "&&& timespan reset to wildcard timespan: " << ts << '\n';
143 #endif
144  }
145 
146  // change log 9/29/10 DO not save id's future limits:
147  }
148 
149  // save, if possible, this xid's initial entry:
150  if (tableLimit < 0 || static_cast<int>(counts.size()) < tableLimit)
151  counts[xid] = CountAndLimit(lim, ts, ivl);
152  c = counts.find(xid);
153  }
154 
155  return (c == counts.end()) ? true // no limit filtering can be applied
156  : (*c).second.add() // apply limit filtering
157  ;
158 
159  } // add()
160 
161  // ----------------------------------------------------------------------
162  // Control methods invoked by the framework:
163  // ----------------------------------------------------------------------
164 
166  // This clears everything -- counts and aggregate counts for severity levels
167  // and for individual ID's, as well as any limits established, the limit
168  // for "*" all messages, and the collection of severity defaults. wipe()
169  // does not not affect thresholds.
170 
171  limits.erase(limits.begin(), limits.end());
172  ELmap_counts::iterator i;
173  for (i = counts.begin(); i != counts.end(); ++i) {
174  (*i).second.limit = -1;
175  (*i).second.n = (*i).second.aggregateN = 0;
176  }
177 
178  wildcardLimit = -1;
179  wildcardTimespan = -1;
180  for (int lev = 0; lev < ELseverityLevel::nLevels; ++lev) {
181  severityLimits[lev] = -1;
182  severityIntervals[lev] = -1;
183  severityTimespans[lev] = -1;
184  }
185  }
186 
188  // This clears counts but not aggregate counts for severity levels
189  // and for individual ID's.
190 
191  ELmap_counts::iterator i;
192  for (i = counts.begin(); i != counts.end(); ++i)
193  (*i).second.n = 0;
194  }
195 
196  void ELlimitsTable::setLimit(const ELstring& id, int n) {
197  if (id[0] == '*')
198  wildcardLimit = n;
199  else
200  limits[id].limit = n;
201  }
202 
203  void ELlimitsTable::setLimit(const ELseverityLevel& sev, int n) { severityLimits[sev.getLevel()] = n; }
204 
206  if (id[0] == '*')
208  else
209  limits[id].interval = interval;
210  }
211 
214  }
215 
216  void ELlimitsTable::setTimespan(const ELstring& id, int n) {
217  if (id[0] == '*')
219  else
220  limits[id].timespan = n;
221  }
222 
224 
225  // ----------------------------------------------------------------------
226  // Support for internal operations:
227  // ----------------------------------------------------------------------
228 
230  if (this == &t) {
231  return *this; // self assignment
232  }
233  limits = t.limits; // The non-trivial operator= for a map!
234 
235  for (int lev = 0; lev < ELseverityLevel::nLevels; ++lev) {
236  severityTimespans[lev] = t.severityTimespans[lev];
237  severityTimespans[lev] = t.severityTimespans[lev];
238  }
239 
240  wildcardLimit = t.wildcardLimit;
241  wildcardTimespan = t.wildcardTimespan;
242 
243  return *this;
244 
245  } // operator=()
246 
247  // ----------------------------------------------------------------------
248 
249  } // end of namespace service
250 } // end of namespace edm
service
Definition: service.py:1
edm::ELseverityLevel::getLevel
int getLevel() const
Definition: ELseverityLevel.cc:123
mps_fire.i
i
Definition: mps_fire.py:355
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::ELextendedID::id
ELstring id
Definition: ELextendedID.h:28
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::service::ELlimitsTable::setTimespan
void setTimespan(const ELstring &id, int n)
Definition: ELlimitsTable.cc:216
edm::service::ELlimitsTable::operator=
ELlimitsTable & operator=(const ELlimitsTable &t)
Definition: ELlimitsTable.cc:229
edm::service::ELlimitsTable::severityLimits
int severityLimits[ELseverityLevel::nLevels]
Definition: ELlimitsTable.h:88
edm::ELextendedID
Definition: ELextendedID.h:24
edm::service::ELlimitsTable::severityTimespans
int severityTimespans[ELseverityLevel::nLevels]
Definition: ELlimitsTable.h:89
edm::service::ELlimitsTable::setLimit
void setLimit(const ELstring &id, int n)
Definition: ELlimitsTable.cc:196
edm::service::ELlimitsTable::wipe
void wipe()
Definition: ELlimitsTable.cc:165
edm::service::ELlimitsTable::wildcardTimespan
int wildcardTimespan
Definition: ELlimitsTable.h:93
edm::LimitAndTimespan
Definition: ELmap.h:43
edm::ELstring
std::string ELstring
Definition: ELstring.h:21
edm::service::ELlimitsTable::~ELlimitsTable
~ELlimitsTable()
Definition: ELlimitsTable.cc:52
edm::service::ELlimitsTable
Definition: ELlimitsTable.h:56
ELlimitsTable.h
dqmdumpme.k
k
Definition: dqmdumpme.py:60
edm::CountAndLimit
Definition: ELmap.h:53
OrderedSet.t
t
Definition: OrderedSet.py:90
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
edm::service::ELlimitsTable::severityIntervals
int severityIntervals[ELseverityLevel::nLevels]
Definition: ELlimitsTable.h:90
edm::service::ELlimitsTable::add
bool add(const ELextendedID &xid)
Definition: ELlimitsTable.cc:65
edm::ELseverityLevel::nLevels
Definition: ELseverityLevel.h:121
edm::service::ELlimitsTable::setTableLimit
void setTableLimit(int n)
Definition: ELlimitsTable.cc:63
edm::service::ELlimitsTable::limits
ELmap_limits limits
Definition: ELlimitsTable.h:96
edm::service::ELlimitsTable::wildcardInterval
int wildcardInterval
Definition: ELlimitsTable.h:92
readEcalDQMStatus.interval
interval
Definition: readEcalDQMStatus.py:18
edm::service::ELlimitsTable::tableLimit
int tableLimit
Definition: ELlimitsTable.h:95
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
edm::service::ELlimitsTable::wildcardLimit
int wildcardLimit
Definition: ELlimitsTable.h:91
TH2PolyOfflineMaps.limits
limits
Definition: TH2PolyOfflineMaps.py:45
edm::ELseverityLevel
Definition: ELseverityLevel.h:96
edm::service::ELlimitsTable::setInterval
void setInterval(const ELstring &id, int interval)
Definition: ELlimitsTable.cc:205
edm::service::ELlimitsTable::zero
void zero()
Definition: ELlimitsTable.cc:187
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
dqmiodumpmetadata.counts
counts
Definition: dqmiodumpmetadata.py:25
edm::service::ELlimitsTable::counts
ELmap_counts counts
Definition: ELlimitsTable.h:97
edm::ELextendedID::severity
ELseverityLevel severity
Definition: ELextendedID.h:29
edm::service::ELlimitsTable::ELlimitsTable
ELlimitsTable()
Definition: ELlimitsTable.cc:38