Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "FWCore/MessageService/interface/ELlimitsTable.h"
00025
00026
00027
00028
00029
00030
00031
00032
00033 namespace edm {
00034 namespace service {
00035
00036
00037
00038
00039
00040
00041 ELlimitsTable::ELlimitsTable()
00042 : wildcardLimit ( -1 )
00043 , wildcardInterval( -1 )
00044 , wildcardTimespan( -1 )
00045 , tableLimit ( -1 )
00046 , limits ( )
00047 , counts ( )
00048 {
00049
00050 #ifdef ELlimitsTableCONSTRUCTOR_TRACE
00051 std::cerr << "Constructor for ELlimitsTable\n";
00052 #endif
00053
00054 for ( int k = 0; k < ELseverityLevel::nLevels; ++k ) {
00055 severityLimits[k] = -1;
00056 severityIntervals[k] = -1;
00057 severityTimespans[k] = -1;
00058 }
00059
00060 }
00061
00062
00063 ELlimitsTable::~ELlimitsTable() {
00064
00065 #ifdef ELlimitsTableCONSTRUCTOR_TRACE
00066 std::cerr << "Destructor for ELlimitsTable\n";
00067 #endif
00068
00069 }
00070
00071
00072
00073
00074
00075
00076 void ELlimitsTable::setTableLimit( int n ) { tableLimit = n; }
00077
00078
00079 bool ELlimitsTable::add( const ELextendedID & xid ) {
00080
00081 #ifdef ELlimitsTableATRACE
00082 std::cerr << "&&&--- adding to limits table: " << xid.id << '\n';
00083 #endif
00084
00085 ELmap_counts::iterator c = counts.find( xid );
00086
00087 if ( c == counts.end() ) {
00088
00089 #ifdef ELlimitsTableATRACE
00090 std::cerr << "&&& no such entry yet in counts \n";
00091 #endif
00092
00093
00094
00095 if ( tableLimit > 0 && static_cast<int>(counts.size()) >= tableLimit ) {
00096 return true;
00097 }
00098 int lim;
00099 int ivl;
00100 int ts;
00101 ELmap_limits::iterator l = limits.find( xid.id );
00102
00103 if ( l != limits.end() ) {
00104 lim = (*l).second.limit;
00105 ivl = (*l).second.interval;
00106 ts = (*l).second.timespan;
00107 if ( lim < 0 ) {
00108 lim = severityLimits[xid.severity.getLevel()];
00109 if ( lim < 0 ) {
00110 lim = wildcardLimit;
00111 }
00112 }
00113 if ( ivl < 0 ) {
00114 ivl = severityIntervals[xid.severity.getLevel()];
00115 if ( ivl < 0 ) {
00116 ivl = wildcardInterval;
00117 }
00118 }
00119 if ( ts < 0 ) {
00120 ts = severityTimespans[xid.severity.getLevel()];
00121 if (ts < 0 ) {
00122 ts = wildcardTimespan;
00123 }
00124 limits[xid.id] = LimitAndTimespan( lim, ts );
00125 }
00126 #ifdef ELlimitsTableATRACE
00127 std::cerr << "&&& Entry found in limits: limit = " << lim
00128 << " interval = " << ivl
00129 << " timespan = " << ts << '\n';
00130 #endif
00131
00132 } else {
00133 lim = severityLimits [xid.severity.getLevel()];
00134 ivl = severityIntervals[xid.severity.getLevel()];
00135 ts = severityTimespans[xid.severity.getLevel()];
00136 #ifdef ELlimitsTableATRACE
00137 std::cerr << "&&& Limit taken from severityLimits: " << lim << '\n'
00138 << "&&& Interval taken from severityLimits: " << ivl << '\n';
00139 #endif
00140 if ( lim < 0 ) {
00141 lim = wildcardLimit;
00142 #ifdef ELlimitsTableATRACE
00143 std::cerr << "&&& Limit reset to wildcard limit: " << lim << '\n';
00144 #endif
00145 }
00146 if ( ivl < 0 ) {
00147 ivl = wildcardInterval;
00148 #ifdef ELlimitsTableATRACE
00149 std::cerr << "&&& Interval reset to wildcard interval: " << ivl << '\n';
00150 #endif
00151 }
00152 #ifdef ELlimitsTableATRACE
00153 std::cerr << "&&& Timespan taken from severityTimespans: " << ts << '\n';
00154 #endif
00155 if ( ts < 0 ) {
00156 ts = wildcardTimespan;
00157 #ifdef ELlimitsTableATRACE
00158 std::cerr << "&&& timespan reset to wildcard timespan: " << ts << '\n';
00159 #endif
00160 }
00161
00162
00163 }
00164
00165
00166 if ( tableLimit < 0 || static_cast<int>(counts.size()) < tableLimit )
00167 counts[xid] = CountAndLimit( lim, ts, ivl );
00168 c = counts.find( xid );
00169 }
00170
00171 return ( c == counts.end() )
00172 ? true
00173 : (*c).second.add()
00174 ;
00175
00176 }
00177
00178
00179
00180
00181
00182
00183 void ELlimitsTable::wipe() {
00184
00185
00186
00187
00188
00189 limits.erase( limits.begin(), limits.end() );
00190 ELmap_counts::iterator i;
00191 for ( i = counts.begin(); i != counts.end(); ++i ) {
00192 (*i).second.limit = -1;
00193 (*i).second.n = (*i).second.aggregateN = 0;
00194 }
00195
00196 wildcardLimit = -1;
00197 wildcardTimespan = -1;
00198 for ( int lev = 0; lev < ELseverityLevel::nLevels; ++lev ) {
00199 severityLimits [lev] = -1;
00200 severityIntervals[lev] = -1;
00201 severityTimespans[lev] = -1;
00202 }
00203
00204 }
00205
00206
00207 void ELlimitsTable::zero() {
00208
00209
00210
00211 ELmap_counts::iterator i;
00212 for ( i = counts.begin(); i != counts.end(); ++i )
00213 (*i).second.n = 0;
00214 }
00215
00216
00217 void ELlimitsTable::setLimit( const ELstring & id, int n ) {
00218 if ( id[0] == '*' ) wildcardLimit = n;
00219 else limits[id].limit = n;
00220 }
00221
00222
00223 void ELlimitsTable::setLimit( const ELseverityLevel & sev, int n ) {
00224 severityLimits[sev.getLevel()] = n;
00225 }
00226
00227 void ELlimitsTable::setInterval( const ELstring & id, int interval ) {
00228 if ( id[0] == '*' ) wildcardInterval = interval;
00229 else limits[id].interval = interval;
00230 }
00231
00232
00233 void ELlimitsTable::setInterval( const ELseverityLevel & sev, int interval ) {
00234 severityIntervals[sev.getLevel()] = interval;
00235 }
00236
00237
00238 void ELlimitsTable::setTimespan( const ELstring & id, int n ) {
00239 if ( id[0] == '*' ) wildcardTimespan = n;
00240 else limits[id].timespan = n;
00241 }
00242
00243
00244 void ELlimitsTable::setTimespan( const ELseverityLevel & sev, int n ) {
00245 severityTimespans[sev.getLevel()] = n;
00246 }
00247
00248
00249
00250
00251
00252
00253 ELlimitsTable & ELlimitsTable::operator=( const ELlimitsTable & t ) {
00254
00255 if(this == &t) {
00256 return *this;
00257 }
00258 limits = t.limits;
00259
00260 for ( int lev = 0; lev < ELseverityLevel::nLevels; ++lev ) {
00261 severityTimespans[lev] = t.severityTimespans[lev];
00262 severityTimespans[lev] = t.severityTimespans[lev];
00263 }
00264
00265 wildcardLimit = t.wildcardLimit;
00266 wildcardTimespan = t.wildcardTimespan;
00267
00268 return *this;
00269
00270 }
00271
00272
00273
00274
00275
00276 }
00277 }