diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs | 154 |
1 files changed, 96 insertions, 58 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 85073fc..0efe99d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs | |||
@@ -52,12 +52,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
52 | MethodBase.GetCurrentMethod().DeclaringType); | 52 | MethodBase.GetCurrentMethod().DeclaringType); |
53 | 53 | ||
54 | private bool m_Enabled = false; | 54 | private bool m_Enabled = false; |
55 | private string m_ThisGatekeeper = string.Empty; | ||
55 | 56 | ||
56 | private IGridService m_LocalGridService; | 57 | private IGridService m_LocalGridService; |
57 | private IGridService m_RemoteGridService; | 58 | private IGridService m_RemoteGridService; |
58 | 59 | ||
59 | private RegionInfoCache m_RegionInfoCache = new RegionInfoCache(); | 60 | private RegionInfoCache m_RegionInfoCache; |
60 | 61 | ||
61 | public RemoteGridServicesConnector() | 62 | public RemoteGridServicesConnector() |
62 | { | 63 | { |
63 | } | 64 | } |
@@ -69,7 +70,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
69 | 70 | ||
70 | #region ISharedRegionmodule | 71 | #region ISharedRegionmodule |
71 | 72 | ||
72 | public Type ReplaceableInterface | 73 | public Type ReplaceableInterface |
73 | { | 74 | { |
74 | get { return null; } | 75 | get { return null; } |
75 | } | 76 | } |
@@ -87,38 +88,57 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
87 | string name = moduleConfig.GetString("GridServices", ""); | 88 | string name = moduleConfig.GetString("GridServices", ""); |
88 | if (name == Name) | 89 | if (name == Name) |
89 | { | 90 | { |
90 | InitialiseServices(source); | 91 | if(InitialiseServices(source)) |
91 | m_Enabled = true; | 92 | { |
92 | m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled"); | 93 | m_Enabled = true; |
94 | m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled"); | ||
95 | } | ||
93 | } | 96 | } |
94 | } | 97 | } |
95 | } | 98 | } |
96 | 99 | ||
97 | private void InitialiseServices(IConfigSource source) | 100 | private bool InitialiseServices(IConfigSource source) |
98 | { | 101 | { |
99 | IConfig gridConfig = source.Configs["GridService"]; | 102 | IConfig gridConfig = source.Configs["GridService"]; |
100 | if (gridConfig == null) | 103 | if (gridConfig == null) |
101 | { | 104 | { |
102 | m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini"); | 105 | m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini"); |
103 | return; | 106 | return false; |
104 | } | 107 | } |
105 | 108 | ||
106 | string networkConnector = gridConfig.GetString("NetworkConnector", string.Empty); | 109 | string networkConnector = gridConfig.GetString("NetworkConnector", string.Empty); |
107 | if (networkConnector == string.Empty) | 110 | if (networkConnector == string.Empty) |
108 | { | 111 | { |
109 | m_log.Error("[REMOTE GRID CONNECTOR]: Please specify a network connector under [GridService]"); | 112 | m_log.Error("[REMOTE GRID CONNECTOR]: Please specify a network connector under [GridService]"); |
110 | return; | 113 | return false; |
111 | } | 114 | } |
112 | 115 | ||
113 | Object[] args = new Object[] { source }; | 116 | Object[] args = new Object[] { source }; |
114 | m_RemoteGridService = ServerUtils.LoadPlugin<IGridService>(networkConnector, args); | 117 | m_RemoteGridService = ServerUtils.LoadPlugin<IGridService>(networkConnector, args); |
115 | 118 | ||
116 | m_LocalGridService = new LocalGridServicesConnector(source); | 119 | m_LocalGridService = new LocalGridServicesConnector(source, m_RegionInfoCache); |
117 | } | 120 | if (m_LocalGridService == null) |
121 | { | ||
122 | m_log.Error("[REMOTE GRID CONNECTOR]: failed to load local connector"); | ||
123 | return false; | ||
124 | } | ||
125 | |||
126 | if(m_RegionInfoCache == null) | ||
127 | m_RegionInfoCache = new RegionInfoCache(); | ||
128 | |||
129 | m_ThisGatekeeper = Util.GetConfigVarFromSections<string>(source, "GatekeeperURI", | ||
130 | new string[] { "Startup", "Hypergrid", "GridService" }, String.Empty); | ||
131 | // Legacy. Remove soon! | ||
132 | //// m_ThisGatekeeper = gridConfig.GetString("Gatekeeper", m_ThisGatekeeper); | ||
133 | |||
134 | Util.checkServiceURI(m_ThisGatekeeper, out m_ThisGatekeeper); | ||
135 | |||
136 | return true; | ||
137 | } | ||
118 | 138 | ||
119 | public void PostInitialise() | 139 | public void PostInitialise() |
120 | { | 140 | { |
121 | if (m_LocalGridService != null) | 141 | if (m_Enabled) |
122 | ((ISharedRegionModule)m_LocalGridService).PostInitialise(); | 142 | ((ISharedRegionModule)m_LocalGridService).PostInitialise(); |
123 | } | 143 | } |
124 | 144 | ||
@@ -129,15 +149,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
129 | public void AddRegion(Scene scene) | 149 | public void AddRegion(Scene scene) |
130 | { | 150 | { |
131 | if (m_Enabled) | 151 | if (m_Enabled) |
152 | { | ||
132 | scene.RegisterModuleInterface<IGridService>(this); | 153 | scene.RegisterModuleInterface<IGridService>(this); |
133 | |||
134 | if (m_LocalGridService != null) | ||
135 | ((ISharedRegionModule)m_LocalGridService).AddRegion(scene); | 154 | ((ISharedRegionModule)m_LocalGridService).AddRegion(scene); |
155 | } | ||
136 | } | 156 | } |
137 | 157 | ||
138 | public void RemoveRegion(Scene scene) | 158 | public void RemoveRegion(Scene scene) |
139 | { | 159 | { |
140 | if (m_LocalGridService != null) | 160 | if (m_Enabled) |
141 | ((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene); | 161 | ((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene); |
142 | } | 162 | } |
143 | 163 | ||
@@ -174,16 +194,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
174 | 194 | ||
175 | public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) | 195 | public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) |
176 | { | 196 | { |
177 | bool inCache = false; | 197 | GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID); |
178 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID,regionID,out inCache); | 198 | if (rinfo != null) |
179 | if (inCache) | ||
180 | return rinfo; | 199 | return rinfo; |
181 | |||
182 | rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID); | ||
183 | if (rinfo == null) | ||
184 | rinfo = m_RemoteGridService.GetRegionByUUID(scopeID, regionID); | ||
185 | 200 | ||
186 | m_RegionInfoCache.Cache(scopeID,regionID,rinfo); | 201 | rinfo = m_RemoteGridService.GetRegionByUUID(scopeID, regionID); |
202 | m_RegionInfoCache.Cache(scopeID, rinfo); | ||
187 | return rinfo; | 203 | return rinfo; |
188 | } | 204 | } |
189 | 205 | ||
@@ -193,51 +209,56 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
193 | // The coordinates are world coords (meters), NOT region units. | 209 | // The coordinates are world coords (meters), NOT region units. |
194 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) | 210 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
195 | { | 211 | { |
196 | ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y); | 212 | GridRegion rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); |
197 | uint regionX = Util.WorldToRegionLoc((uint)x); | 213 | if (rinfo != null) |
198 | uint regionY = Util.WorldToRegionLoc((uint)y); | ||
199 | |||
200 | // Sanity check | ||
201 | if ((Util.RegionToWorldLoc(regionX) != (uint)x) || (Util.RegionToWorldLoc(regionY) != (uint)y)) | ||
202 | { | 214 | { |
203 | m_log.WarnFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Bad position requested: not the base of the region. Requested Pos=<{0},{1}>, Should Be=<{2},{3}>", | 215 | // m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Found region {0} on local. Pos=<{1},{2}>, RegionHandle={3}", |
204 | x, y, Util.RegionToWorldLoc(regionX), Util.RegionToWorldLoc(regionY)); | 216 | // rinfo.RegionName, rinfo.RegionCoordX, rinfo.RegionCoordY, rinfo.RegionHandle); |
205 | } | ||
206 | |||
207 | bool inCache = false; | ||
208 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache); | ||
209 | if (inCache) | ||
210 | { | ||
211 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Found region {0} in cache. Pos=<{1},{2}>, RegionHandle={3}", | ||
212 | // (rinfo == null) ? "<missing>" : rinfo.RegionName, regionX, regionY, (rinfo == null) ? regionHandle : rinfo.RegionHandle); | ||
213 | return rinfo; | 217 | return rinfo; |
214 | } | 218 | } |
215 | 219 | ||
216 | rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); | 220 | rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y); |
217 | if (rinfo == null) | ||
218 | rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y); | ||
219 | 221 | ||
220 | m_RegionInfoCache.Cache(rinfo); | 222 | if (rinfo == null) |
221 | 223 | { | |
222 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache. Pos=<{1},{2}>, RegionHandle={3}", | 224 | // uint regionX = Util.WorldToRegionLoc((uint)x); |
223 | // (rinfo == null) ? "<missing>" : rinfo.RegionName, regionX, regionY, (rinfo == null) ? regionHandle : rinfo.RegionHandle); | 225 | // uint regionY = Util.WorldToRegionLoc((uint)y); |
226 | // m_log.WarnFormat("[REMOTE GRID CONNECTOR]: Requested region {0}-{1} not found", regionX, regionY); | ||
227 | } | ||
228 | else | ||
229 | { | ||
230 | m_RegionInfoCache.Cache(scopeID, rinfo); | ||
224 | 231 | ||
232 | // m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache. Pos=<{1},{2}>, RegionHandle={3}", | ||
233 | // rinfo.RegionName, rinfo.RegionCoordX, rinfo.RegionCoordY, rinfo.RegionHandle); | ||
234 | } | ||
225 | return rinfo; | 235 | return rinfo; |
226 | } | 236 | } |
227 | 237 | ||
228 | public GridRegion GetRegionByName(UUID scopeID, string regionName) | 238 | public GridRegion GetRegionByName(UUID scopeID, string name) |
229 | { | 239 | { |
230 | bool inCache = false; | 240 | GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, name); |
231 | GridRegion rinfo = m_RegionInfoCache.Get(scopeID,regionName, out inCache); | 241 | if (rinfo != null) |
232 | if (inCache) | ||
233 | return rinfo; | 242 | return rinfo; |
234 | |||
235 | rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName); | ||
236 | if (rinfo == null) | ||
237 | rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName); | ||
238 | 243 | ||
239 | // can't cache negative results for name lookups | 244 | // HG urls should not get here, strip them |
240 | m_RegionInfoCache.Cache(rinfo); | 245 | // side effect is that local regions with same name as HG may also be found |
246 | // this mb good or bad | ||
247 | string regionName = name; | ||
248 | if(name.Contains(".")) | ||
249 | { | ||
250 | if(string.IsNullOrWhiteSpace(m_ThisGatekeeper)) | ||
251 | return rinfo; // no HG | ||
252 | |||
253 | string regionURI = ""; | ||
254 | if(!Util.buildHGRegionURI(name, out regionURI, out regionName) || string.IsNullOrWhiteSpace(regionName)) | ||
255 | return rinfo; // invalid | ||
256 | if(m_ThisGatekeeper != regionURI) | ||
257 | return rinfo; // not local grid | ||
258 | } | ||
259 | |||
260 | rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName); | ||
261 | m_RegionInfoCache.Cache(scopeID, rinfo); | ||
241 | return rinfo; | 262 | return rinfo; |
242 | } | 263 | } |
243 | 264 | ||
@@ -245,7 +266,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | |||
245 | { | 266 | { |
246 | List<GridRegion> rinfo = m_LocalGridService.GetRegionsByName(scopeID, name, maxNumber); | 267 | List<GridRegion> rinfo = m_LocalGridService.GetRegionsByName(scopeID, name, maxNumber); |
247 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetRegionsByName {0} found {1} regions", name, rinfo.Count); | 268 | //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Local GetRegionsByName {0} found {1} regions", name, rinfo.Count); |
248 | List<GridRegion> grinfo = m_RemoteGridService.GetRegionsByName(scopeID, name, maxNumber); | 269 | |
270 | // HG urls should not get here, strip them | ||
271 | // side effect is that local regions with same name as HG may also be found | ||
272 | // this mb good or bad | ||
273 | string regionName = name; | ||
274 | if(name.Contains(".")) | ||
275 | { | ||
276 | if(string.IsNullOrWhiteSpace(m_ThisGatekeeper)) | ||
277 | return rinfo; // no HG | ||
278 | |||
279 | string regionURI = ""; | ||
280 | if(!Util.buildHGRegionURI(name, out regionURI, out regionName) || string.IsNullOrWhiteSpace(regionName)) | ||
281 | return rinfo; // invalid | ||
282 | if(m_ThisGatekeeper != regionURI) | ||
283 | return rinfo; // not local grid | ||
284 | } | ||
285 | |||
286 | List<GridRegion> grinfo = m_RemoteGridService.GetRegionsByName(scopeID, regionName, maxNumber); | ||
249 | 287 | ||
250 | if (grinfo != null) | 288 | if (grinfo != null) |
251 | { | 289 | { |