aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs34
1 files changed, 17 insertions, 17 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
index ab8d268..d215595 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs
@@ -76,8 +76,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
76 /// Map of children buckets and their requested maximum burst rate 76 /// Map of children buckets and their requested maximum burst rate
77 /// </summary> 77 /// </summary>
78 protected Dictionary<TokenBucket,Int64> m_children = new Dictionary<TokenBucket,Int64>(); 78 protected Dictionary<TokenBucket,Int64> m_children = new Dictionary<TokenBucket,Int64>();
79
80#region Properties
81 79
82 /// <summary> 80 /// <summary>
83 /// The parent bucket of this bucket, or null if this bucket has no 81 /// The parent bucket of this bucket, or null if this bucket has no
@@ -123,7 +121,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
123 /// RequestedDripRate is set to 0. Really, this should always return m_dripRate and then we can get 121 /// RequestedDripRate is set to 0. Really, this should always return m_dripRate and then we can get
124 /// (m_dripRate == 0 ? TotalDripRequest : m_dripRate) on some other properties. 122 /// (m_dripRate == 0 ? TotalDripRequest : m_dripRate) on some other properties.
125 /// </remarks> 123 /// </remarks>
126 protected Int64 m_dripRate;
127 public virtual Int64 RequestedDripRate 124 public virtual Int64 RequestedDripRate
128 { 125 {
129 get { return (m_dripRate == 0 ? TotalDripRequest : m_dripRate); } 126 get { return (m_dripRate == 0 ? TotalDripRequest : m_dripRate); }
@@ -179,6 +176,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
179 return (Int64)rate; 176 return (Int64)rate;
180 } 177 }
181 } 178 }
179 protected Int64 m_dripRate;
182 180
183 // <summary> 181 // <summary>
184 // The maximum rate for flow control. Drip rate can never be greater than this. 182 // The maximum rate for flow control. Drip rate can never be greater than this.
@@ -189,10 +187,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
189 /// The current total of the requested maximum burst rates of children buckets. 187 /// The current total of the requested maximum burst rates of children buckets.
190 /// </summary> 188 /// </summary>
191 public Int64 TotalDripRequest { get; protected set; } 189 public Int64 TotalDripRequest { get; protected set; }
192
193#endregion Properties
194
195#region Constructor
196 190
197 /// <summary> 191 /// <summary>
198 /// Default constructor 192 /// Default constructor
@@ -200,20 +194,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
200 /// <param name="identifier">Identifier for this token bucket</param> 194 /// <param name="identifier">Identifier for this token bucket</param>
201 /// <param name="parent">Parent bucket if this is a child bucket, or 195 /// <param name="parent">Parent bucket if this is a child bucket, or
202 /// null if this is a root bucket</param> 196 /// null if this is a root bucket</param>
203 /// <param name="dripRate">Rate that the bucket fills, in bytes per 197 /// <param name="requestedDripRate">
204 /// second. If zero, the bucket always remains full</param> 198 /// Requested rate that the bucket fills, in bytes per
205 public TokenBucket(string identifier, TokenBucket parent, Int64 dripRate, Int64 maxDripRate) 199 /// second. If zero, the bucket always remains full.
200 /// </param>
201 public TokenBucket(string identifier, TokenBucket parent, Int64 requestedDripRate, Int64 maxDripRate)
206 { 202 {
207 Identifier = identifier; 203 Identifier = identifier;
208 204
209 Parent = parent; 205 Parent = parent;
210 RequestedDripRate = dripRate; 206 RequestedDripRate = requestedDripRate;
211 MaxDripRate = maxDripRate; 207 MaxDripRate = maxDripRate;
212 m_lastDrip = Util.EnvironmentTickCount(); 208 m_lastDrip = Util.EnvironmentTickCount();
213 } 209 }
214 210
215#endregion Constructor
216
217 /// <summary> 211 /// <summary>
218 /// Compute a modifier for the MaxBurst rate. This is 1.0, meaning 212 /// Compute a modifier for the MaxBurst rate. This is 1.0, meaning
219 /// no modification if the requested bandwidth is less than the 213 /// no modification if the requested bandwidth is less than the
@@ -374,7 +368,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
374 public Int64 TargetDripRate 368 public Int64 TargetDripRate
375 { 369 {
376 get { return m_targetDripRate; } 370 get { return m_targetDripRate; }
377 set { m_targetDripRate = Math.Max(0, value); } 371 set
372 {
373 m_targetDripRate = Math.Max(value, m_minimumFlow);
374 }
378 } 375 }
379 protected Int64 m_targetDripRate; 376 protected Int64 m_targetDripRate;
380 377
@@ -384,9 +381,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
384 public virtual Int64 AdjustedDripRate 381 public virtual Int64 AdjustedDripRate
385 { 382 {
386 get { return m_dripRate; } 383 get { return m_dripRate; }
387 set { 384 set
385 {
388 m_dripRate = OpenSim.Framework.Util.Clamp<Int64>(value, m_minimumFlow, TargetDripRate); 386 m_dripRate = OpenSim.Framework.Util.Clamp<Int64>(value, m_minimumFlow, TargetDripRate);
389 m_burstRate = (Int64)((double)m_dripRate * m_quantumsPerBurst); 387 m_burstRate = (Int64)((double)m_dripRate * m_quantumsPerBurst);
388
390 if (Parent != null) 389 if (Parent != null)
391 Parent.RegisterRequest(this, m_dripRate); 390 Parent.RegisterRequest(this, m_dripRate);
392 } 391 }
@@ -399,14 +398,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
399 /// </summary> 398 /// </summary>
400 protected const Int64 m_minimumFlow = m_minimumDripRate * 15; 399 protected const Int64 m_minimumFlow = m_minimumDripRate * 15;
401 400
402 public AdaptiveTokenBucket(string identifier, TokenBucket parent, Int64 dripRate, Int64 maxDripRate, bool enabled) 401 public AdaptiveTokenBucket(string identifier, TokenBucket parent, Int64 requestedDripRate, Int64 maxDripRate, bool enabled)
403 : base(identifier, parent, dripRate, maxDripRate) 402 : base(identifier, parent, requestedDripRate, maxDripRate)
404 { 403 {
405 AdaptiveEnabled = enabled; 404 AdaptiveEnabled = enabled;
406 405
407 if (AdaptiveEnabled) 406 if (AdaptiveEnabled)
408 { 407 {
409// m_log.DebugFormat("[TOKENBUCKET]: Adaptive throttle enabled"); 408// m_log.DebugFormat("[TOKENBUCKET]: Adaptive throttle enabled");
409 TargetDripRate = m_minimumFlow;
410 AdjustedDripRate = m_minimumFlow; 410 AdjustedDripRate = m_minimumFlow;
411 } 411 }
412 } 412 }