diff options
author | Melanie | 2010-12-30 01:40:38 +0000 |
---|---|---|
committer | Melanie | 2010-12-30 01:40:38 +0000 |
commit | 3b50066ceb620ec00c50e3ea52be398e9914afdc (patch) | |
tree | af41bb529e93a0d2cf5e2ee002f0231d300c0d16 /OpenSim/Services/Connectors/SimianGrid | |
parent | Implement SendPlacesReply (diff) | |
parent | Implement SendPlacesReply (diff) | |
download | opensim-SC_OLD-3b50066ceb620ec00c50e3ea52be398e9914afdc.zip opensim-SC_OLD-3b50066ceb620ec00c50e3ea52be398e9914afdc.tar.gz opensim-SC_OLD-3b50066ceb620ec00c50e3ea52be398e9914afdc.tar.bz2 opensim-SC_OLD-3b50066ceb620ec00c50e3ea52be398e9914afdc.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Services/Connectors/SimianGrid')
-rw-r--r-- | OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs | 118 |
1 files changed, 50 insertions, 68 deletions
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs index f86eba3..5584c62 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs | |||
@@ -51,51 +51,21 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
51 | /// Connects region registration and neighbor lookups to the SimianGrid | 51 | /// Connects region registration and neighbor lookups to the SimianGrid |
52 | /// backend | 52 | /// backend |
53 | /// </summary> | 53 | /// </summary> |
54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 54 | public class SimianGridServiceConnector : IGridService |
55 | public class SimianGridServiceConnector : IGridService, ISharedRegionModule | ||
56 | { | 55 | { |
57 | private static readonly ILog m_log = | 56 | private static readonly ILog m_log = |
58 | LogManager.GetLogger( | 57 | LogManager.GetLogger( |
59 | MethodBase.GetCurrentMethod().DeclaringType); | 58 | MethodBase.GetCurrentMethod().DeclaringType); |
60 | 59 | ||
61 | private string m_serverUrl = String.Empty; | 60 | private string m_ServerURI = String.Empty; |
62 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); | ||
63 | private bool m_Enabled = false; | 61 | private bool m_Enabled = false; |
64 | 62 | ||
65 | #region ISharedRegionModule | ||
66 | |||
67 | public Type ReplaceableInterface { get { return null; } } | ||
68 | public void RegionLoaded(Scene scene) { } | ||
69 | public void PostInitialise() { } | ||
70 | public void Close() { } | ||
71 | |||
72 | public SimianGridServiceConnector() { } | 63 | public SimianGridServiceConnector() { } |
73 | public string Name { get { return "SimianGridServiceConnector"; } } | 64 | public SimianGridServiceConnector(string serverURI) |
74 | public void AddRegion(Scene scene) | ||
75 | { | ||
76 | if (!m_Enabled) | ||
77 | return; | ||
78 | |||
79 | // Every shared region module has to maintain an indepedent list of | ||
80 | // currently running regions | ||
81 | lock (m_scenes) | ||
82 | m_scenes[scene.RegionInfo.RegionID] = scene; | ||
83 | |||
84 | scene.RegisterModuleInterface<IGridService>(this); | ||
85 | } | ||
86 | public void RemoveRegion(Scene scene) | ||
87 | { | 65 | { |
88 | if (!m_Enabled) | 66 | m_ServerURI = serverURI.TrimEnd('/'); |
89 | return; | ||
90 | |||
91 | lock (m_scenes) | ||
92 | m_scenes.Remove(scene.RegionInfo.RegionID); | ||
93 | |||
94 | scene.UnregisterModuleInterface<IGridService>(this); | ||
95 | } | 67 | } |
96 | 68 | ||
97 | #endregion ISharedRegionModule | ||
98 | |||
99 | public SimianGridServiceConnector(IConfigSource source) | 69 | public SimianGridServiceConnector(IConfigSource source) |
100 | { | 70 | { |
101 | CommonInit(source); | 71 | CommonInit(source); |
@@ -103,32 +73,29 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
103 | 73 | ||
104 | public void Initialise(IConfigSource source) | 74 | public void Initialise(IConfigSource source) |
105 | { | 75 | { |
106 | IConfig moduleConfig = source.Configs["Modules"]; | 76 | CommonInit(source); |
107 | if (moduleConfig != null) | ||
108 | { | ||
109 | string name = moduleConfig.GetString("GridServices", ""); | ||
110 | if (name == Name) | ||
111 | CommonInit(source); | ||
112 | } | ||
113 | } | 77 | } |
114 | 78 | ||
115 | private void CommonInit(IConfigSource source) | 79 | private void CommonInit(IConfigSource source) |
116 | { | 80 | { |
117 | IConfig gridConfig = source.Configs["GridService"]; | 81 | IConfig gridConfig = source.Configs["GridService"]; |
118 | if (gridConfig != null) | 82 | if (gridConfig == null) |
119 | { | 83 | { |
120 | string serviceUrl = gridConfig.GetString("GridServerURI"); | 84 | m_log.Error("[SIMIAN GRID CONNECTOR]: GridService missing from OpenSim.ini"); |
121 | if (!String.IsNullOrEmpty(serviceUrl)) | 85 | throw new Exception("Grid connector init error"); |
122 | { | ||
123 | if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) | ||
124 | serviceUrl = serviceUrl + '/'; | ||
125 | m_serverUrl = serviceUrl; | ||
126 | m_Enabled = true; | ||
127 | } | ||
128 | } | 86 | } |
129 | 87 | ||
130 | if (String.IsNullOrEmpty(m_serverUrl)) | 88 | string serviceUrl = gridConfig.GetString("GridServerURI"); |
131 | m_log.Info("[SIMIAN GRID CONNECTOR]: No GridServerURI specified, disabling connector"); | 89 | if (String.IsNullOrEmpty(serviceUrl)) |
90 | { | ||
91 | m_log.Error("[SIMIAN GRID CONNECTOR]: No Server URI named in section GridService"); | ||
92 | throw new Exception("Grid connector init error"); | ||
93 | } | ||
94 | |||
95 | if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) | ||
96 | serviceUrl = serviceUrl + '/'; | ||
97 | m_ServerURI = serviceUrl; | ||
98 | m_Enabled = true; | ||
132 | } | 99 | } |
133 | 100 | ||
134 | #region IGridService | 101 | #region IGridService |
@@ -138,11 +105,11 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
138 | IPEndPoint ext = regionInfo.ExternalEndPoint; | 105 | IPEndPoint ext = regionInfo.ExternalEndPoint; |
139 | if (ext == null) return "Region registration for " + regionInfo.RegionName + " failed: Could not resolve EndPoint"; | 106 | if (ext == null) return "Region registration for " + regionInfo.RegionName + " failed: Could not resolve EndPoint"; |
140 | // Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service | 107 | // Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service |
141 | Scene scene; | 108 | // Scene scene; |
142 | if (m_scenes.TryGetValue(regionInfo.RegionID, out scene)) | 109 | // if (m_scenes.TryGetValue(regionInfo.RegionID, out scene)) |
143 | UploadMapTile(scene); | 110 | // UploadMapTile(scene); |
144 | else | 111 | // else |
145 | m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking"); | 112 | // m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking"); |
146 | 113 | ||
147 | Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); | 114 | Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); |
148 | Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, 4096.0); | 115 | Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, 4096.0); |
@@ -173,7 +140,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
173 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } | 140 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } |
174 | }; | 141 | }; |
175 | 142 | ||
176 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 143 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); |
177 | if (response["Success"].AsBoolean()) | 144 | if (response["Success"].AsBoolean()) |
178 | return String.Empty; | 145 | return String.Empty; |
179 | else | 146 | else |
@@ -189,7 +156,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
189 | { "Enabled", "0" } | 156 | { "Enabled", "0" } |
190 | }; | 157 | }; |
191 | 158 | ||
192 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 159 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); |
193 | bool success = response["Success"].AsBoolean(); | 160 | bool success = response["Success"].AsBoolean(); |
194 | 161 | ||
195 | if (!success) | 162 | if (!success) |
@@ -234,9 +201,12 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
234 | { "SceneID", regionID.ToString() } | 201 | { "SceneID", regionID.ToString() } |
235 | }; | 202 | }; |
236 | 203 | ||
237 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 204 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString()); |
205 | |||
206 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | ||
238 | if (response["Success"].AsBoolean()) | 207 | if (response["Success"].AsBoolean()) |
239 | { | 208 | { |
209 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString()); | ||
240 | return ResponseToGridRegion(response); | 210 | return ResponseToGridRegion(response); |
241 | } | 211 | } |
242 | else | 212 | else |
@@ -259,15 +229,18 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
259 | { "Enabled", "1" } | 229 | { "Enabled", "1" } |
260 | }; | 230 | }; |
261 | 231 | ||
262 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 232 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString()); |
233 | |||
234 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | ||
263 | if (response["Success"].AsBoolean()) | 235 | if (response["Success"].AsBoolean()) |
264 | { | 236 | { |
237 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString()); | ||
265 | return ResponseToGridRegion(response); | 238 | return ResponseToGridRegion(response); |
266 | } | 239 | } |
267 | else | 240 | else |
268 | { | 241 | { |
269 | //m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}", | 242 | // m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}", |
270 | // x / Constants.RegionSize, y / Constants.RegionSize); | 243 | // x / Constants.RegionSize, y / Constants.RegionSize); |
271 | return null; | 244 | return null; |
272 | } | 245 | } |
273 | } | 246 | } |
@@ -297,9 +270,13 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
297 | if (maxNumber > 0) | 270 | if (maxNumber > 0) |
298 | requestArgs["MaxNumber"] = maxNumber.ToString(); | 271 | requestArgs["MaxNumber"] = maxNumber.ToString(); |
299 | 272 | ||
300 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 273 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name); |
274 | |||
275 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | ||
301 | if (response["Success"].AsBoolean()) | 276 | if (response["Success"].AsBoolean()) |
302 | { | 277 | { |
278 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); | ||
279 | |||
303 | OSDArray array = response["Scenes"] as OSDArray; | 280 | OSDArray array = response["Scenes"] as OSDArray; |
304 | if (array != null) | 281 | if (array != null) |
305 | { | 282 | { |
@@ -330,7 +307,10 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
330 | { "Enabled", "1" } | 307 | { "Enabled", "1" } |
331 | }; | 308 | }; |
332 | 309 | ||
333 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 310 | m_log.WarnFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString()); |
311 | |||
312 | |||
313 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | ||
334 | if (response["Success"].AsBoolean()) | 314 | if (response["Success"].AsBoolean()) |
335 | { | 315 | { |
336 | OSDArray array = response["Scenes"] as OSDArray; | 316 | OSDArray array = response["Scenes"] as OSDArray; |
@@ -386,7 +366,9 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
386 | { "SceneID", regionID.ToString() } | 366 | { "SceneID", regionID.ToString() } |
387 | }; | 367 | }; |
388 | 368 | ||
389 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 369 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString()); |
370 | |||
371 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | ||
390 | if (response["Success"].AsBoolean()) | 372 | if (response["Success"].AsBoolean()) |
391 | { | 373 | { |
392 | return response["Enabled"].AsBoolean() ? REGION_ONLINE : 0; | 374 | return response["Enabled"].AsBoolean() ? REGION_ONLINE : 0; |
@@ -432,7 +414,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
432 | // Make the remote storage request | 414 | // Make the remote storage request |
433 | try | 415 | try |
434 | { | 416 | { |
435 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl); | 417 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI); |
436 | 418 | ||
437 | HttpWebResponse response = MultipartForm.Post(request, postParameters); | 419 | HttpWebResponse response = MultipartForm.Post(request, postParameters); |
438 | using (Stream responseStream = response.GetResponseStream()) | 420 | using (Stream responseStream = response.GetResponseStream()) |
@@ -488,7 +470,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
488 | if (onlyEnabled) | 470 | if (onlyEnabled) |
489 | requestArgs["Enabled"] = "1"; | 471 | requestArgs["Enabled"] = "1"; |
490 | 472 | ||
491 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 473 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); |
492 | if (response["Success"].AsBoolean()) | 474 | if (response["Success"].AsBoolean()) |
493 | { | 475 | { |
494 | return ResponseToGridRegion(response); | 476 | return ResponseToGridRegion(response); |