aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs54
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs52
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs19
4 files changed, 121 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
index 52db400..c8062d7 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -135,6 +135,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
135 135
136 public void PostInitialise() 136 public void PostInitialise()
137 { 137 {
138 ((ISharedRegionModule)m_GridServiceConnector).PostInitialise();
138 } 139 }
139 140
140 public void Close() 141 public void Close()
@@ -150,11 +151,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
150 scene.RegisterModuleInterface<IGridService>(this); 151 scene.RegisterModuleInterface<IGridService>(this);
151 scene.RegisterModuleInterface<IHyperlinkService>(this); 152 scene.RegisterModuleInterface<IHyperlinkService>(this);
152 153
154 ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene);
155
153 } 156 }
154 157
155 public void RemoveRegion(Scene scene) 158 public void RemoveRegion(Scene scene)
156 { 159 {
157 m_LocalScenes.Remove(scene.RegionInfo.RegionHandle); 160 m_LocalScenes.Remove(scene.RegionInfo.RegionHandle);
161 ((ISharedRegionModule)m_GridServiceConnector).RemoveRegion(scene);
158 } 162 }
159 163
160 public void RegionLoaded(Scene scene) 164 public void RegionLoaded(Scene scene)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index 743d3b9..6c2928a 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -31,6 +31,7 @@ using System;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Reflection; 32using System.Reflection;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Console;
34using OpenSim.Server.Base; 35using OpenSim.Server.Base;
35using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
@@ -47,7 +48,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
47 LogManager.GetLogger( 48 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType); 49 MethodBase.GetCurrentMethod().DeclaringType);
49 50
51 private static LocalGridServicesConnector m_MainInstance;
52
50 private IGridService m_GridService; 53 private IGridService m_GridService;
54 private Dictionary<UUID, RegionCache> m_LocalCache = new Dictionary<UUID, RegionCache>();
51 55
52 private bool m_Enabled = false; 56 private bool m_Enabled = false;
53 57
@@ -58,6 +62,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
58 public LocalGridServicesConnector(IConfigSource source) 62 public LocalGridServicesConnector(IConfigSource source)
59 { 63 {
60 m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated"); 64 m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated");
65 m_MainInstance = this;
61 InitialiseService(source); 66 InitialiseService(source);
62 } 67 }
63 68
@@ -82,6 +87,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
82 if (name == Name) 87 if (name == Name)
83 { 88 {
84 InitialiseService(source); 89 InitialiseService(source);
90 m_MainInstance = this;
85 m_Enabled = true; 91 m_Enabled = true;
86 m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled"); 92 m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled");
87 } 93 }
@@ -120,6 +126,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
120 126
121 public void PostInitialise() 127 public void PostInitialise()
122 { 128 {
129 if (m_MainInstance == this)
130 {
131 MainConsole.Instance.Commands.AddCommand("LocalGridConnector", false, "show neighbours",
132 "show neighbours",
133 "Shows the local regions' neighbours", NeighboursCommand);
134 }
123 } 135 }
124 136
125 public void Close() 137 public void Close()
@@ -128,14 +140,26 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
128 140
129 public void AddRegion(Scene scene) 141 public void AddRegion(Scene scene)
130 { 142 {
131 if (!m_Enabled) 143 if (m_Enabled)
132 return; 144 scene.RegisterModuleInterface<IGridService>(this);
145
146 if (m_MainInstance == this)
147 {
148 if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID))
149 m_log.ErrorFormat("[LOCAL GRID CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!");
150 else
151 m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene));
133 152
134 scene.RegisterModuleInterface<IGridService>(this); 153 }
135 } 154 }
136 155
137 public void RemoveRegion(Scene scene) 156 public void RemoveRegion(Scene scene)
138 { 157 {
158 if (m_MainInstance == this)
159 {
160 m_LocalCache[scene.RegionInfo.RegionID].Clear();
161 m_LocalCache.Remove(scene.RegionInfo.RegionID);
162 }
139 } 163 }
140 164
141 public void RegionLoaded(Scene scene) 165 public void RegionLoaded(Scene scene)
@@ -158,7 +182,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
158 182
159 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) 183 public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
160 { 184 {
161 return m_GridService.GetNeighbours(scopeID, regionID); 185 if (m_LocalCache.ContainsKey(regionID))
186 {
187 return m_LocalCache[regionID].GetNeighbours();
188 }
189 else
190 {
191 m_log.WarnFormat("[LOCAL GRID CONNECTOR]: GetNeighbours: Requested region {0} is not on this sim", regionID);
192 return new List<GridRegion>();
193 }
194
195 // Don't go to the DB
196 //return m_GridService.GetNeighbours(scopeID, regionID);
162 } 197 }
163 198
164 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) 199 public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
@@ -187,5 +222,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
187 } 222 }
188 223
189 #endregion 224 #endregion
225
226 public void NeighboursCommand(string module, string[] cmdparams)
227 {
228 foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache)
229 {
230 m_log.InfoFormat("*** Neighbours of {0} {1} ***", kvp.Key, kvp.Value.RegionName);
231 List<GridRegion> regions = kvp.Value.GetNeighbours();
232 foreach (GridRegion r in regions)
233 m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize);
234 }
235 }
190 } 236 }
191} 237}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
new file mode 100644
index 0000000..ea205a2
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionCache.cs
@@ -0,0 +1,52 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4
5using OpenSim.Region.Framework.Scenes;
6using OpenSim.Services.Interfaces;
7using GridRegion = OpenSim.Services.Interfaces.GridRegion;
8
9using log4net;
10
11namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
12{
13 public class RegionCache
14 {
15 private static readonly ILog m_log =
16 LogManager.GetLogger(
17 MethodBase.GetCurrentMethod().DeclaringType);
18
19 private Scene m_scene;
20 private Dictionary<ulong, GridRegion> m_neighbours = new Dictionary<ulong, GridRegion>();
21
22 public string RegionName
23 {
24 get { return m_scene.RegionInfo.RegionName; }
25 }
26
27 public RegionCache(Scene s)
28 {
29 m_scene = s;
30 m_scene.EventManager.OnRegionUp += OnRegionUp;
31 }
32
33 private void OnRegionUp(GridRegion otherRegion)
34 {
35 m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}",
36 m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
37
38 m_neighbours[otherRegion.RegionHandle] = otherRegion;
39 }
40
41 public void Clear()
42 {
43 m_scene.EventManager.OnRegionUp -= OnRegionUp;
44 m_neighbours.Clear();
45 }
46
47 public List<GridRegion> GetNeighbours()
48 {
49 return new List<GridRegion>(m_neighbours.Values);
50 }
51 }
52}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
index 91a808b..72c00fc 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -104,6 +104,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
104 104
105 public void PostInitialise() 105 public void PostInitialise()
106 { 106 {
107 if (m_LocalGridService != null)
108 ((ISharedRegionModule)m_LocalGridService).PostInitialise();
107 } 109 }
108 110
109 public void Close() 111 public void Close()
@@ -112,14 +114,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
112 114
113 public void AddRegion(Scene scene) 115 public void AddRegion(Scene scene)
114 { 116 {
115 if (!m_Enabled) 117 if (m_Enabled)
116 return; 118 scene.RegisterModuleInterface<IGridService>(this);
117 119
118 scene.RegisterModuleInterface<IGridService>(this); 120 if (m_LocalGridService != null)
121 ((ISharedRegionModule)m_LocalGridService).AddRegion(scene);
119 } 122 }
120 123
121 public void RemoveRegion(Scene scene) 124 public void RemoveRegion(Scene scene)
122 { 125 {
126 if (m_LocalGridService != null)
127 ((ISharedRegionModule)m_LocalGridService).RemoveRegion(scene);
123 } 128 }
124 129
125 public void RegionLoaded(Scene scene) 130 public void RegionLoaded(Scene scene)
@@ -146,7 +151,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
146 return false; 151 return false;
147 } 152 }
148 153
149 // Let's not override GetNeighbours -- let's get them all from the grid server 154 // Let's override GetNeighbours completely -- never go to the grid server
155 // Neighbours are/should be cached locally
156 // For retrieval from the DB, caller should call GetRegionByPosition
157 public override List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
158 {
159 return m_LocalGridService.GetNeighbours(scopeID, regionID);
160 }
150 161
151 public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) 162 public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
152 { 163 {