diff options
author | lbsa71 | 2007-09-27 13:25:45 +0000 |
---|---|---|
committer | lbsa71 | 2007-09-27 13:25:45 +0000 |
commit | 8143c597fc5f62ec0d931d2d5b887730e06aec04 (patch) | |
tree | ae67873a5f801b2b7bdf9a7b088db98beb97b5ac /OpenSim/Grid/InventoryServer | |
parent | Terrain: (diff) | |
download | opensim-SC-8143c597fc5f62ec0d931d2d5b887730e06aec04.zip opensim-SC-8143c597fc5f62ec0d931d2d5b887730e06aec04.tar.gz opensim-SC-8143c597fc5f62ec0d931d2d5b887730e06aec04.tar.bz2 opensim-SC-8143c597fc5f62ec0d931d2d5b887730e06aec04.tar.xz |
* Tleiades grid mode inventory (#444) - thanx Tleiades!
* updated to rev 1413 on libsecondlife.dll and libsecondlife.dll.config (#423)
Diffstat (limited to 'OpenSim/Grid/InventoryServer')
-rw-r--r-- | OpenSim/Grid/InventoryServer/InventoryManager.cs | 131 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/InventoryService.cs | 136 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/Main.cs | 113 |
3 files changed, 318 insertions, 62 deletions
diff --git a/OpenSim/Grid/InventoryServer/InventoryManager.cs b/OpenSim/Grid/InventoryServer/InventoryManager.cs index 016b8bb..a46f359 100644 --- a/OpenSim/Grid/InventoryServer/InventoryManager.cs +++ b/OpenSim/Grid/InventoryServer/InventoryManager.cs | |||
@@ -26,37 +26,34 @@ | |||
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Text; | ||
30 | using System.Reflection; | ||
29 | using System.Collections; | 31 | using System.Collections; |
30 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
31 | using System.Text; | ||
32 | using OpenGrid.Framework.Data; | ||
33 | using libsecondlife; | 33 | using libsecondlife; |
34 | using System.Reflection; | ||
35 | 34 | ||
36 | using System.Xml; | 35 | using System.Xml; |
37 | using Nwc.XmlRpc; | 36 | using OpenSim.Framework.Console; |
38 | using OpenSim.Framework.Sims; | ||
39 | using OpenSim.Framework.Inventory; | ||
40 | using OpenSim.Framework.Utilities; | 37 | using OpenSim.Framework.Utilities; |
38 | using OpenSim.Framework.Data; | ||
39 | using InventoryCategory = OpenSim.Framework.Data.InventoryCategory; | ||
41 | 40 | ||
42 | using System.Security.Cryptography; | 41 | namespace OpenSim.Grid.InventoryServer |
43 | |||
44 | namespace OpenGridServices.InventoryServer | ||
45 | { | 42 | { |
46 | class InventoryManager | 43 | class InventoryManager : IInventoryData |
47 | { | 44 | { |
48 | Dictionary<string, IInventoryData> _plugins = new Dictionary<string, IInventoryData>(); | 45 | IInventoryData _databasePlugin; |
49 | 46 | ||
50 | /// <summary> | 47 | /// <summary> |
51 | /// Adds a new inventory server plugin - user servers will be requested in the order they were loaded. | 48 | /// Adds a new inventory server plugin - user servers will be requested in the order they were loaded. |
52 | /// </summary> | 49 | /// </summary> |
53 | /// <param name="FileName">The filename to the inventory server plugin DLL</param> | 50 | /// <param name="FileName">The filename to the inventory server plugin DLL</param> |
54 | public void AddPlugin(string FileName) | 51 | public void AddDatabasePlugin(string FileName) |
55 | { | 52 | { |
56 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Attempting to load " + FileName); | 53 | MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Invenstorage: Attempting to load " + FileName); |
57 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | 54 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); |
58 | 55 | ||
59 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); | 56 | MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); |
60 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 57 | foreach (Type pluginType in pluginAssembly.GetTypes()) |
61 | { | 58 | { |
62 | if (!pluginType.IsAbstract) | 59 | if (!pluginType.IsAbstract) |
@@ -67,8 +64,9 @@ namespace OpenGridServices.InventoryServer | |||
67 | { | 64 | { |
68 | IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | 65 | IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); |
69 | plug.Initialise(); | 66 | plug.Initialise(); |
70 | this._plugins.Add(plug.getName(), plug); | 67 | _databasePlugin = plug; |
71 | OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Added IUserData Interface"); | 68 | MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Invenstorage: Added IInventoryData Interface"); |
69 | break; | ||
72 | } | 70 | } |
73 | 71 | ||
74 | typeInterface = null; | 72 | typeInterface = null; |
@@ -80,46 +78,87 @@ namespace OpenGridServices.InventoryServer | |||
80 | 78 | ||
81 | public List<InventoryFolderBase> getRootFolders(LLUUID user) | 79 | public List<InventoryFolderBase> getRootFolders(LLUUID user) |
82 | { | 80 | { |
83 | foreach (KeyValuePair<string, IInventoryData> kvp in _plugins) | ||
84 | { | ||
85 | try | ||
86 | { | ||
87 | return kvp.Value.getUserRootFolders(user); | ||
88 | } | ||
89 | catch (Exception e) | ||
90 | { | ||
91 | OpenSim.Framework.Console.MainConsole.Instance.Notice("Unable to get root folders via " + kvp.Key + " (" + e.ToString() + ")"); | ||
92 | } | ||
93 | } | ||
94 | return null; | 81 | return null; |
95 | } | 82 | } |
96 | 83 | ||
97 | public XmlRpcResponse XmlRpcInventoryRequest(XmlRpcRequest request) | 84 | #region IInventoryData Members |
85 | |||
86 | |||
87 | public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID) | ||
88 | { | ||
89 | return _databasePlugin.getInventoryInFolder(folderID); | ||
90 | } | ||
91 | |||
92 | public List<InventoryFolderBase> getUserRootFolders(LLUUID user) | ||
98 | { | 93 | { |
99 | XmlRpcResponse response = new XmlRpcResponse(); | 94 | return _databasePlugin.getUserRootFolders(user); |
100 | Hashtable requestData = (Hashtable)request.Params[0]; | 95 | } |
101 | 96 | ||
102 | Hashtable responseData = new Hashtable(); | 97 | public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID) |
98 | { | ||
99 | return _databasePlugin.getInventoryFolders(parentID); | ||
100 | } | ||
103 | 101 | ||
104 | // Stuff happens here | 102 | public InventoryItemBase getInventoryItem(LLUUID item) |
103 | { | ||
104 | throw new Exception("The method or operation is not implemented."); | ||
105 | } | ||
105 | 106 | ||
106 | if (requestData.ContainsKey("Access-type")) | 107 | public InventoryFolderBase getInventoryFolder(LLUUID folder) |
107 | { | 108 | { |
108 | if (requestData["access-type"] == "rootfolders") | 109 | return _databasePlugin.getInventoryFolder(folder); |
109 | { | 110 | } |
110 | // responseData["rootfolders"] = | 111 | |
111 | } | 112 | public void addInventoryItem(InventoryItemBase item) |
112 | } | 113 | { |
113 | else | 114 | _databasePlugin.addInventoryItem(item); |
114 | { | 115 | } |
115 | responseData["error"] = "No access-type specified."; | 116 | |
116 | } | 117 | public void updateInventoryItem(InventoryItemBase item) |
118 | { | ||
119 | throw new Exception("The method or operation is not implemented."); | ||
120 | } | ||
121 | |||
122 | public void deleteInventoryItem(InventoryItemBase item) | ||
123 | { | ||
124 | throw new Exception("The method or operation is not implemented."); | ||
125 | } | ||
126 | |||
127 | public void addInventoryFolder(InventoryFolderBase folder) | ||
128 | { | ||
129 | _databasePlugin.addInventoryFolder(folder); | ||
130 | } | ||
131 | |||
132 | public void updateInventoryFolder(InventoryFolderBase folder) | ||
133 | { | ||
134 | throw new Exception("The method or operation is not implemented."); | ||
135 | } | ||
136 | |||
137 | public void Initialise() | ||
138 | { | ||
139 | throw new Exception("The method or operation is not implemented."); | ||
140 | } | ||
141 | |||
142 | public void Close() | ||
143 | { | ||
144 | throw new Exception("The method or operation is not implemented."); | ||
145 | } | ||
117 | 146 | ||
147 | public string getName() | ||
148 | { | ||
149 | throw new Exception("The method or operation is not implemented."); | ||
150 | } | ||
118 | 151 | ||
119 | // Stuff stops happening here | 152 | public string getVersion() |
153 | { | ||
154 | throw new Exception("The method or operation is not implemented."); | ||
155 | } | ||
120 | 156 | ||
121 | response.Value = responseData; | 157 | public void deleteInventoryCategory(InventoryCategory inventoryCategory) |
122 | return response; | 158 | { |
159 | _databasePlugin.deleteInventoryCategory(inventoryCategory); | ||
123 | } | 160 | } |
161 | |||
162 | #endregion | ||
124 | } | 163 | } |
125 | } | 164 | } |
diff --git a/OpenSim/Grid/InventoryServer/InventoryService.cs b/OpenSim/Grid/InventoryServer/InventoryService.cs new file mode 100644 index 0000000..cbc0558 --- /dev/null +++ b/OpenSim/Grid/InventoryServer/InventoryService.cs | |||
@@ -0,0 +1,136 @@ | |||
1 | using System; | ||
2 | using System.Runtime.Remoting; | ||
3 | using System.Runtime.Remoting.Channels; | ||
4 | using System.Runtime.Remoting.Channels.Tcp; | ||
5 | using System.Runtime.Serialization.Formatters; | ||
6 | using System.Collections; | ||
7 | using System.Collections.Generic; | ||
8 | |||
9 | |||
10 | using libsecondlife; | ||
11 | using OpenSim.Framework.Data; | ||
12 | using OpenSim.Framework.Communications; | ||
13 | using OpenSim.Framework.Configuration; | ||
14 | using InventoryCategory = OpenSim.Framework.Data.InventoryCategory; | ||
15 | |||
16 | namespace OpenSim.Grid.InventoryServer | ||
17 | { | ||
18 | class InventoryServiceSingleton : OpenSim.Framework.Communications.InventoryServiceBase | ||
19 | { | ||
20 | static InventoryManager _inventoryManager; | ||
21 | |||
22 | static public InventoryManager InventoryManager | ||
23 | { | ||
24 | set { _inventoryManager = value; } | ||
25 | get { return _inventoryManager; } | ||
26 | } | ||
27 | |||
28 | #region Singleton Pattern | ||
29 | static InventoryServiceSingleton instance=null; | ||
30 | |||
31 | InventoryServiceSingleton() | ||
32 | { | ||
33 | } | ||
34 | |||
35 | public static InventoryServiceSingleton Instance | ||
36 | { | ||
37 | get | ||
38 | { | ||
39 | if (instance==null) | ||
40 | { | ||
41 | instance = new InventoryServiceSingleton(); | ||
42 | } | ||
43 | return instance; | ||
44 | } | ||
45 | } | ||
46 | #endregion | ||
47 | |||
48 | #region IInventoryServices Members | ||
49 | |||
50 | public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) | ||
51 | { | ||
52 | List<InventoryFolderBase> folders = this.RequestFirstLevelFolders(userID); | ||
53 | InventoryFolderBase rootFolder = null; | ||
54 | |||
55 | //need to make sure we send root folder first | ||
56 | foreach (InventoryFolderBase folder in folders) | ||
57 | { | ||
58 | if (folder.parentID == libsecondlife.LLUUID.Zero) | ||
59 | { | ||
60 | rootFolder = folder; | ||
61 | folderCallBack(userID, folder); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | if (rootFolder != null) | ||
66 | { | ||
67 | foreach (InventoryFolderBase folder in folders) | ||
68 | { | ||
69 | if (folder.folderID != rootFolder.folderID) | ||
70 | { | ||
71 | folderCallBack(userID, folder); | ||
72 | |||
73 | List<InventoryItemBase> items = this.RequestFolderItems(folder.folderID); | ||
74 | foreach (InventoryItemBase item in items) | ||
75 | { | ||
76 | itemCallBack(userID, item); | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | |||
82 | } | ||
83 | |||
84 | public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder) | ||
85 | { | ||
86 | _inventoryManager.addInventoryFolder(folder); | ||
87 | } | ||
88 | |||
89 | public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) | ||
90 | { | ||
91 | throw new Exception("Not implemented exception"); | ||
92 | } | ||
93 | |||
94 | public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) | ||
95 | { | ||
96 | throw new Exception("Not implemented exception"); | ||
97 | } | ||
98 | |||
99 | public List<InventoryItemBase> RequestFolderItems(LLUUID folderID) | ||
100 | { | ||
101 | return _inventoryManager.getInventoryInFolder(folderID); | ||
102 | } | ||
103 | |||
104 | |||
105 | #endregion | ||
106 | } | ||
107 | |||
108 | class InventoryService | ||
109 | { | ||
110 | InventoryServiceSingleton _inventoryServiceMethods; | ||
111 | public InventoryService(InventoryManager inventoryManager, InventoryConfig cfg) | ||
112 | { | ||
113 | // we only need to register the tcp channel once, and we don't know which other modules use remoting | ||
114 | if (ChannelServices.GetChannel("tcp") == null) | ||
115 | { | ||
116 | // Creating a custom formatter for a TcpChannel sink chain. | ||
117 | BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); | ||
118 | serverProvider.TypeFilterLevel = TypeFilterLevel.Full; | ||
119 | |||
120 | IDictionary props = new Hashtable(); | ||
121 | props["port"] = cfg.RemotingPort; | ||
122 | props["typeFilterLevel"] = TypeFilterLevel.Full; | ||
123 | |||
124 | // Pass the properties for the port setting and the server provider in the server chain argument. (Client remains null here.) | ||
125 | ChannelServices.RegisterChannel(new TcpChannel(props, null, serverProvider), true); | ||
126 | } | ||
127 | |||
128 | // Register the object | ||
129 | RemotingConfiguration.RegisterWellKnownServiceType(typeof(InventoryServiceSingleton), "Inventory", WellKnownObjectMode.Singleton); | ||
130 | |||
131 | _inventoryServiceMethods = InventoryServiceSingleton.Instance; | ||
132 | InventoryServiceSingleton.InventoryManager = inventoryManager; | ||
133 | } | ||
134 | |||
135 | } | ||
136 | } | ||
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs index 97addb0..392c741 100644 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ b/OpenSim/Grid/InventoryServer/Main.cs | |||
@@ -31,49 +31,130 @@ using System.Collections.Generic; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Text; | 33 | using System.Text; |
34 | using System.Xml; | ||
35 | |||
34 | using libsecondlife; | 36 | using libsecondlife; |
35 | using OpenSim.Framework.User; | ||
36 | using OpenSim.Framework.Sims; | ||
37 | using OpenSim.Framework.Inventory; | ||
38 | using OpenSim.Framework.Interfaces; | 37 | using OpenSim.Framework.Interfaces; |
39 | using OpenSim.Framework.Console; | 38 | using OpenSim.Framework.Console; |
40 | using OpenSim.Servers; | ||
41 | using OpenSim.Framework.Utilities; | 39 | using OpenSim.Framework.Utilities; |
40 | using OpenSim.Framework.Configuration; | ||
41 | using OpenSim.Framework.Data; | ||
42 | using InventoryCategory = OpenSim.Framework.Data.InventoryCategory; | ||
42 | 43 | ||
43 | namespace OpenGridServices.InventoryServer | 44 | namespace OpenSim.Grid.InventoryServer |
44 | { | 45 | { |
45 | public class OpenInventory_Main : BaseServer, conscmd_callback | 46 | |
47 | public class OpenInventory_Main : conscmd_callback | ||
46 | { | 48 | { |
47 | ConsoleBase m_console; | ||
48 | InventoryManager m_inventoryManager; | ||
49 | 49 | ||
50 | public const string MainLogName = "INVENTORY"; | ||
51 | |||
52 | private InventoryConfig m_config; | ||
53 | LogBase m_console; | ||
54 | InventoryManager m_inventoryManager; ///connection the database backend | ||
55 | InventoryService m_inventoryService; ///Remoting interface, where messages arrive | ||
56 | [STAThread] | ||
50 | public static void Main(string[] args) | 57 | public static void Main(string[] args) |
51 | { | 58 | { |
59 | Console.WriteLine("Launching InventoryServer..."); | ||
60 | |||
61 | OpenInventory_Main inventoryServer = new OpenInventory_Main(); | ||
62 | |||
63 | inventoryServer.Startup(); | ||
64 | |||
65 | // inventoryServer.RunCmd("load", new string[] { "library", "inventory_library.xml" }); | ||
66 | // inventoryServer.RunCmd("load", new string[] { "default", "inventory_default.xml" }); | ||
67 | |||
68 | inventoryServer.Work(); | ||
52 | } | 69 | } |
53 | 70 | ||
54 | public OpenInventory_Main() | 71 | public OpenInventory_Main() |
55 | { | 72 | { |
56 | m_console = new ConsoleBase("opengrid-inventory-console.log", "OpenInventory", this, false); | 73 | |
57 | MainConsole.Instance = m_console; | 74 | if (!Directory.Exists(Util.logDir())) |
75 | { | ||
76 | Directory.CreateDirectory(Util.logDir()); | ||
77 | } | ||
78 | |||
79 | m_console = new LogBase(Path.Combine(Util.logDir(), "opensim-inventory-console.log"), "OpenInventory", this, false); | ||
80 | MainLog.Instance = m_console; | ||
81 | } | ||
82 | |||
83 | private void Work() | ||
84 | { | ||
85 | m_console.Notice(OpenInventory_Main.MainLogName, "Enter help for a list of commands\n"); | ||
86 | |||
87 | while (true) | ||
88 | { | ||
89 | m_console.MainLogPrompt(); | ||
90 | } | ||
58 | } | 91 | } |
59 | 92 | ||
60 | public void Startup() | 93 | public void Startup() |
61 | { | 94 | { |
62 | MainConsole.Instance.Notice("Initialising inventory manager..."); | 95 | MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Initialising inventory manager..."); |
96 | |||
97 | m_config = new InventoryConfig(OpenInventory_Main.MainLogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); | ||
98 | |||
99 | // instantiate the manager, responsible for doing the actual storage | ||
63 | m_inventoryManager = new InventoryManager(); | 100 | m_inventoryManager = new InventoryManager(); |
101 | m_inventoryManager.AddDatabasePlugin(m_config.DatabaseProvider); | ||
102 | |||
103 | m_inventoryService = new InventoryService(m_inventoryManager, m_config); | ||
64 | 104 | ||
65 | MainConsole.Instance.Notice("Starting HTTP server"); | 105 | // Dig out the embedded version number of this assembly |
66 | BaseHttpServer httpServer = new BaseHttpServer(8004); | 106 | Assembly assembly = Assembly.GetExecutingAssembly(); |
107 | string serverExeName = assembly.ManifestModule.Name; | ||
108 | Version serverExeVersion = AssemblyName.GetAssemblyName(serverExeName).Version; | ||
67 | 109 | ||
68 | httpServer.AddXmlRPCHandler("rootfolders", m_inventoryManager.XmlRpcInventoryRequest); | 110 | m_console.Status(OpenInventory_Main.MainLogName, "Inventoryserver {0}.{1}.{2}.{3} - Startup complete", serverExeVersion.Major, serverExeVersion.Minor, serverExeVersion.Revision, serverExeVersion.Build); |
69 | //httpServer.AddRestHandler("GET","/rootfolders/",Rest | ||
70 | } | 111 | } |
71 | 112 | ||
72 | public void RunCmd(string cmd, string[] cmdparams) | 113 | |
114 | public void Load(string[] cmdparams) | ||
73 | { | 115 | { |
116 | string cmd = cmdparams[0]; | ||
117 | string fileName = cmdparams[1]; | ||
118 | |||
119 | if (cmdparams.Length != 2) | ||
120 | { | ||
121 | cmd = "help"; | ||
122 | } | ||
123 | |||
74 | switch (cmd) | 124 | switch (cmd) |
75 | { | 125 | { |
126 | case "library": | ||
127 | InventoryServiceSingleton.Instance.loadInventoryFromXmlFile(InventoryCategory.Library, fileName); | ||
128 | break; | ||
129 | case "default": | ||
130 | InventoryServiceSingleton.Instance.loadInventoryFromXmlFile(InventoryCategory.Default, fileName); | ||
131 | break; | ||
132 | case "user": | ||
133 | InventoryServiceSingleton.Instance.loadInventoryFromXmlFile(InventoryCategory.User, fileName); | ||
134 | break; | ||
135 | case "help": | ||
136 | m_console.Notice("load library <filename>, load library inventory, shared between all users"); | ||
137 | m_console.Notice("load default <filename>, load template inventory, used when creating a new user inventory"); | ||
138 | m_console.Notice("load user <first> <last>, load inventory for a specific users, warning this will reset the contents of the inventory"); | ||
139 | break; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | public void RunCmd(string cmd, string[] cmdparams) | ||
144 | { | ||
145 | switch (cmd) | ||
146 | { | ||
147 | case "help": | ||
148 | m_console.Notice("load - load verious inventories, use \"load help\", to see a list of commands"); | ||
149 | m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); | ||
150 | m_console.Notice("quit - shutdown the grid (USE CAUTION!)"); | ||
151 | break; | ||
152 | case "load": | ||
153 | Load(cmdparams); | ||
154 | break; | ||
155 | case "quit": | ||
76 | case "shutdown": | 156 | case "shutdown": |
157 | MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Shutting down inventory server"); | ||
77 | m_console.Close(); | 158 | m_console.Close(); |
78 | Environment.Exit(0); | 159 | Environment.Exit(0); |
79 | break; | 160 | break; |