Coverage Report

Created: 2024-04-23 06:04

/src/resiprocate/rutil/CongestionManager.hxx
Line
Count
Source (jump to first uncovered line)
1
#ifndef RESIP_CongestionManager_hxx
2
#define RESIP_CongestionManager_hxx 
3
4
#include "rutil/Data.hxx"
5
6
namespace resip
7
{
8
class FifoStatsInterface;
9
10
/**
11
   @brief Abstract base class that provides a basic congestion management 
12
   interface.
13
   The primary job of subclasses is to implement 
14
   getRejectionBehavior() such that it will return 
15
   REJECTING_NEW_WORK or REJECTING_NON_ESSENTIAL when sufficient congestion is 
16
   detected in the fifo in question. logCurrentState() is used to provide a 
17
   logging statement for the current state of the queueing system.
18
19
   In order to write a CongestionManager that determines congestion state for 
20
   specific fifos based on the state of the whole system, you will need to 
21
   override getRejectionBehavior() to examine the fifo being passed to determine 
22
   what role it has in the system (this is done by calling 
23
   FifoStatsInterface::getDescription()), and assigning a role-number that 
24
   designates the role of this fifo (this means you only need to perform a 
25
   string comparison the first time getRejectionBehavior() is called for a 
26
   particular fifo). Here are the returns you will get from 
27
   FifoStatsInterface::getDescription() on a number of key fifos in the 
28
   resiprocate stack:
29
30
   - TransactionController::mStateMacFifo
31
   - TlsTransport::mTxFifo
32
   - TcpTransport::mTxFifo
33
   - UdpTransport::mTxFifo
34
   - DnsStub::mCommandFifo
35
36
   The following fifos don't see much use, and are therefore not that vital, but they do have descriptions.
37
38
   - SipStack::mTUFifo
39
   - TuSelector::mShutdownFifo
40
41
   @ingroup message_passing
42
*/
43
class CongestionManager
44
{
45
46
   public:
47
48
   /**
49
      Constructor
50
   */
51
0
   CongestionManager(){};
52
0
   virtual ~CongestionManager(){};
53
54
   typedef enum
55
   {
56
      NORMAL=0, /**< Not rejecting any work. */
57
      REJECTING_NEW_WORK=1, /**< Overloaded, should refuse new work. Should not 
58
                                 refuse continuation of old work. */
59
      REJECTING_NON_ESSENTIAL=2 /**< Rejecting all work that is non-essential to 
60
                                 the health of the system (ie, if dropping 
61
                                 something is liable to cause a leak, 
62
                                 instability, or state-bloat, don't drop it. 
63
                                 Otherwise, reject it.) */
64
   } RejectionBehavior;
65
66
   /**
67
      Return the current rejection behavior for this fifo.
68
      This is the primary functionality provided by this class. Implementors may
69
      merely examine the current state of the fifo in question, or they may make
70
      the decision based on the state of the entire system.
71
      @param fifo The fifo in question.
72
      @return The current desired RejectionBehavior for the fifo.
73
   */
74
   virtual RejectionBehavior getRejectionBehavior(const FifoStatsInterface *fifo) const=0;
75
76
   /**
77
      Registers a fifo with the congestion manager. May be a no-op, or may 
78
      assign a role number to the fifo.
79
   */
80
   virtual void registerFifo(resip::FifoStatsInterface* fifo)=0;
81
82
   /**
83
      Unregisters a fifo with the congestion manager.
84
   */
85
   virtual void unregisterFifo(resip::FifoStatsInterface* fifo)=0;
86
87
   /**
88
      Log the current state of all monitored fifos.
89
   */
90
   virtual void logCurrentState() const=0;
91
92
   /**
93
      Get the current state of all monitored fifos.to a stream
94
   */
95
   virtual EncodeStream& encodeCurrentState(EncodeStream& strm) const=0;
96
97
};
98
99
100
} // namespace resip
101
102
#endif
103
104
/* ====================================================================
105
 * The Vovida Software License, Version 1.0 
106
 * 
107
 * Redistribution and use in source and binary forms, with or without
108
 * modification, are permitted provided that the following conditions
109
 * are met:
110
 * 
111
 * 1. Redistributions of source code must retain the above copyright
112
 *    notice, this list of conditions and the following disclaimer.
113
 * 
114
 * 2. Redistributions in binary form must reproduce the above copyright
115
 *    notice, this list of conditions and the following disclaimer in
116
 *    the documentation and/or other materials provided with the
117
 *    distribution.
118
 * 
119
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
120
 *    and "Vovida Open Communication Application Library (VOCAL)" must
121
 *    not be used to endorse or promote products derived from this
122
 *    software without prior written permission. For written
123
 *    permission, please contact vocal@vovida.org.
124
 *
125
 * 4. Products derived from this software may not be called "VOCAL", nor
126
 *    may "VOCAL" appear in their name, without prior written
127
 *    permission of Vovida Networks, Inc.
128
 * 
129
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
130
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
131
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
132
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
133
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
134
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
135
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
136
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
137
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
138
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
139
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
140
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
141
 * DAMAGE.
142
 * 
143
 * ====================================================================
144
 * 
145
 * This software consists of voluntary contributions made by Vovida
146
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
147
 * Inc.  For more information on Vovida Networks, Inc., please see
148
 * <http://www.vovida.org/>.
149
 *
150
 */