diff options
author | Mike Mazur | 2008-07-18 04:51:41 +0000 |
---|---|---|
committer | Mike Mazur | 2008-07-18 04:51:41 +0000 |
commit | e0e0db366061eae148364e3d5670f275b1ab25b7 (patch) | |
tree | cbd4890958aa28a3ff98a917909ec77247a80d00 /OpenSim/Grid/GridServer | |
parent | Make scripts LSL compliant. (diff) | |
download | opensim-SC_OLD-e0e0db366061eae148364e3d5670f275b1ab25b7.zip opensim-SC_OLD-e0e0db366061eae148364e3d5670f275b1ab25b7.tar.gz opensim-SC_OLD-e0e0db366061eae148364e3d5670f275b1ab25b7.tar.bz2 opensim-SC_OLD-e0e0db366061eae148364e3d5670f275b1ab25b7.tar.xz |
Thanks, sempuki, for a patch that moves all grid plugins to new PluginLoader (issue 1763).
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Grid/GridServer/GridManager.cs | 120 | ||||
-rw-r--r-- | OpenSim/Grid/GridServer/GridServerBase.cs | 3 | ||||
-rw-r--r-- | OpenSim/Grid/GridServer/IGridPlugin.cs | 3 |
3 files changed, 61 insertions, 65 deletions
diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs index c539e66..ebc6ac3 100644 --- a/OpenSim/Grid/GridServer/GridManager.cs +++ b/OpenSim/Grid/GridServer/GridManager.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Text; | ||
29 | using System.Collections; | 30 | using System.Collections; |
30 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
31 | using System.IO; | 32 | using System.IO; |
@@ -46,8 +47,8 @@ namespace OpenSim.Grid.GridServer | |||
46 | { | 47 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 49 | ||
49 | private Dictionary<string, IGridData> _plugins = new Dictionary<string, IGridData>(); | 50 | private List<IGridDataPlugin> _plugins = new List<IGridDataPlugin>(); |
50 | private Dictionary<string, ILogData> _logplugins = new Dictionary<string, ILogData>(); | 51 | private List<ILogDataPlugin> _logplugins = new List<ILogDataPlugin>(); |
51 | 52 | ||
52 | // This is here so that the grid server can hand out MessageServer settings to regions on registration | 53 | // This is here so that the grid server can hand out MessageServer settings to regions on registration |
53 | private List<MessageServerInfo> _MessageServers = new List<MessageServerInfo>(); | 54 | private List<MessageServerInfo> _MessageServers = new List<MessageServerInfo>(); |
@@ -57,42 +58,39 @@ namespace OpenSim.Grid.GridServer | |||
57 | /// <summary> | 58 | /// <summary> |
58 | /// Adds a new grid server plugin - grid servers will be requested in the order they were loaded. | 59 | /// Adds a new grid server plugin - grid servers will be requested in the order they were loaded. |
59 | /// </summary> | 60 | /// </summary> |
60 | /// <param name="FileName">The filename to the grid server plugin DLL</param> | 61 | /// <param name="provider">The name of the grid server plugin DLL</param> |
61 | public void AddPlugin(string FileName, string Connect) | 62 | public void AddPlugin(string provider, string connect) |
62 | { | 63 | { |
63 | m_log.Info("[DATA]: Attempting to load " + FileName); | 64 | // FIXME: convert "provider" DLL file name to Mono.Addins "id", |
64 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | 65 | // which unless it is changed in the source code, is the .NET namespace. |
65 | 66 | // In the future, the "provider" should be changed to "id" in the | |
66 | m_log.Info("[DATA]: Found " + pluginAssembly.GetTypes().Length + " interfaces."); | 67 | // config files, and is independent of filenames or namespaces. |
67 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 68 | string[] s = provider.Split ('.'); |
68 | { | 69 | int len = s.Length; |
69 | if (!pluginType.IsAbstract) | 70 | if ((len >= 2) && (s [len-1] == "dll")) |
70 | { | 71 | s [len-1] = s [len-2]; |
71 | // Regions go here | 72 | |
72 | Type typeInterface = pluginType.GetInterface("IGridData", true); | 73 | provider = String.Join (".", s); |
73 | 74 | ||
74 | if (typeInterface != null) | 75 | PluginLoader<IGridDataPlugin> gridloader = |
75 | { | 76 | new PluginLoader<IGridDataPlugin> (new GridDataStoreInitialiser (connect)); |
76 | IGridData plug = | 77 | |
77 | (IGridData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | 78 | PluginLoader<ILogDataPlugin> logloader = |
78 | plug.Initialise(Connect); | 79 | new PluginLoader<ILogDataPlugin> (new LogDataInitialiser (connect)); |
79 | _plugins.Add(plug.getName(), plug); | 80 | |
80 | m_log.Info("[DATA]: Added IGridData Interface"); | 81 | gridloader.AddExtensionPoint ("/OpenSim/GridDataStore"); |
81 | } | 82 | logloader.AddExtensionPoint ("/OpenSim/GridLogData"); |
82 | 83 | ||
83 | // Logs go here | 84 | // loader will try to load all providers (MySQL, MSSQL, etc) |
84 | typeInterface = pluginType.GetInterface("ILogData", true); | 85 | // unless it is constrainted to the correct "id" |
85 | 86 | gridloader.AddFilter ("/OpenSim/GridDataStore", new PluginIdFilter (provider + "GridData")); | |
86 | if (typeInterface != null) | 87 | logloader.AddFilter ("/OpenSim/GridLogData", new PluginIdFilter (provider + "LogData")); |
87 | { | 88 | |
88 | ILogData plug = | 89 | gridloader.Load(); |
89 | (ILogData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | 90 | logloader.Load(); |
90 | plug.Initialise(Connect); | 91 | |
91 | _logplugins.Add(plug.getName(), plug); | 92 | _plugins = gridloader.Plugins; |
92 | m_log.Info("[DATA]: Added ILogData Interface"); | 93 | _logplugins = logloader.Plugins; |
93 | } | ||
94 | } | ||
95 | } | ||
96 | } | 94 | } |
97 | 95 | ||
98 | /// <summary> | 96 | /// <summary> |
@@ -105,15 +103,15 @@ namespace OpenSim.Grid.GridServer | |||
105 | /// <param name="message">The message to log</param> | 103 | /// <param name="message">The message to log</param> |
106 | private void logToDB(string target, string method, string args, int priority, string message) | 104 | private void logToDB(string target, string method, string args, int priority, string message) |
107 | { | 105 | { |
108 | foreach (KeyValuePair<string, ILogData> kvp in _logplugins) | 106 | foreach (ILogDataPlugin plugin in _logplugins) |
109 | { | 107 | { |
110 | try | 108 | try |
111 | { | 109 | { |
112 | kvp.Value.saveLog("Gridserver", target, method, args, priority, message); | 110 | plugin.saveLog("Gridserver", target, method, args, priority, message); |
113 | } | 111 | } |
114 | catch (Exception) | 112 | catch (Exception) |
115 | { | 113 | { |
116 | m_log.Warn("[storage]: Unable to write log via " + kvp.Key); | 114 | m_log.Warn("[storage]: Unable to write log via "); |
117 | } | 115 | } |
118 | } | 116 | } |
119 | } | 117 | } |
@@ -125,11 +123,11 @@ namespace OpenSim.Grid.GridServer | |||
125 | /// <returns>A SimProfileData for the region</returns> | 123 | /// <returns>A SimProfileData for the region</returns> |
126 | public RegionProfileData GetRegion(LLUUID uuid) | 124 | public RegionProfileData GetRegion(LLUUID uuid) |
127 | { | 125 | { |
128 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 126 | foreach (IGridDataPlugin plugin in _plugins) |
129 | { | 127 | { |
130 | try | 128 | try |
131 | { | 129 | { |
132 | return kvp.Value.GetProfileByLLUUID(uuid); | 130 | return plugin.GetProfileByLLUUID(uuid); |
133 | } | 131 | } |
134 | catch (Exception e) | 132 | catch (Exception e) |
135 | { | 133 | { |
@@ -146,15 +144,15 @@ namespace OpenSim.Grid.GridServer | |||
146 | /// <returns>A SimProfileData for the region</returns> | 144 | /// <returns>A SimProfileData for the region</returns> |
147 | public RegionProfileData GetRegion(ulong handle) | 145 | public RegionProfileData GetRegion(ulong handle) |
148 | { | 146 | { |
149 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 147 | foreach (IGridDataPlugin plugin in _plugins) |
150 | { | 148 | { |
151 | try | 149 | try |
152 | { | 150 | { |
153 | return kvp.Value.GetProfileByHandle(handle); | 151 | return plugin.GetProfileByHandle(handle); |
154 | } | 152 | } |
155 | catch | 153 | catch |
156 | { | 154 | { |
157 | m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + kvp.Key); | 155 | m_log.Warn("[storage]: Unable to find region " + handle.ToString() + " via " + plugin.Name); |
158 | } | 156 | } |
159 | } | 157 | } |
160 | return null; | 158 | return null; |
@@ -167,15 +165,15 @@ namespace OpenSim.Grid.GridServer | |||
167 | /// <returns>A SimProfileData for the region</returns> | 165 | /// <returns>A SimProfileData for the region</returns> |
168 | public RegionProfileData GetRegion(string regionName) | 166 | public RegionProfileData GetRegion(string regionName) |
169 | { | 167 | { |
170 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 168 | foreach (IGridDataPlugin plugin in _plugins) |
171 | { | 169 | { |
172 | try | 170 | try |
173 | { | 171 | { |
174 | return kvp.Value.GetProfileByString(regionName); | 172 | return plugin.GetProfileByString(regionName); |
175 | } | 173 | } |
176 | catch | 174 | catch |
177 | { | 175 | { |
178 | m_log.Warn("[storage]: Unable to find region " + regionName + " via " + kvp.Key); | 176 | m_log.Warn("[storage]: Unable to find region " + regionName + " via " + plugin.Name); |
179 | } | 177 | } |
180 | } | 178 | } |
181 | return null; | 179 | return null; |
@@ -185,11 +183,11 @@ namespace OpenSim.Grid.GridServer | |||
185 | { | 183 | { |
186 | Dictionary<ulong, RegionProfileData> regions = new Dictionary<ulong, RegionProfileData>(); | 184 | Dictionary<ulong, RegionProfileData> regions = new Dictionary<ulong, RegionProfileData>(); |
187 | 185 | ||
188 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 186 | foreach (IGridDataPlugin plugin in _plugins) |
189 | { | 187 | { |
190 | try | 188 | try |
191 | { | 189 | { |
192 | RegionProfileData[] neighbours = kvp.Value.GetProfilesInRange(xmin, ymin, xmax, ymax); | 190 | RegionProfileData[] neighbours = plugin.GetProfilesInRange(xmin, ymin, xmax, ymax); |
193 | foreach (RegionProfileData neighbour in neighbours) | 191 | foreach (RegionProfileData neighbour in neighbours) |
194 | { | 192 | { |
195 | regions[neighbour.regionHandle] = neighbour; | 193 | regions[neighbour.regionHandle] = neighbour; |
@@ -197,7 +195,7 @@ namespace OpenSim.Grid.GridServer | |||
197 | } | 195 | } |
198 | catch | 196 | catch |
199 | { | 197 | { |
200 | m_log.Warn("[storage]: Unable to query regionblock via " + kvp.Key); | 198 | m_log.Warn("[storage]: Unable to query regionblock via " + plugin.Name); |
201 | } | 199 | } |
202 | } | 200 | } |
203 | 201 | ||
@@ -404,7 +402,7 @@ namespace OpenSim.Grid.GridServer | |||
404 | return e.XmlRpcErrorResponse; | 402 | return e.XmlRpcErrorResponse; |
405 | } | 403 | } |
406 | 404 | ||
407 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 405 | foreach (IGridDataPlugin plugin in _plugins) |
408 | { | 406 | { |
409 | try | 407 | try |
410 | { | 408 | { |
@@ -412,11 +410,11 @@ namespace OpenSim.Grid.GridServer | |||
412 | 410 | ||
413 | if (existingSim == null) | 411 | if (existingSim == null) |
414 | { | 412 | { |
415 | insertResponse = kvp.Value.AddProfile(sim); | 413 | insertResponse = plugin.AddProfile(sim); |
416 | } | 414 | } |
417 | else | 415 | else |
418 | { | 416 | { |
419 | insertResponse = kvp.Value.UpdateProfile(sim); | 417 | insertResponse = plugin.UpdateProfile(sim); |
420 | } | 418 | } |
421 | 419 | ||
422 | switch (insertResponse) | 420 | switch (insertResponse) |
@@ -441,7 +439,7 @@ namespace OpenSim.Grid.GridServer | |||
441 | catch (Exception e) | 439 | catch (Exception e) |
442 | { | 440 | { |
443 | m_log.Warn("[LOGIN END]: " + | 441 | m_log.Warn("[LOGIN END]: " + |
444 | "Unable to login region " + sim.UUID.ToString() + " via " + kvp.Key); | 442 | "Unable to login region " + sim.UUID.ToString() + " via " + plugin.Name); |
445 | m_log.Warn("[LOGIN END]: " + e.ToString()); | 443 | m_log.Warn("[LOGIN END]: " + e.ToString()); |
446 | } | 444 | } |
447 | } | 445 | } |
@@ -682,12 +680,12 @@ namespace OpenSim.Grid.GridServer | |||
682 | return response; | 680 | return response; |
683 | } | 681 | } |
684 | 682 | ||
685 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 683 | foreach (IGridDataPlugin plugin in _plugins) |
686 | { | 684 | { |
687 | //OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData(); | 685 | //OpenSim.Data.MySQL.MySQLGridData dbengine = new OpenSim.Data.MySQL.MySQLGridData(); |
688 | try | 686 | try |
689 | { | 687 | { |
690 | MySQLGridData mysqldata = (MySQLGridData)(kvp.Value); | 688 | MySQLGridData mysqldata = (MySQLGridData)(plugin); |
691 | //DataResponse insertResponse = mysqldata.DeleteProfile(TheSim); | 689 | //DataResponse insertResponse = mysqldata.DeleteProfile(TheSim); |
692 | DataResponse insertResponse = mysqldata.DeleteProfile(uuid); | 690 | DataResponse insertResponse = mysqldata.DeleteProfile(uuid); |
693 | switch (insertResponse) | 691 | switch (insertResponse) |
@@ -1053,17 +1051,17 @@ namespace OpenSim.Grid.GridServer | |||
1053 | m_log.Info("[DATA]: " + | 1051 | m_log.Info("[DATA]: " + |
1054 | "Updating / adding via " + _plugins.Count + " storage provider(s) registered."); | 1052 | "Updating / adding via " + _plugins.Count + " storage provider(s) registered."); |
1055 | 1053 | ||
1056 | foreach (KeyValuePair<string, IGridData> kvp in _plugins) | 1054 | foreach (IGridDataPlugin plugin in _plugins) |
1057 | { | 1055 | { |
1058 | try | 1056 | try |
1059 | { | 1057 | { |
1060 | //Check reservations | 1058 | //Check reservations |
1061 | ReservationData reserveData = | 1059 | ReservationData reserveData = |
1062 | kvp.Value.GetReservationAtPoint(theSim.regionLocX, theSim.regionLocY); | 1060 | plugin.GetReservationAtPoint(theSim.regionLocX, theSim.regionLocY); |
1063 | if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) || | 1061 | if ((reserveData != null && reserveData.gridRecvKey == theSim.regionRecvKey) || |
1064 | (reserveData == null && authkeynode.InnerText != theSim.regionRecvKey)) | 1062 | (reserveData == null && authkeynode.InnerText != theSim.regionRecvKey)) |
1065 | { | 1063 | { |
1066 | kvp.Value.AddProfile(theSim); | 1064 | plugin.AddProfile(theSim); |
1067 | m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")"); | 1065 | m_log.Info("[grid]: New sim added to grid (" + theSim.regionName + ")"); |
1068 | logToDB(theSim.UUID.ToString(), "RestSetSimMethod", String.Empty, 5, | 1066 | logToDB(theSim.UUID.ToString(), "RestSetSimMethod", String.Empty, 5, |
1069 | "Region successfully updated and connected to grid."); | 1067 | "Region successfully updated and connected to grid."); |
@@ -1078,7 +1076,7 @@ namespace OpenSim.Grid.GridServer | |||
1078 | } | 1076 | } |
1079 | catch (Exception e) | 1077 | catch (Exception e) |
1080 | { | 1078 | { |
1081 | m_log.Warn("[GRID]: GetRegionPlugin Handle " + kvp.Key + " unable to add new sim: " + | 1079 | m_log.Warn("[GRID]: GetRegionPlugin Handle " + plugin.Name + " unable to add new sim: " + |
1082 | e.ToString()); | 1080 | e.ToString()); |
1083 | } | 1081 | } |
1084 | } | 1082 | } |
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs index 3cd7489..a8ebd27 100644 --- a/OpenSim/Grid/GridServer/GridServerBase.cs +++ b/OpenSim/Grid/GridServer/GridServerBase.cs | |||
@@ -31,7 +31,6 @@ using System.IO; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Timers; | 32 | using System.Timers; |
33 | using log4net; | 33 | using log4net; |
34 | using Mono.Addins; | ||
35 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Servers; | 36 | using OpenSim.Framework.Servers; |
@@ -121,7 +120,7 @@ namespace OpenSim.Grid.GridServer | |||
121 | PluginLoader<IGridPlugin> loader = | 120 | PluginLoader<IGridPlugin> loader = |
122 | new PluginLoader<IGridPlugin> (new GridPluginInitialiser (this)); | 121 | new PluginLoader<IGridPlugin> (new GridPluginInitialiser (this)); |
123 | 122 | ||
124 | loader.Load ("/OpenSim/GridServer", "."); | 123 | loader.Load ("/OpenSim/GridServer"); |
125 | m_plugins = loader.Plugins; | 124 | m_plugins = loader.Plugins; |
126 | } | 125 | } |
127 | 126 | ||
diff --git a/OpenSim/Grid/GridServer/IGridPlugin.cs b/OpenSim/Grid/GridServer/IGridPlugin.cs index 6593962..418caec 100644 --- a/OpenSim/Grid/GridServer/IGridPlugin.cs +++ b/OpenSim/Grid/GridServer/IGridPlugin.cs | |||
@@ -29,7 +29,7 @@ | |||
29 | using Mono.Addins; | 29 | using Mono.Addins; |
30 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
31 | 31 | ||
32 | [assembly : AddinRoot("OpenSim", "0.5")] | 32 | [assembly : AddinRoot("OpenSim.Grid.GridServer", "0.5")] |
33 | 33 | ||
34 | namespace OpenSim.Grid.GridServer | 34 | namespace OpenSim.Grid.GridServer |
35 | { | 35 | { |
@@ -37,7 +37,6 @@ namespace OpenSim.Grid.GridServer | |||
37 | public interface IGridPlugin : IPlugin | 37 | public interface IGridPlugin : IPlugin |
38 | { | 38 | { |
39 | void Initialise(GridServerBase gridServer); | 39 | void Initialise(GridServerBase gridServer); |
40 | void Close(); | ||
41 | } | 40 | } |
42 | 41 | ||
43 | public class GridPluginInitialiser : PluginInitialiserBase | 42 | public class GridPluginInitialiser : PluginInitialiserBase |