aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs161
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs18
2 files changed, 161 insertions, 18 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs b/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs
new file mode 100644
index 0000000..5511fea
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs
@@ -0,0 +1,161 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Threading;
32using log4net;
33using Mono.Addins;
34using Nini.Config;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Framework.Monitoring;
39using OpenSim.Region.Framework.Scenes;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42namespace OpenSim.Region.CoreModules.Framework
43{
44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GridServiceThrottleModule")]
45 public class GridServiceThrottleModule : ISharedRegionModule
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 private readonly List<Scene> m_scenes = new List<Scene>();
51
52 private OpenSim.Framework.BlockingQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<GridRegionRequest>();
53
54 public void Initialise(IConfigSource config)
55 {
56 Watchdog.StartThread(
57 ProcessQueue,
58 "GridServiceRequestThread",
59 ThreadPriority.BelowNormal,
60 true,
61 true);
62 }
63
64 public void AddRegion(Scene scene)
65 {
66 lock (m_scenes)
67 {
68 m_scenes.Add(scene);
69 scene.EventManager.OnNewClient += OnNewClient;
70 }
71 }
72
73 public void RegionLoaded(Scene scene)
74 {
75 }
76
77 public void RemoveRegion(Scene scene)
78 {
79 lock (m_scenes)
80 {
81 m_scenes.Remove(scene);
82 scene.EventManager.OnNewClient -= OnNewClient;
83 }
84 }
85
86 void OnNewClient(IClientAPI client)
87 {
88 client.OnRegionHandleRequest += OnRegionHandleRequest;
89 }
90
91 public void PostInitialise()
92 {
93 }
94
95 public void Close()
96 {
97 }
98
99 public string Name
100 {
101 get { return "GridServiceThrottleModule"; }
102 }
103
104 public Type ReplaceableInterface
105 {
106 get { return null; }
107 }
108
109 public void OnRegionHandleRequest(IClientAPI client, UUID regionID)
110 {
111 m_log.DebugFormat("[GRIDSERVICE THROTTLE]: RegionHandleRequest {0}", regionID);
112 ulong handle = 0;
113 if (IsLocalRegionHandle(regionID, out handle))
114 {
115 client.SendRegionHandle(regionID, handle);
116 return;
117 }
118
119 GridRegionRequest request = new GridRegionRequest(client, regionID);
120 m_RequestQueue.Enqueue(request);
121
122 }
123
124 private bool IsLocalRegionHandle(UUID regionID, out ulong regionHandle)
125 {
126 regionHandle = 0;
127 foreach (Scene s in m_scenes)
128 if (s.RegionInfo.RegionID == regionID)
129 {
130 regionHandle = s.RegionInfo.RegionHandle;
131 return true;
132 }
133 return false;
134 }
135
136 private void ProcessQueue()
137 {
138 while (true)
139 {
140 GridRegionRequest request = m_RequestQueue.Dequeue();
141 GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, request.regionID);
142
143 if (r != null && r.RegionHandle != 0)
144 request.client.SendRegionHandle(request.regionID, r.RegionHandle);
145
146 }
147 }
148 }
149
150 class GridRegionRequest
151 {
152 public IClientAPI client;
153 public UUID regionID;
154
155 public GridRegionRequest(IClientAPI c, UUID r)
156 {
157 client = c;
158 regionID = r;
159 }
160 }
161}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index aa14529..355e0ee 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3103,7 +3103,6 @@ namespace OpenSim.Region.Framework.Scenes
3103 { 3103 {
3104 //client.OnNameFromUUIDRequest += HandleUUIDNameRequest; 3104 //client.OnNameFromUUIDRequest += HandleUUIDNameRequest;
3105 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; 3105 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
3106 client.OnRegionHandleRequest += RegionHandleRequest;
3107 } 3106 }
3108 3107
3109 public virtual void SubscribeToClientNetworkEvents(IClientAPI client) 3108 public virtual void SubscribeToClientNetworkEvents(IClientAPI client)
@@ -3227,7 +3226,6 @@ namespace OpenSim.Region.Framework.Scenes
3227 { 3226 {
3228 //client.OnNameFromUUIDRequest -= HandleUUIDNameRequest; 3227 //client.OnNameFromUUIDRequest -= HandleUUIDNameRequest;
3229 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; 3228 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest;
3230 client.OnRegionHandleRequest -= RegionHandleRequest;
3231 } 3229 }
3232 3230
3233 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client) 3231 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client)
@@ -4887,22 +4885,6 @@ namespace OpenSim.Region.Framework.Scenes
4887 4885
4888 #endregion 4886 #endregion
4889 4887
4890 public void RegionHandleRequest(IClientAPI client, UUID regionID)
4891 {
4892 m_log.DebugFormat("[SCENE]: RegionHandleRequest {0}", regionID);
4893 ulong handle = 0;
4894 if (regionID == RegionInfo.RegionID)
4895 handle = RegionInfo.RegionHandle;
4896 else
4897 {
4898 GridRegion r = GridService.GetRegionByUUID(UUID.Zero, regionID);
4899 if (r != null)
4900 handle = r.RegionHandle;
4901 }
4902
4903 if (handle != 0)
4904 client.SendRegionHandle(regionID, handle);
4905 }
4906 4888
4907// Commented pending deletion since this method no longer appears to do anything at all 4889// Commented pending deletion since this method no longer appears to do anything at all
4908// public bool NeedSceneCacheClear(UUID agentID) 4890// public bool NeedSceneCacheClear(UUID agentID)