7#define RESIPROCATE_SUBSYSTEM Subsystem::STATS
11GeneralCongestionManager::GeneralCongestionManager(
MetricType defaultMetric,
13 mDefaultMetric(defaultMetric),
14 mDefaultMaxTolerance(defaultMaxTolerance)
17 mRejectionThresholds[
NORMAL]=0;
30 Lock lock(mFifosMutex);
34 info.maxTolerance=maxTolerance;
35 mFifos.push_back(info);
42 Lock lock(mFifosMutex);
43 if(fifo->
getRole() < mFifos.size())
55 Lock lock(mFifosMutex);
56 for(std::vector<FifoInfo>::iterator i=mFifos.begin(); i!=mFifos.end(); ++i)
59 (fifoDescription.
empty() ||
isEqualNoCase(i->fifo->getDescription(), fifoDescription)))
61 i->maxTolerance=UINT_MAX;
63 i->maxTolerance=maxTolerance;
64 if(!fifoDescription.
empty())
return true;
67 return false || fifoDescription.
empty();
73 Lock lock(mFifosMutex);
74 return getRejectionBehaviorInternal(fifo);
78GeneralCongestionManager::getRejectionBehaviorInternal(
const FifoStatsInterface *fifo)
const
83 uint16_t percent=getCongestionPercentInternal(fifo);
103 Lock lock(mFifosMutex);
105 for(std::vector<FifoInfo>::const_iterator i=mFifos.begin();
113 encodeFifoStats(fifo, strm);
122 Lock lock(mFifosMutex);
123 for(std::vector<FifoInfo>::const_iterator i=mFifos.begin();
129 encodeFifoStats(fifo, strm);
140 Lock lock(mFifosMutex);
141 return getCongestionPercentInternal(fifo);
145GeneralCongestionManager::getCongestionPercentInternal(
const FifoStatsInterface* fifo)
const
147 if(fifo->
getRole() >= mFifos.size())
153 const FifoInfo& info = mFifos[fifo->
getRole()];
171GeneralCongestionManager::encodeFifoStats(
const FifoStatsInterface& fifoStats,
EncodeStream& strm)
const
174 const FifoInfo& info = mFifos[fifoStats.getRole()];
175 strm <<fifoStats.getDescription()
176 <<
": Size=" << fifoStats.getCountDepth()
177 <<
" TimeDepth(sec)=" << fifoStats.getTimeDepth()
178 <<
" ExpWait(msec)=" << fifoStats.expectedWaitTimeMilliSec()
179 <<
" AvgSvcTime(usec)="
180 << fifoStats.averageServiceTimeMicroSec()
182 << (info.metric ==
WAIT_TIME ?
"WAIT_TIME" :
188 << (behavior ==
NORMAL ?
"NORMAL" :
190 "REJECTING_NON_ESSENTIAL");
#define WarningLog(args_)
#define resip_assert(x)
This file needs to work for both C and C++ code.
@ REJECTING_NEW_WORK
Overloaded, should refuse new work.
@ NORMAL
Not rejecting any work.
@ REJECTING_NON_ESSENTIAL
Rejecting all work that is non-essential to the health of the system (ie, if dropping something is li...
An iostream that operates on an existing Data.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
bool empty() const noexcept
Checks whether the Data is empty.
Interface for providing metrics on FIFOs, primarily used by CongestionManager.
virtual time_t getTimeDepth() const =0
Returns the difference in time between the youngest and oldest item in the FIFO in seconds.
virtual size_t getCountDepth() const =0
Returns the number of elements in the FIFO.
virtual time_t expectedWaitTimeMilliSec() const =0
Returns the expected time it will take to service all messages currently in the queue (in milli-secon...
void setRole(uint8_t role)
virtual EncodeStream & encodeCurrentState(EncodeStream &strm) const
Get the current state of all monitored fifos.to a stream.
virtual void logCurrentState() const
Log the current state of all monitored fifos.
virtual void unregisterFifo(resip::FifoStatsInterface *fifo)
Remove a fifo from the collection of fifos monitored by this CongestionManager.
virtual RejectionBehavior getRejectionBehavior(const FifoStatsInterface *fifo) const
Gets the current RejectionBehavior for this fifo, based only on the congestion-state of this fifo (ie...
virtual uint16_t getCongestionPercent(const FifoStatsInterface *fifo) const
Returns the percent of maximum tolerances that this queue is at.
virtual void registerFifo(resip::FifoStatsInterface *fifo, MetricType metric, uint32_t maxTolerance)
Add a fifo to the collection of fifos monitored by this CongestionManager, with a specified metric an...
MetricType
Enumeration of congestion metric types this class supports.
@ WAIT_TIME
The expected service time (the time it takes for new items to be serviced) This is the recommended me...
@ SIZE
The current size of the fifo.
@ TIME_DEPTH
The age of the oldest item in the fifo.
virtual ~GeneralCongestionManager()
virtual bool updateFifoTolerances(const resip::Data &fifoDescription, MetricType metric, uint32_t maxTolerance)
Update the metric type and tolerances of a given fifo that the GeneralCongestionManager is already aw...
dcm! – add UnusedChecking(_enum) below;
bool isEqualNoCase(const Data &left, const Data &right)
const _Tp1 resipIntDiv(const _Tp1 &__a, const _Tp2 &__b)
std::unique_lock< Mutex > Lock
A convenience class to lock a Lockable (such as a Mutex) on object creation, and unlock on destructio...