aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid
diff options
context:
space:
mode:
authorTleiades Hax2007-10-13 07:26:21 +0000
committerTleiades Hax2007-10-13 07:26:21 +0000
commit1232eb1c587ffdc06c26a1c5b1b4fa5f22848754 (patch)
tree468fb8483a2cd03e472a6988ef60f1c8ff01c07e /OpenSim/Grid
parentChange 3 UserServer login messages from writeline to MainLog to help diagnose... (diff)
downloadopensim-SC-1232eb1c587ffdc06c26a1c5b1b4fa5f22848754.zip
opensim-SC-1232eb1c587ffdc06c26a1c5b1b4fa5f22848754.tar.gz
opensim-SC-1232eb1c587ffdc06c26a1c5b1b4fa5f22848754.tar.bz2
opensim-SC-1232eb1c587ffdc06c26a1c5b1b4fa5f22848754.tar.xz
Asset server implementation. Again one of these "plumbing" releases, where no real functionality has been introduced, but ground work has been made, enabling the asset server, and preparing the sim server to query the asset server.
Introduced an "IPlugin" interface, which plugins can inherit from.
Diffstat (limited to 'OpenSim/Grid')
-rw-r--r--OpenSim/Grid/AssetServer/Main.cs193
1 files changed, 22 insertions, 171 deletions
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs
index 6bdb9da..9272f24 100644
--- a/OpenSim/Grid/AssetServer/Main.cs
+++ b/OpenSim/Grid/AssetServer/Main.cs
@@ -28,14 +28,21 @@
28 28
29using System; 29using System;
30using System.IO; 30using System.IO;
31using System.Text; 31
32using Db4objects.Db4o;
33using libsecondlife; 32using libsecondlife;
34using OpenSim.Framework.Console; 33using OpenSim.Framework.Console;
35using OpenSim.Framework.Types;
36using OpenSim.Framework.Servers; 34using OpenSim.Framework.Servers;
35using OpenSim.Framework.Configuration;
36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Utilities; 37using OpenSim.Framework.Utilities;
38 38using OpenSim.Framework.Communications.Caches;
39/*
40using System.Text;
41using Db4objects.Db4o;
42using OpenSim.Framework.Types;
43using OpenSim.Framework.Utilities;
44using OpenSim.Framework.Communications.Caches;
45*/
39namespace OpenSim.Grid.AssetServer 46namespace OpenSim.Grid.AssetServer
40{ 47{
41 /// <summary> 48 /// <summary>
@@ -43,11 +50,11 @@ namespace OpenSim.Grid.AssetServer
43 /// </summary> 50 /// </summary>
44 public class OpenAsset_Main : conscmd_callback 51 public class OpenAsset_Main : conscmd_callback
45 { 52 {
46 private IObjectContainer db;
47
48 public static OpenAsset_Main assetserver; 53 public static OpenAsset_Main assetserver;
49 54
50 private LogBase m_console; 55 private LogBase m_console;
56 private AssetConfig m_config;
57 private IAssetServer m_assetServer;
51 58
52 [STAThread] 59 [STAThread]
53 public static void Main(string[] args) 60 public static void Main(string[] args)
@@ -82,8 +89,10 @@ namespace OpenSim.Grid.AssetServer
82 89
83 public void Startup() 90 public void Startup()
84 { 91 {
92 m_config = new AssetConfig("ASSET SERVER", (Path.Combine(Util.configDir(), "AssetServer_Config.xml")));
93
85 m_console.Verbose("ASSET", "Setting up asset DB"); 94 m_console.Verbose("ASSET", "Setting up asset DB");
86 setupDB(); 95 setupDB(m_config);
87 96
88 m_console.Verbose("ASSET", "Starting HTTP process"); 97 m_console.Verbose("ASSET", "Starting HTTP process");
89 BaseHttpServer httpServer = new BaseHttpServer(8003); 98 BaseHttpServer httpServer = new BaseHttpServer(8003);
@@ -97,180 +106,22 @@ namespace OpenSim.Grid.AssetServer
97 106
98 public byte[] GetAssetData(LLUUID assetID, bool isTexture) 107 public byte[] GetAssetData(LLUUID assetID, bool isTexture)
99 { 108 {
100 bool found = false; 109 return null;
101 AssetStorage foundAsset = null;
102
103 IObjectSet result = db.Get(new AssetStorage(assetID));
104 if (result.Count > 0)
105 {
106 foundAsset = (AssetStorage)result.Next();
107 found = true;
108 }
109
110 if (found)
111 {
112 return foundAsset.Data;
113 }
114 else
115 {
116 return null;
117 }
118 } 110 }
119 111
120 public void setupDB() 112 public void setupDB(AssetConfig config)
121 { 113 {
122 string yappath=(Path.Combine(Util.dataDir(),"gridassets.yap"));
123 bool yapfile = File.Exists(yappath);
124 try 114 try
125 { 115 {
126 db = Db4oFactory.OpenFile(yappath); 116 m_assetServer = new SQLAssetServer(config.DatabaseProvider);
127 MainLog.Instance.Verbose("storage", "Main.cs:setupDB() - creation");
128 } 117 }
129 catch (Exception e) 118 catch (Exception e)
130 { 119 {
131 db.Close(); 120 MainLog.Instance.Warn("ASSET", "setupDB() - Exception occured");
132 MainLog.Instance.Warn("storage", "Main.cs:setupDB() - Exception occured"); 121 MainLog.Instance.Warn("ASSET", e.ToString());
133 MainLog.Instance.Warn("storage", e.ToString());
134 }
135 if (!yapfile)
136 {
137 this.LoadDB();
138 } 122 }
139 } 123 }
140 124
141 public void LoadDB()
142 {
143 try
144 {
145
146 Console.WriteLine("setting up Asset database");
147
148 AssetBase Image = new AssetBase();
149 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000001");
150 Image.Name = "Bricks";
151 this.LoadAsset(Image, true, "bricks.jp2");
152 AssetStorage store = new AssetStorage();
153 store.Data = Image.Data;
154 store.Name = Image.Name;
155 store.UUID = Image.FullID;
156 db.Set(store);
157 db.Commit();
158
159 Image = new AssetBase();
160 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000002");
161 Image.Name = "Plywood";
162 this.LoadAsset(Image, true, "plywood.jp2");
163 store = new AssetStorage();
164 store.Data = Image.Data;
165 store.Name = Image.Name;
166 store.UUID = Image.FullID;
167 db.Set(store);
168 db.Commit();
169
170 Image = new AssetBase();
171 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000003");
172 Image.Name = "Rocks";
173 this.LoadAsset(Image, true, "rocks.jp2");
174 store = new AssetStorage();
175 store.Data = Image.Data;
176 store.Name = Image.Name;
177 store.UUID = Image.FullID;
178 db.Set(store);
179 db.Commit();
180
181 Image = new AssetBase();
182 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000004");
183 Image.Name = "Granite";
184 this.LoadAsset(Image, true, "granite.jp2");
185 store = new AssetStorage();
186 store.Data = Image.Data;
187 store.Name = Image.Name;
188 store.UUID = Image.FullID;
189 db.Set(store);
190 db.Commit();
191
192 Image = new AssetBase();
193 Image.FullID = new LLUUID("00000000-0000-0000-9999-000000000005");
194 Image.Name = "Hardwood";
195 this.LoadAsset(Image, true, "hardwood.jp2");
196 store = new AssetStorage();
197 store.Data = Image.Data;
198 store.Name = Image.Name;
199 store.UUID = Image.FullID;
200 db.Set(store);
201 db.Commit();
202
203 Image = new AssetBase();
204 Image.FullID = new LLUUID("00000000-0000-0000-5005-000000000005");
205 Image.Name = "Prim Base Texture";
206 this.LoadAsset(Image, true, "plywood.jp2");
207 store = new AssetStorage();
208 store.Data = Image.Data;
209 store.Name = Image.Name;
210 store.UUID = Image.FullID;
211 db.Set(store);
212 db.Commit();
213
214 Image = new AssetBase();
215 Image.FullID = new LLUUID("13371337-1337-1337-1337-133713371337");
216 Image.Name = "Peaches";
217 this.LoadAsset(Image, true, "peaches.jp2");
218 store = new AssetStorage();
219 store.Data = Image.Data;
220 store.Name = Image.Name;
221 store.UUID = Image.FullID;
222 db.Set(store);
223 db.Commit();
224
225 Image = new AssetBase();
226 Image.FullID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
227 Image.Name = "Shape";
228 this.LoadAsset(Image, false, "base_shape.dat");
229 store = new AssetStorage();
230 store.Data = Image.Data;
231 store.Name = Image.Name;
232 store.UUID = Image.FullID;
233 db.Set(store);
234 db.Commit();
235 }
236 catch (Exception e)
237 {
238 Console.WriteLine(e.Message);
239 }
240 }
241
242 private void LoadAsset(AssetBase info, bool image, string filename)
243 {
244
245
246 string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets"); //+ folder;
247 string fileName = Path.Combine(dataPath, filename);
248 FileInfo fInfo = new FileInfo(fileName);
249 long numBytes = fInfo.Length;
250 FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
251 byte[] idata = new byte[numBytes];
252 BinaryReader br = new BinaryReader(fStream);
253 idata = br.ReadBytes((int)numBytes);
254 br.Close();
255 fStream.Close();
256 info.Data = idata;
257 //info.loaded=true;
258 }
259
260 public void CreateAsset(LLUUID assetId, byte[] assetData)
261 {
262 AssetBase asset = new AssetBase();
263 asset.Name = "";
264 asset.FullID = assetId;
265 asset.Data = assetData;
266
267 AssetStorage store = new AssetStorage();
268 store.Data = asset.Data;
269 store.Name = asset.Name;
270 store.UUID = asset.FullID;
271 db.Set(store);
272 db.Commit();
273 }
274 125
275 public void RunCmd(string cmd, string[] cmdparams) 126 public void RunCmd(string cmd, string[] cmdparams)
276 { 127 {
@@ -339,7 +190,7 @@ namespace OpenSim.Grid.AssetServer
339 190
340 byte[] assetData = memoryStream.ToArray(); 191 byte[] assetData = memoryStream.ToArray();
341 192
342 m_assetManager.CreateAsset(assetId, assetData); 193// m_assetManager.CreateAsset(assetId, assetData);
343 } 194 }
344 } 195 }
345 196