diff options
author | Mic Bowman | 2010-12-27 17:18:49 -0800 |
---|---|---|
committer | Mic Bowman | 2010-12-27 17:18:49 -0800 |
commit | 94ed69b1daaf4ea3e9431cb739b79dce808573d0 (patch) | |
tree | d2112082bf784a3e74a1ead080c37a84c3968903 /OpenSim/Services/Connectors/SimianGrid | |
parent | No need for these methods to be virtual now. (diff) | |
download | opensim-SC-94ed69b1daaf4ea3e9431cb739b79dce808573d0.zip opensim-SC-94ed69b1daaf4ea3e9431cb739b79dce808573d0.tar.gz opensim-SC-94ed69b1daaf4ea3e9431cb739b79dce808573d0.tar.bz2 opensim-SC-94ed69b1daaf4ea3e9431cb739b79dce808573d0.tar.xz |
Update SimianGridServicesConnector to work more like
a connector so we can take advantage of the logic in
RemoteGridServicesConnector.
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 8076fab..2f61538 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 |
@@ -136,11 +103,11 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
136 | public string RegisterRegion(UUID scopeID, GridRegion regionInfo) | 103 | public string RegisterRegion(UUID scopeID, GridRegion regionInfo) |
137 | { | 104 | { |
138 | // Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service | 105 | // Generate and upload our map tile in PNG format to the SimianGrid AddMapTile service |
139 | Scene scene; | 106 | // Scene scene; |
140 | if (m_scenes.TryGetValue(regionInfo.RegionID, out scene)) | 107 | // if (m_scenes.TryGetValue(regionInfo.RegionID, out scene)) |
141 | UploadMapTile(scene); | 108 | // UploadMapTile(scene); |
142 | else | 109 | // else |
143 | m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking"); | 110 | // m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking"); |
144 | 111 | ||
145 | Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); | 112 | Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); |
146 | Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, 4096.0); | 113 | Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, 4096.0); |
@@ -171,7 +138,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
171 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } | 138 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } |
172 | }; | 139 | }; |
173 | 140 | ||
174 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 141 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); |
175 | if (response["Success"].AsBoolean()) | 142 | if (response["Success"].AsBoolean()) |
176 | return String.Empty; | 143 | return String.Empty; |
177 | else | 144 | else |
@@ -187,7 +154,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
187 | { "Enabled", "0" } | 154 | { "Enabled", "0" } |
188 | }; | 155 | }; |
189 | 156 | ||
190 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 157 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); |
191 | bool success = response["Success"].AsBoolean(); | 158 | bool success = response["Success"].AsBoolean(); |
192 | 159 | ||
193 | if (!success) | 160 | if (!success) |
@@ -232,9 +199,12 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
232 | { "SceneID", regionID.ToString() } | 199 | { "SceneID", regionID.ToString() } |
233 | }; | 200 | }; |
234 | 201 | ||
235 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 202 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString()); |
203 | |||
204 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | ||
236 | if (response["Success"].AsBoolean()) | 205 | if (response["Success"].AsBoolean()) |
237 | { | 206 | { |
207 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString()); | ||
238 | return ResponseToGridRegion(response); | 208 | return ResponseToGridRegion(response); |
239 | } | 209 | } |
240 | else | 210 | else |
@@ -257,15 +227,18 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
257 | { "Enabled", "1" } | 227 | { "Enabled", "1" } |
258 | }; | 228 | }; |
259 | 229 | ||
260 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 230 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString()); |
231 | |||
232 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | ||
261 | if (response["Success"].AsBoolean()) | 233 | if (response["Success"].AsBoolean()) |
262 | { | 234 | { |
235 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString()); | ||
263 | return ResponseToGridRegion(response); | 236 | return ResponseToGridRegion(response); |
264 | } | 237 | } |
265 | else | 238 | else |
266 | { | 239 | { |
267 | //m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}", | 240 | // m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}", |
268 | // x / Constants.RegionSize, y / Constants.RegionSize); | 241 | // x / Constants.RegionSize, y / Constants.RegionSize); |
269 | return null; | 242 | return null; |
270 | } | 243 | } |
271 | } | 244 | } |
@@ -295,9 +268,13 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
295 | if (maxNumber > 0) | 268 | if (maxNumber > 0) |
296 | requestArgs["MaxNumber"] = maxNumber.ToString(); | 269 | requestArgs["MaxNumber"] = maxNumber.ToString(); |
297 | 270 | ||
298 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 271 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name); |
272 | |||
273 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | ||
299 | if (response["Success"].AsBoolean()) | 274 | if (response["Success"].AsBoolean()) |
300 | { | 275 | { |
276 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); | ||
277 | |||
301 | OSDArray array = response["Scenes"] as OSDArray; | 278 | OSDArray array = response["Scenes"] as OSDArray; |
302 | if (array != null) | 279 | if (array != null) |
303 | { | 280 | { |
@@ -328,7 +305,10 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
328 | { "Enabled", "1" } | 305 | { "Enabled", "1" } |
329 | }; | 306 | }; |
330 | 307 | ||
331 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 308 | m_log.WarnFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString()); |
309 | |||
310 | |||
311 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | ||
332 | if (response["Success"].AsBoolean()) | 312 | if (response["Success"].AsBoolean()) |
333 | { | 313 | { |
334 | OSDArray array = response["Scenes"] as OSDArray; | 314 | OSDArray array = response["Scenes"] as OSDArray; |
@@ -384,7 +364,9 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
384 | { "SceneID", regionID.ToString() } | 364 | { "SceneID", regionID.ToString() } |
385 | }; | 365 | }; |
386 | 366 | ||
387 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 367 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString()); |
368 | |||
369 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | ||
388 | if (response["Success"].AsBoolean()) | 370 | if (response["Success"].AsBoolean()) |
389 | { | 371 | { |
390 | return response["Enabled"].AsBoolean() ? REGION_ONLINE : 0; | 372 | return response["Enabled"].AsBoolean() ? REGION_ONLINE : 0; |
@@ -430,7 +412,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
430 | // Make the remote storage request | 412 | // Make the remote storage request |
431 | try | 413 | try |
432 | { | 414 | { |
433 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl); | 415 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI); |
434 | 416 | ||
435 | HttpWebResponse response = MultipartForm.Post(request, postParameters); | 417 | HttpWebResponse response = MultipartForm.Post(request, postParameters); |
436 | using (Stream responseStream = response.GetResponseStream()) | 418 | using (Stream responseStream = response.GetResponseStream()) |
@@ -486,7 +468,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
486 | if (onlyEnabled) | 468 | if (onlyEnabled) |
487 | requestArgs["Enabled"] = "1"; | 469 | requestArgs["Enabled"] = "1"; |
488 | 470 | ||
489 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 471 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); |
490 | if (response["Success"].AsBoolean()) | 472 | if (response["Success"].AsBoolean()) |
491 | { | 473 | { |
492 | return ResponseToGridRegion(response); | 474 | return ResponseToGridRegion(response); |