aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2016-07-30 14:35:43 +0100
committerUbitUmarov2016-07-30 14:35:43 +0100
commit79b7787efff4362761ee131426de01fe823d6946 (patch)
treeb58b014903fb29943b61b20c04dbafc1d99b6a5b /OpenSim/Region
parentremove obsolete config setting (diff)
downloadopensim-SC_OLD-79b7787efff4362761ee131426de01fe823d6946.zip
opensim-SC_OLD-79b7787efff4362761ee131426de01fe823d6946.tar.gz
opensim-SC_OLD-79b7787efff4362761ee131426de01fe823d6946.tar.bz2
opensim-SC_OLD-79b7787efff4362761ee131426de01fe823d6946.tar.xz
let LocalGridServiceConnector also have a RegionInfoCache, use the remote one if this is active.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs95
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs80
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs2
3 files changed, 83 insertions, 94 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index e585c25..3e03a5e 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -52,6 +52,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
52 52
53 private IGridService m_GridService; 53 private IGridService m_GridService;
54 private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>(); 54 private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>();
55 private RegionInfoCache m_RegionInfoCache = null;
55 56
56 private bool m_Enabled; 57 private bool m_Enabled;
57 58
@@ -60,10 +61,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
60 m_log.DebugFormat("{0} LocalGridServicesConnector no parms.", LogHeader); 61 m_log.DebugFormat("{0} LocalGridServicesConnector no parms.", LogHeader);
61 } 62 }
62 63
63 public LocalGridServicesConnector(IConfigSource source) 64 public LocalGridServicesConnector(IConfigSource source, RegionInfoCache regionInfoCache)
64 { 65 {
65 m_log.DebugFormat("{0} LocalGridServicesConnector instantiated directly.", LogHeader); 66 m_log.DebugFormat("{0} LocalGridServicesConnector instantiated directly.", LogHeader);
66 InitialiseService(source); 67 InitialiseService(source, regionInfoCache);
67 } 68 }
68 69
69 #region ISharedRegionModule 70 #region ISharedRegionModule
@@ -86,19 +87,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
86 string name = moduleConfig.GetString("GridServices", ""); 87 string name = moduleConfig.GetString("GridServices", "");
87 if (name == Name) 88 if (name == Name)
88 { 89 {
89 InitialiseService(source); 90
90 m_log.Info("[LOCAL GRID SERVICE CONNECTOR]: Local grid connector enabled"); 91 if(InitialiseService(source,null))
92 m_log.Info("[LOCAL GRID SERVICE CONNECTOR]: Local grid connector enabled");
91 } 93 }
92 } 94 }
93 } 95 }
94 96
95 private void InitialiseService(IConfigSource source) 97 private bool InitialiseService(IConfigSource source, RegionInfoCache ric)
96 { 98 {
99 if(ric == null)
100 m_RegionInfoCache = new RegionInfoCache();
101 else
102 m_RegionInfoCache = ric;
103
97 IConfig config = source.Configs["GridService"]; 104 IConfig config = source.Configs["GridService"];
98 if (config == null) 105 if (config == null)
99 { 106 {
100 m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: GridService missing from OpenSim.ini"); 107 m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: GridService missing from OpenSim.ini");
101 return; 108 return false;
102 } 109 }
103 110
104 string serviceDll = config.GetString("LocalServiceModule", String.Empty); 111 string serviceDll = config.GetString("LocalServiceModule", String.Empty);
@@ -106,7 +113,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
106 if (serviceDll == String.Empty) 113 if (serviceDll == String.Empty)
107 { 114 {
108 m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: No LocalServiceModule named in section GridService"); 115 m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: No LocalServiceModule named in section GridService");
109 return; 116 return false;
110 } 117 }
111 118
112 Object[] args = new Object[] { source }; 119 Object[] args = new Object[] { source };
@@ -117,10 +124,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
117 if (m_GridService == null) 124 if (m_GridService == null)
118 { 125 {
119 m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: Can't load grid service"); 126 m_log.Error("[LOCAL GRID SERVICE CONNECTOR]: Can't load grid service");
120 return; 127 return false;
121 } 128 }
122 129
123 m_Enabled = true; 130 m_Enabled = true;
131 return true;
124 } 132 }
125 133
126 public void PostInitialise() 134 public void PostInitialise()
@@ -189,7 +197,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
189 197
190 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) 198 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
191 { 199 {
192 return m_GridService.GetRegionByUUID(scopeID, regionID); 200 bool inCache = false;
201 GridRegion rinfo = m_RegionInfoCache.Get(scopeID,regionID,out inCache);
202 if (inCache)
203 return rinfo;
204
205 rinfo = m_GridService.GetRegionByUUID(scopeID, regionID);
206 if(rinfo != null)
207 m_RegionInfoCache.Cache(scopeID, rinfo);
208 return rinfo;
193 } 209 }
194 210
195 // Get a region given its base coordinates. 211 // Get a region given its base coordinates.
@@ -197,52 +213,37 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
197 // be the base coordinate of the region. 213 // be the base coordinate of the region.
198 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 214 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
199 { 215 {
200 GridRegion region = null; 216 // try in cache by handler first
201 uint regionX = Util.WorldToRegionLoc((uint)x); 217 ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y);
202 uint regionY = Util.WorldToRegionLoc((uint)y);
203 218
204 // First see if it's a neighbour, even if it isn't on this sim. 219 bool inCache = false;
205 // Neighbour data is cached in memory, so this is fast 220 GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache);
221 if (inCache)
222 return rinfo;
206 223
207 lock (m_LocalCache) 224 // try in cache by slower position next
208 { 225 rinfo = m_RegionInfoCache.Get(scopeID, x, y, out inCache);
209 foreach (RegionCache rcache in m_LocalCache.Values) 226 if (inCache)
210 { 227 return rinfo;
211 region = rcache.GetRegionByPosition(x, y);
212 if (region != null)
213 {
214 //m_log.DebugFormat("{0} GetRegionByPosition. Found region {1} in cache (of region {2}). Pos=<{3},{4}>",
215 // LogHeader, region.RegionName, rcache.RegionName,
216 // Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
217 break;
218 }
219 }
220 }
221 228
222 // Then try on this sim (may be a lookup in DB if this is using MySql). 229 // Then try on this sim (may be a lookup in DB if this is using MySql).
223 if (region == null) 230 rinfo = m_GridService.GetRegionByPosition(scopeID, x, y);
224 { 231 if(rinfo != null)
225 region = m_GridService.GetRegionByPosition(scopeID, x, y); 232 m_RegionInfoCache.Cache(scopeID, rinfo);
226 233 return rinfo;
227 if (region == null)
228 {
229 m_log.DebugFormat("{0} GetRegionByPosition. Region not found by grid service. Pos=<{1},{2}>",
230 LogHeader, regionX, regionY);
231 }
232 else
233 {
234 m_log.DebugFormat("{0} GetRegionByPosition. Got region {1} from grid service. Pos=<{2},{3}>",
235 LogHeader, region.RegionName,
236 Util.WorldToRegionLoc((uint)region.RegionLocX), Util.WorldToRegionLoc((uint)region.RegionLocY));
237 }
238 }
239
240 return region;
241 } 234 }
242 235
243 public GridRegion GetRegionByName(UUID scopeID, string regionName) 236 public GridRegion GetRegionByName(UUID scopeID, string regionName)
244 { 237 {
245 return m_GridService.GetRegionByName(scopeID, regionName); 238 bool inCache = false;
239 GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionName, out inCache);
240 if (inCache)
241 return rinfo;
242
243 rinfo = m_GridService.GetRegionByName(scopeID, regionName);
244 if(rinfo != null)
245 m_RegionInfoCache.Cache(scopeID, rinfo);
246 return rinfo;
246 } 247 }
247 248
248 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) 249 public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
index 6575cfd..363adde 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -87,39 +87,47 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
87 string name = moduleConfig.GetString("GridServices", ""); 87 string name = moduleConfig.GetString("GridServices", "");
88 if (name == Name) 88 if (name == Name)
89 { 89 {
90 InitialiseServices(source); 90 if(InitialiseServices(source))
91 m_Enabled = true; 91 {
92 m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled"); 92 m_Enabled = true;
93 m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled");
94 }
93 } 95 }
94 } 96 }
95 } 97 }
96 98
97 private void InitialiseServices(IConfigSource source) 99 private bool InitialiseServices(IConfigSource source)
98 { 100 {
99 IConfig gridConfig = source.Configs["GridService"]; 101 IConfig gridConfig = source.Configs["GridService"];
100 if (gridConfig == null) 102 if (gridConfig == null)
101 { 103 {
102 m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini"); 104 m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini");
103 return; 105 return false;
104 } 106 }
105 107
106 string networkConnector = gridConfig.GetString("NetworkConnector", string.Empty); 108 string networkConnector = gridConfig.GetString("NetworkConnector", string.Empty);
107 if (networkConnector == string.Empty) 109 if (networkConnector == string.Empty)
108 { 110 {
109 m_log.Error("[REMOTE GRID CONNECTOR]: Please specify a network connector under [GridService]"); 111 m_log.Error("[REMOTE GRID CONNECTOR]: Please specify a network connector under [GridService]");
110 return; 112 return false;
111 } 113 }
112 114
113 Object[] args = new Object[] { source }; 115 Object[] args = new Object[] { source };
114 m_RemoteGridService = ServerUtils.LoadPlugin<IGridService>(networkConnector, args); 116 m_RemoteGridService = ServerUtils.LoadPlugin<IGridService>(networkConnector, args);
115 117
116 m_LocalGridService = new LocalGridServicesConnector(source); 118 m_LocalGridService = new LocalGridServicesConnector(source, m_RegionInfoCache);
119 if (m_LocalGridService == null)
120 {
121 m_log.Error("[REMOTE GRID CONNECTOR]: failed to loar local connector");
122 return false;
123 }
124
125 return true;
117 } 126 }
118 127
119 public void PostInitialise() 128 public void PostInitialise()
120 { 129 {
121 if (m_LocalGridService != null) 130 ((ISharedRegionModule)m_LocalGridService).PostInitialise();
122 ((ISharedRegionModule)m_LocalGridService).PostInitialise();
123 } 131 }
124 132
125 public void Close() 133 public void Close()
@@ -131,14 +139,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
131 if (m_Enabled) 139 if (m_Enabled)
132 scene.RegisterModuleInterface<IGridService>(this); 140 scene.RegisterModuleInterface<IGridService>(this);
133 141
134 if (m_LocalGridService != null) 142 ((ISharedRegionModule)m_LocalGridService).AddRegion(scene);
135 ((ISharedRegionModule)m_LocalGridService).AddRegion(scene);
136 } 143 }
137 144
138 public void RemoveRegion(Scene scene) 145 public void RemoveRegion(Scene scene)
139 { 146 {
140 if (m_LocalGridService != null) 147 ((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene);
141 ((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene);
142 } 148 }
143 149
144 public void RegionLoaded(Scene scene) 150 public void RegionLoaded(Scene scene)
@@ -174,15 +180,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
174 180
175 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) 181 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
176 { 182 {
177 bool inCache = false; 183 GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);
178 GridRegion rinfo = m_RegionInfoCache.Get(scopeID,regionID,out inCache); 184 if (rinfo != null)
179 if (inCache)
180 return rinfo; 185 return rinfo;
181
182 rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID);
183 if (rinfo == null)
184 rinfo = m_RemoteGridService.GetRegionByUUID(scopeID, regionID);
185 186
187 rinfo = m_RemoteGridService.GetRegionByUUID(scopeID, regionID);
186 m_RegionInfoCache.Cache(scopeID, rinfo); 188 m_RegionInfoCache.Cache(scopeID, rinfo);
187 return rinfo; 189 return rinfo;
188 } 190 }
@@ -193,24 +195,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
193 // The coordinates are world coords (meters), NOT region units. 195 // The coordinates are world coords (meters), NOT region units.
194 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 196 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
195 { 197 {
196 // try in cache by handler first 198 GridRegion rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y);
197 ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y); 199 if (rinfo != null)
198 200 {
199 bool inCache = false; 201 m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache from local. Pos=<{1},{2}>, RegionHandle={3}",
200 GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache); 202 rinfo.RegionName, rinfo.RegionCoordX, rinfo.RegionCoordY, rinfo.RegionHandle);
201 if (inCache)
202 return rinfo;
203
204 // try in cache by slower position next
205 rinfo = m_RegionInfoCache.Get(scopeID, x, y, out inCache);
206 if (inCache)
207 return rinfo; 203 return rinfo;
204 }
208 205
209 rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); 206 rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y);
210 if (rinfo == null)
211 rinfo = m_RemoteGridService.GetRegionByPosition(scopeID, x, y);
212
213
214 207
215 if (rinfo == null) 208 if (rinfo == null)
216 { 209 {
@@ -223,23 +216,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
223 m_RegionInfoCache.Cache(scopeID, rinfo); 216 m_RegionInfoCache.Cache(scopeID, rinfo);
224 217
225 m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache. Pos=<{1},{2}>, RegionHandle={3}", 218 m_log.DebugFormat("[REMOTE GRID CONNECTOR]: GetRegionByPosition. Added region {0} to the cache. Pos=<{1},{2}>, RegionHandle={3}",
226 rinfo.RegionName, rinfo.RegionCoordX, rinfo.RegionCoordY, (rinfo == null) ? regionHandle : rinfo.RegionHandle); 219 rinfo.RegionName, rinfo.RegionCoordX, rinfo.RegionCoordY, rinfo.RegionHandle);
227 } 220 }
228 return rinfo; 221 return rinfo;
229 } 222 }
230 223
231 public GridRegion GetRegionByName(UUID scopeID, string regionName) 224 public GridRegion GetRegionByName(UUID scopeID, string regionName)
232 { 225 {
233 bool inCache = false; 226 GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName);
234 GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionName, out inCache); 227 if (rinfo != null)
235 if (inCache)
236 return rinfo; 228 return rinfo;
237 229
238 rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName); 230 rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName);
239 if (rinfo == null)
240 rinfo = m_RemoteGridService.GetRegionByName(scopeID, regionName);
241
242 // can't cache negative results for name lookups
243 m_RegionInfoCache.Cache(scopeID, rinfo); 231 m_RegionInfoCache.Cache(scopeID, rinfo);
244 return rinfo; 232 return rinfo;
245 } 233 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
index c33f7f5..044e0e5 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
64 config.Configs["GridService"].Set("Region_Test_Region_3", "FallbackRegion"); 64 config.Configs["GridService"].Set("Region_Test_Region_3", "FallbackRegion");
65 config.Configs["GridService"].Set("Region_Other_Region_4", "FallbackRegion"); 65 config.Configs["GridService"].Set("Region_Other_Region_4", "FallbackRegion");
66 66
67 m_LocalConnector = new LocalGridServicesConnector(config); 67 m_LocalConnector = new LocalGridServicesConnector(config, null);
68 } 68 }
69 69
70 /// <summary> 70 /// <summary>