reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
GeneralCongestionManager.hxx
Go to the documentation of this file.
1#ifndef GENERAL_CONGESTION_MANAGER_HXX
2#define GENERAL_CONGESTION_MANAGER_HXX
3
5#include "rutil/Mutex.hxx"
6
7#include <vector>
8
9namespace resip
10{
25{
26 public:
30 typedef enum
31 {
32 SIZE=0,
36
54 uint32_t defaultMaxTolerance);
56
85 virtual bool updateFifoTolerances(const resip::Data& fifoDescription,
86 MetricType metric,
87 uint32_t maxTolerance );
88
108 virtual void registerFifo(resip::FifoStatsInterface* fifo,
109 MetricType metric,
110 uint32_t maxTolerance );
111
118 {
119 registerFifo(fifo, mDefaultMetric, mDefaultMaxTolerance);
120 }
121
127 virtual void unregisterFifo(resip::FifoStatsInterface* fifo);
128
136
140 virtual uint16_t getCongestionPercent(const FifoStatsInterface* fifo) const;
141
142 virtual void logCurrentState() const;
143 virtual EncodeStream& encodeCurrentState(EncodeStream& strm) const;
144
145 private:
146 virtual RejectionBehavior getRejectionBehaviorInternal(const FifoStatsInterface *fifo) const;
147 uint16_t getCongestionPercentInternal(const FifoStatsInterface* fifo) const;
148
149 virtual EncodeStream& encodeFifoStats(const FifoStatsInterface& fifoStats, EncodeStream& strm) const;
150
151 typedef struct
152 {
153 FifoStatsInterface* fifo;
154 volatile MetricType metric;
155 volatile uint32_t maxTolerance;
156 } FifoInfo; // !bwc! TODO pick a better name
157
158 std::vector<FifoInfo> mFifos;
159 // !slg! would love to get rid of the following mutex - but we need to protect
160 // threads querying the congestion stats and make sure runtime transport
161 // additions are safe (ie: registerFifo and unregisterFifo being called
162 // when the fifos are in full motion.
163 mutable Mutex mFifosMutex;
164 uint16_t mRejectionThresholds[REJECTING_NON_ESSENTIAL+1];
165 MetricType mDefaultMetric;
166 uint32_t mDefaultMaxTolerance;
167
168 // disabled
169 GeneralCongestionManager();
170 GeneralCongestionManager(const GeneralCongestionManager& orig);
171 GeneralCongestionManager& operator=(const GeneralCongestionManager& rhs);
172};
173}
174
175#endif
176
177/* ====================================================================
178 * The Vovida Software License, Version 1.0
179 *
180 * Redistribution and use in source and binary forms, with or without
181 * modification, are permitted provided that the following conditions
182 * are met:
183 *
184 * 1. Redistributions of source code must retain the above copyright
185 * notice, this list of conditions and the following disclaimer.
186 *
187 * 2. Redistributions in binary form must reproduce the above copyright
188 * notice, this list of conditions and the following disclaimer in
189 * the documentation and/or other materials provided with the
190 * distribution.
191 *
192 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
193 * and "Vovida Open Communication Application Library (VOCAL)" must
194 * not be used to endorse or promote products derived from this
195 * software without prior written permission. For written
196 * permission, please contact vocal@vovida.org.
197 *
198 * 4. Products derived from this software may not be called "VOCAL", nor
199 * may "VOCAL" appear in their name, without prior written
200 * permission of Vovida Networks, Inc.
201 *
202 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
203 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
204 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
205 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
206 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
207 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
208 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
209 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
210 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
211 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
212 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
213 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
214 * DAMAGE.
215 *
216 * ====================================================================
217 *
218 * This software consists of voluntary contributions made by Vovida
219 * Networks, Inc. and many individuals on behalf of Vovida Networks,
220 * Inc. For more information on Vovida Networks, Inc., please see
221 * <http://www.vovida.org/>.
222 *
223 */
Abstract base class that provides a basic congestion management interface.
@ REJECTING_NON_ESSENTIAL
Rejecting all work that is non-essential to the health of the system (ie, if dropping something is li...
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
Interface for providing metrics on FIFOs, primarily used by CongestionManager.
This is a general-purpose congestion manager.
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 registerFifo(resip::FifoStatsInterface *fifo)
Add a fifo to the collection of fifos monitored by this CongestionManager, with the default metric an...
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 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;
std::mutex Mutex
A semaphore that can be locked by only one thread at a time.
Definition Mutex.hxx:37
unsigned short uint16_t
Definition Stun.hxx:30
unsigned int uint32_t
Definition Stun.hxx:34
#define EncodeStream
unsigned short uint16_t
Definition stdint.h:84
unsigned int uint32_t
Definition stdint.h:85