diff options
author | Jeff Ames | 2008-05-16 01:22:11 +0000 |
---|---|---|
committer | Jeff Ames | 2008-05-16 01:22:11 +0000 |
commit | 65c5efe43b68700bad94076d4cd421160203c5de (patch) | |
tree | 589b56649ed02f4942671fd6e51c6dc43f682e0d /OpenSim/Framework/Communications/Limit | |
parent | Thank you very much, mjm for : (diff) | |
download | opensim-SC_OLD-65c5efe43b68700bad94076d4cd421160203c5de.zip opensim-SC_OLD-65c5efe43b68700bad94076d4cd421160203c5de.tar.gz opensim-SC_OLD-65c5efe43b68700bad94076d4cd421160203c5de.tar.bz2 opensim-SC_OLD-65c5efe43b68700bad94076d4cd421160203c5de.tar.xz |
Formatting cleanup.
Diffstat (limited to 'OpenSim/Framework/Communications/Limit')
4 files changed, 52 insertions, 52 deletions
diff --git a/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs index 6ec21d9..1a9cc24 100644 --- a/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/IRequestLimitStrategy.cs | |||
@@ -31,9 +31,9 @@ namespace OpenSim.Framework.Communications.Limit | |||
31 | /// Interface for strategies that can limit requests from the client. Currently only used in the | 31 | /// Interface for strategies that can limit requests from the client. Currently only used in the |
32 | /// texture modules to deal with repeated requests for certain textures. However, limiting strategies | 32 | /// texture modules to deal with repeated requests for certain textures. However, limiting strategies |
33 | /// could be used with other requests. | 33 | /// could be used with other requests. |
34 | /// </summary> | 34 | /// </summary> |
35 | public interface IRequestLimitStrategy<TId> | 35 | public interface IRequestLimitStrategy<TId> |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// Should the request be allowed? If the id is not monitored, then the request is always allowed. | 38 | /// Should the request be allowed? If the id is not monitored, then the request is always allowed. |
39 | /// Otherwise, the strategy criteria will be applied. | 39 | /// Otherwise, the strategy criteria will be applied. |
@@ -41,21 +41,21 @@ namespace OpenSim.Framework.Communications.Limit | |||
41 | /// <param name="id"></param> | 41 | /// <param name="id"></param> |
42 | /// <returns></returns> | 42 | /// <returns></returns> |
43 | bool AllowRequest(TId id); | 43 | bool AllowRequest(TId id); |
44 | 44 | ||
45 | /// <summary> | 45 | /// <summary> |
46 | /// Has the request been refused just once? | 46 | /// Has the request been refused just once? |
47 | /// </summary> | 47 | /// </summary> |
48 | /// <returns>False if the request has not yet been refused, or if the request has been refused more | 48 | /// <returns>False if the request has not yet been refused, or if the request has been refused more |
49 | /// than once.</returns> | 49 | /// than once.</returns> |
50 | bool IsFirstRefusal(TId id); | 50 | bool IsFirstRefusal(TId id); |
51 | 51 | ||
52 | /// <summary> | 52 | /// <summary> |
53 | /// Start monitoring for future AllowRequest calls. If the id is already monitored, then monitoring | 53 | /// Start monitoring for future AllowRequest calls. If the id is already monitored, then monitoring |
54 | /// continues. | 54 | /// continues. |
55 | /// </summary> | 55 | /// </summary> |
56 | /// <param name="id"></param> | 56 | /// <param name="id"></param> |
57 | void MonitorRequests(TId id); | 57 | void MonitorRequests(TId id); |
58 | 58 | ||
59 | /// <summary> | 59 | /// <summary> |
60 | /// Is the id being monitored? | 60 | /// Is the id being monitored? |
61 | /// </summary> | 61 | /// </summary> |
diff --git a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs index 72d0586..932f780 100644 --- a/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/NullLimitStrategy.cs | |||
@@ -26,15 +26,15 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | namespace OpenSim.Framework.Communications.Limit | 28 | namespace OpenSim.Framework.Communications.Limit |
29 | { | 29 | { |
30 | /// <summary> | 30 | /// <summary> |
31 | /// Strategy which polices no limits | 31 | /// Strategy which polices no limits |
32 | /// </summary> | 32 | /// </summary> |
33 | public class NullLimitStrategy<TId> : IRequestLimitStrategy<TId> | 33 | public class NullLimitStrategy<TId> : IRequestLimitStrategy<TId> |
34 | { | 34 | { |
35 | public bool AllowRequest(TId id) { return true; } | 35 | public bool AllowRequest(TId id) { return true; } |
36 | public bool IsFirstRefusal(TId id) { return false; } | 36 | public bool IsFirstRefusal(TId id) { return false; } |
37 | public void MonitorRequests(TId id) { /* intentionally blank */ } | 37 | public void MonitorRequests(TId id) { /* intentionally blank */ } |
38 | public bool IsMonitoringRequests(TId id) { return false; } | 38 | public bool IsMonitoringRequests(TId id) { return false; } |
39 | } | 39 | } |
40 | } | 40 | } |
diff --git a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs index dfa05fa..bb72029 100644 --- a/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/RepeatLimitStrategy.cs | |||
@@ -31,14 +31,14 @@ namespace OpenSim.Framework.Communications.Limit | |||
31 | { | 31 | { |
32 | /// <summary> | 32 | /// <summary> |
33 | /// Limit requests by discarding them after they've been repeated a certain number of times. | 33 | /// Limit requests by discarding them after they've been repeated a certain number of times. |
34 | /// </summary> | 34 | /// </summary> |
35 | public class RepeatLimitStrategy<TId> : IRequestLimitStrategy<TId> | 35 | public class RepeatLimitStrategy<TId> : IRequestLimitStrategy<TId> |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// Record each asset request that we're notified about. | 38 | /// Record each asset request that we're notified about. |
39 | /// </summary> | 39 | /// </summary> |
40 | private readonly Dictionary<TId, int> requestCounts = new Dictionary<TId, int>(); | 40 | private readonly Dictionary<TId, int> requestCounts = new Dictionary<TId, int>(); |
41 | 41 | ||
42 | /// <summary> | 42 | /// <summary> |
43 | /// The maximum number of requests that can be made before we drop subsequent requests. | 43 | /// The maximum number of requests that can be made before we drop subsequent requests. |
44 | /// </summary> | 44 | /// </summary> |
@@ -47,7 +47,7 @@ namespace OpenSim.Framework.Communications.Limit | |||
47 | { | 47 | { |
48 | get { return m_maxRequests; } | 48 | get { return m_maxRequests; } |
49 | } | 49 | } |
50 | 50 | ||
51 | /// <summary></summary> | 51 | /// <summary></summary> |
52 | /// <param name="maxRequests">The maximum number of requests that may be served before all further | 52 | /// <param name="maxRequests">The maximum number of requests that may be served before all further |
53 | /// requests are dropped.</param> | 53 | /// requests are dropped.</param> |
@@ -55,52 +55,52 @@ namespace OpenSim.Framework.Communications.Limit | |||
55 | { | 55 | { |
56 | m_maxRequests = maxRequests; | 56 | m_maxRequests = maxRequests; |
57 | } | 57 | } |
58 | 58 | ||
59 | /// <summary> | 59 | /// <summary> |
60 | /// <see cref="IRequestLimitStrategy"/> | 60 | /// <see cref="IRequestLimitStrategy"/> |
61 | /// </summary> | 61 | /// </summary> |
62 | public bool AllowRequest(TId id) | 62 | public bool AllowRequest(TId id) |
63 | { | 63 | { |
64 | if (requestCounts.ContainsKey(id)) | 64 | if (requestCounts.ContainsKey(id)) |
65 | { | 65 | { |
66 | requestCounts[id] += 1; | 66 | requestCounts[id] += 1; |
67 | 67 | ||
68 | if (requestCounts[id] > m_maxRequests) | 68 | if (requestCounts[id] > m_maxRequests) |
69 | { | 69 | { |
70 | return false; | 70 | return false; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | return true; | 74 | return true; |
75 | } | 75 | } |
76 | 76 | ||
77 | /// <summary> | 77 | /// <summary> |
78 | /// <see cref="IRequestLimitStrategy"/> | 78 | /// <see cref="IRequestLimitStrategy"/> |
79 | /// </summary> | 79 | /// </summary> |
80 | public bool IsFirstRefusal(TId id) | 80 | public bool IsFirstRefusal(TId id) |
81 | { | 81 | { |
82 | if (requestCounts.ContainsKey(id) && m_maxRequests + 1 == requestCounts[id]) | 82 | if (requestCounts.ContainsKey(id) && m_maxRequests + 1 == requestCounts[id]) |
83 | { | 83 | { |
84 | return true; | 84 | return true; |
85 | } | 85 | } |
86 | 86 | ||
87 | return false; | 87 | return false; |
88 | } | 88 | } |
89 | 89 | ||
90 | /// <summary> | 90 | /// <summary> |
91 | /// <see cref="IRequestLimitStrategy"/> | 91 | /// <see cref="IRequestLimitStrategy"/> |
92 | /// </summary> | 92 | /// </summary> |
93 | public void MonitorRequests(TId id) | 93 | public void MonitorRequests(TId id) |
94 | { | 94 | { |
95 | if (!IsMonitoringRequests(id)) | 95 | if (!IsMonitoringRequests(id)) |
96 | { | 96 | { |
97 | requestCounts.Add(id, 1); | 97 | requestCounts.Add(id, 1); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | /// <summary> | 101 | /// <summary> |
102 | /// <see cref="IRequestLimitStrategy"/> | 102 | /// <see cref="IRequestLimitStrategy"/> |
103 | /// </summary> | 103 | /// </summary> |
104 | public bool IsMonitoringRequests(TId id) | 104 | public bool IsMonitoringRequests(TId id) |
105 | { | 105 | { |
106 | return requestCounts.ContainsKey(id); | 106 | return requestCounts.ContainsKey(id); |
diff --git a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs index 34b01ff..b5b925e 100644 --- a/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs +++ b/OpenSim/Framework/Communications/Limit/TimeLimitStrategy.cs | |||
@@ -32,17 +32,17 @@ namespace OpenSim.Framework.Communications.Limit | |||
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// Limit requests by discarding repeat attempts that occur within a given time period | 34 | /// Limit requests by discarding repeat attempts that occur within a given time period |
35 | /// | 35 | /// |
36 | /// XXX Don't use this for limiting texture downloading, at least not until we better handle multiple requests | 36 | /// XXX Don't use this for limiting texture downloading, at least not until we better handle multiple requests |
37 | /// for the same texture at different resolutions. | 37 | /// for the same texture at different resolutions. |
38 | /// </summary> | 38 | /// </summary> |
39 | public class TimeLimitStrategy<TId> : IRequestLimitStrategy<TId> | 39 | public class TimeLimitStrategy<TId> : IRequestLimitStrategy<TId> |
40 | { | 40 | { |
41 | /// <summary> | 41 | /// <summary> |
42 | /// Record the time at which an asset request occurs. | 42 | /// Record the time at which an asset request occurs. |
43 | /// </summary> | 43 | /// </summary> |
44 | private readonly Dictionary<TId, Request> requests = new Dictionary<TId, Request>(); | 44 | private readonly Dictionary<TId, Request> requests = new Dictionary<TId, Request>(); |
45 | 45 | ||
46 | /// <summary> | 46 | /// <summary> |
47 | /// The minimum time period between which requests for the same data will be serviced. | 47 | /// The minimum time period between which requests for the same data will be serviced. |
48 | /// </summary> | 48 | /// </summary> |
@@ -53,37 +53,37 @@ namespace OpenSim.Framework.Communications.Limit | |||
53 | } | 53 | } |
54 | 54 | ||
55 | /// <summary></summary> | 55 | /// <summary></summary> |
56 | /// <param name="repeatPeriod"></param> | 56 | /// <param name="repeatPeriod"></param> |
57 | public TimeLimitStrategy(TimeSpan repeatPeriod) | 57 | public TimeLimitStrategy(TimeSpan repeatPeriod) |
58 | { | 58 | { |
59 | m_repeatPeriod = repeatPeriod; | 59 | m_repeatPeriod = repeatPeriod; |
60 | } | 60 | } |
61 | 61 | ||
62 | /// <summary> | 62 | /// <summary> |
63 | /// <see cref="IRequestLimitStrategy"/> | 63 | /// <see cref="IRequestLimitStrategy"/> |
64 | /// </summary> | 64 | /// </summary> |
65 | public bool AllowRequest(TId id) | 65 | public bool AllowRequest(TId id) |
66 | { | 66 | { |
67 | if (IsMonitoringRequests(id)) | 67 | if (IsMonitoringRequests(id)) |
68 | { | 68 | { |
69 | DateTime now = DateTime.Now; | 69 | DateTime now = DateTime.Now; |
70 | TimeSpan elapsed = now - requests[id].Time; | 70 | TimeSpan elapsed = now - requests[id].Time; |
71 | 71 | ||
72 | if (elapsed < RepeatPeriod) | 72 | if (elapsed < RepeatPeriod) |
73 | { | 73 | { |
74 | requests[id].Refusals += 1; | 74 | requests[id].Refusals += 1; |
75 | return false; | 75 | return false; |
76 | } | 76 | } |
77 | 77 | ||
78 | requests[id].Time = now; | 78 | requests[id].Time = now; |
79 | } | 79 | } |
80 | 80 | ||
81 | return true; | 81 | return true; |
82 | } | 82 | } |
83 | 83 | ||
84 | /// <summary> | 84 | /// <summary> |
85 | /// <see cref="IRequestLimitStrategy"/> | 85 | /// <see cref="IRequestLimitStrategy"/> |
86 | /// </summary> | 86 | /// </summary> |
87 | public bool IsFirstRefusal(TId id) | 87 | public bool IsFirstRefusal(TId id) |
88 | { | 88 | { |
89 | if (IsMonitoringRequests(id)) | 89 | if (IsMonitoringRequests(id)) |
@@ -92,31 +92,31 @@ namespace OpenSim.Framework.Communications.Limit | |||
92 | { | 92 | { |
93 | return true; | 93 | return true; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | return false; | 97 | return false; |
98 | } | 98 | } |
99 | 99 | ||
100 | /// <summary> | 100 | /// <summary> |
101 | /// <see cref="IRequestLimitStrategy"/> | 101 | /// <see cref="IRequestLimitStrategy"/> |
102 | /// </summary> | 102 | /// </summary> |
103 | public void MonitorRequests(TId id) | 103 | public void MonitorRequests(TId id) |
104 | { | 104 | { |
105 | if (!IsMonitoringRequests(id)) | 105 | if (!IsMonitoringRequests(id)) |
106 | { | 106 | { |
107 | requests.Add(id, new Request(DateTime.Now)); | 107 | requests.Add(id, new Request(DateTime.Now)); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | /// <summary> | 111 | /// <summary> |
112 | /// <see cref="IRequestLimitStrategy"/> | 112 | /// <see cref="IRequestLimitStrategy"/> |
113 | /// </summary> | 113 | /// </summary> |
114 | public bool IsMonitoringRequests(TId id) | 114 | public bool IsMonitoringRequests(TId id) |
115 | { | 115 | { |
116 | return requests.ContainsKey(id); | 116 | return requests.ContainsKey(id); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | /// <summary> | 120 | /// <summary> |
121 | /// Private request details. | 121 | /// Private request details. |
122 | /// </summary> | 122 | /// </summary> |
@@ -126,12 +126,12 @@ namespace OpenSim.Framework.Communications.Limit | |||
126 | /// Time of last request | 126 | /// Time of last request |
127 | /// </summary> | 127 | /// </summary> |
128 | public DateTime Time; | 128 | public DateTime Time; |
129 | 129 | ||
130 | /// <summary> | 130 | /// <summary> |
131 | /// Number of refusals associated with this request | 131 | /// Number of refusals associated with this request |
132 | /// </summary> | 132 | /// </summary> |
133 | public int Refusals; | 133 | public int Refusals; |
134 | 134 | ||
135 | public Request(DateTime time) | 135 | public Request(DateTime time) |
136 | { | 136 | { |
137 | Time = time; | 137 | Time = time; |