aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache
diff options
context:
space:
mode:
authorlbsa712007-11-06 11:10:45 +0000
committerlbsa712007-11-06 11:10:45 +0000
commitee1fcc729c9fe4df367a12ffe4a0d90c7378c160 (patch)
treecc1ecc6f5fe304184ec7c371f950745c948e28a4 /OpenSim/Framework/Communications/Cache
parentteravus debug patch of libode.so from libs (diff)
downloadopensim-SC_OLD-ee1fcc729c9fe4df367a12ffe4a0d90c7378c160.zip
opensim-SC_OLD-ee1fcc729c9fe4df367a12ffe4a0d90c7378c160.tar.gz
opensim-SC_OLD-ee1fcc729c9fe4df367a12ffe4a0d90c7378c160.tar.bz2
opensim-SC_OLD-ee1fcc729c9fe4df367a12ffe4a0d90c7378c160.tar.xz
* Added better logging to AssetCache
* AssetCache now ignores duplicate uploads * some m_ refactoring * ignored some bins
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs108
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs20
2 files changed, 67 insertions, 61 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 6be0852..8adf76c 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -58,37 +58,40 @@ namespace OpenSim.Framework.Communications.Cache
58 //Textures requested from the asset server 58 //Textures requested from the asset server
59 59
60 public Dictionary<LLUUID, TextureSender> SendingTextures = new Dictionary<LLUUID, TextureSender>(); 60 public Dictionary<LLUUID, TextureSender> SendingTextures = new Dictionary<LLUUID, TextureSender>();
61 private BlockingQueue<TextureSender> QueueTextures = new BlockingQueue<TextureSender>();
62 61
63 private Dictionary<LLUUID, List<LLUUID>> AvatarRecievedTextures = new Dictionary<LLUUID, List<LLUUID>>(); 62 public Dictionary<LLUUID, AssetRequestsList> RequestLists = new Dictionary<LLUUID, AssetRequestsList>();
63
64 private BlockingQueue<TextureSender> m_queueTextures = new BlockingQueue<TextureSender>();
65 private Dictionary<LLUUID, List<LLUUID>> m_avatarReceivedTextures = new Dictionary<LLUUID, List<LLUUID>>();
64 66
65 private Dictionary<LLUUID, Dictionary<LLUUID, int>> TimesTextureSent = 67 private Dictionary<LLUUID, Dictionary<LLUUID, int>> m_timesTextureSent =
66 new Dictionary<LLUUID, Dictionary<LLUUID, int>>(); 68 new Dictionary<LLUUID, Dictionary<LLUUID, int>>();
67 69
68 public Dictionary<LLUUID, AssetRequestsList> RequestLists = new Dictionary<LLUUID, AssetRequestsList>();
69 70
70 private IAssetServer _assetServer; 71 private IAssetServer m_assetServer;
71 private Thread _assetCacheThread;
72 72
73 private Thread TextureSenderThread; 73 private Thread m_assetCacheThread;
74 private Thread m_textureSenderThread;
75 private LogBase m_log;
74 76
75 /// <summary> 77 /// <summary>
76 /// 78 ///
77 /// </summary> 79 /// </summary>
78 public AssetCache(IAssetServer assetServer) 80 public AssetCache(IAssetServer assetServer, LogBase log)
79 { 81 {
80 MainLog.Instance.Verbose("ASSETSTORAGE", "Creating Asset cache"); 82 log.Verbose("ASSETSTORAGE", "Creating Asset cache");
81 _assetServer = assetServer; 83 m_assetServer = assetServer;
82 _assetServer.SetReceiver(this); 84 m_assetServer.SetReceiver(this);
83 Assets = new Dictionary<LLUUID, AssetInfo>(); 85 Assets = new Dictionary<LLUUID, AssetInfo>();
84 Textures = new Dictionary<LLUUID, TextureImage>(); 86 Textures = new Dictionary<LLUUID, TextureImage>();
85 _assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); 87 m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
86 _assetCacheThread.IsBackground = true; 88 m_assetCacheThread.IsBackground = true;
87 _assetCacheThread.Start(); 89 m_assetCacheThread.Start();
88 90
89 TextureSenderThread = new Thread(new ThreadStart(ProcessTextureSenders)); 91 m_textureSenderThread = new Thread(new ThreadStart(ProcessTextureSenders));
90 TextureSenderThread.IsBackground = true; 92 m_textureSenderThread.IsBackground = true;
91 TextureSenderThread.Start(); 93 m_textureSenderThread.Start();
94 m_log = log;
92 } 95 }
93 96
94 /// <summary> 97 /// <summary>
@@ -161,7 +164,7 @@ namespace OpenSim.Framework.Communications.Cache
161 RequestLists.Add(assetID, reqList); 164 RequestLists.Add(assetID, reqList);
162 } 165 }
163 } 166 }
164 _assetServer.RequestAsset(assetID, false); 167 m_assetServer.RequestAsset(assetID, false);
165 } 168 }
166 } 169 }
167 170
@@ -171,46 +174,67 @@ namespace OpenSim.Framework.Communications.Cache
171 AssetBase asset = GetAsset(assetID); 174 AssetBase asset = GetAsset(assetID);
172 if (asset == null) 175 if (asset == null)
173 { 176 {
174 _assetServer.RequestAsset(assetID, isTexture); 177 m_assetServer.RequestAsset(assetID, isTexture);
175 } 178 }
176 return asset; 179 return asset;
177 } 180 }
178 181
179 public void AddAsset(AssetBase asset) 182 public void AddAsset(AssetBase asset)
180 { 183 {
181 //System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); 184 string temporary = asset.Temporary ? "temporary" : "";
185 string type = asset.Type == 0 ? "texture" : "asset";
186
187 string result = "Ignored";
188
182 if (asset.Type == 0) 189 if (asset.Type == 0)
183 { 190 {
184 //Console.WriteLine("which is a texture"); 191 if(Textures.ContainsKey(asset.FullID))
185 if (!Textures.ContainsKey(asset.FullID))
186 { 192 {
187 //texture 193 result = "Duplicate ignored.";
188 TextureImage textur = new TextureImage(asset);
189 Textures.Add(textur.FullID, textur);
190 if (!asset.Temporary)
191 _assetServer.StoreAndCommitAsset(asset);
192 } 194 }
193 else 195 else
194 { 196 {
195 TextureImage textur = new TextureImage(asset); 197 TextureImage textur = new TextureImage(asset);
196 Textures[asset.FullID] = textur; 198 Textures.Add(textur.FullID, textur);
199 if (asset.Temporary)
200 {
201 result = "Added to cache";
202 }
203 else
204 {
205 m_assetServer.StoreAndCommitAsset(asset);
206 result = "Added to server";
207 }
197 } 208 }
198 } 209 }
199 else 210 else
200 { 211 {
201 if (!Assets.ContainsKey(asset.FullID)) 212 if (Assets.ContainsKey(asset.FullID))
213 {
214 result = "Duplicate ignored.";
215 }
216 else
202 { 217 {
203 AssetInfo assetInf = new AssetInfo(asset); 218 AssetInfo assetInf = new AssetInfo(asset);
204 Assets.Add(assetInf.FullID, assetInf); 219 Assets.Add(assetInf.FullID, assetInf);
205 if (!asset.Temporary) 220 if (asset.Temporary)
206 _assetServer.StoreAndCommitAsset(asset); 221 {
222 result = "Added to cache";
223 }
224 else
225 {
226 m_assetServer.StoreAndCommitAsset(asset);
227 result = "Added to server";
228 }
207 } 229 }
208 } 230 }
231
232 m_log.Verbose("ASSETCACHE", "Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result);
209 } 233 }
210 234
211 public void DeleteAsset(LLUUID assetID) 235 public void DeleteAsset(LLUUID assetID)
212 { 236 {
213 // this._assetServer.DeleteAsset(assetID); 237 // this.m_assetServer.DeleteAsset(assetID);
214 238
215 //Todo should delete it from memory too 239 //Todo should delete it from memory too
216 } 240 }
@@ -238,7 +262,7 @@ namespace OpenSim.Framework.Communications.Cache
238 TextureSender sender = new TextureSender(req); 262 TextureSender sender = new TextureSender(req);
239 //sender.OnComplete += this.TextureSent; 263 //sender.OnComplete += this.TextureSent;
240 SendingTextures.Add(req.ImageInfo.FullID, sender); 264 SendingTextures.Add(req.ImageInfo.FullID, sender);
241 QueueTextures.Enqueue(sender); 265 m_queueTextures.Enqueue(sender);
242 } 266 }
243 } 267 }
244 268
@@ -249,7 +273,7 @@ namespace OpenSim.Framework.Communications.Cache
249 { 273 {
250 while (true) 274 while (true)
251 { 275 {
252 TextureSender sender = QueueTextures.Dequeue(); 276 TextureSender sender = m_queueTextures.Dequeue();
253 277
254 bool finished = sender.SendTexture(); 278 bool finished = sender.SendTexture();
255 if (finished) 279 if (finished)
@@ -259,7 +283,7 @@ namespace OpenSim.Framework.Communications.Cache
259 else 283 else
260 { 284 {
261 // Console.WriteLine("readding texture"); 285 // Console.WriteLine("readding texture");
262 QueueTextures.Enqueue(sender); 286 m_queueTextures.Enqueue(sender);
263 } 287 }
264 } 288 }
265 } 289 }
@@ -273,7 +297,7 @@ namespace OpenSim.Framework.Communications.Cache
273 if (SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) 297 if (SendingTextures.ContainsKey(sender.request.ImageInfo.FullID))
274 { 298 {
275 SendingTextures.Remove(sender.request.ImageInfo.FullID); 299 SendingTextures.Remove(sender.request.ImageInfo.FullID);
276 // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); 300 // this.m_avatarReceivedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID);
277 } 301 }
278 } 302 }
279 303
@@ -409,7 +433,7 @@ namespace OpenSim.Framework.Communications.Cache
409 request.AssetRequestSource = source; 433 request.AssetRequestSource = source;
410 request.Params = transferRequest.TransferInfo.Params; 434 request.Params = transferRequest.TransferInfo.Params;
411 RequestedAssets.Add(requestID, request); 435 RequestedAssets.Add(requestID, request);
412 _assetServer.RequestAsset(requestID, false); 436 m_assetServer.RequestAsset(requestID, false);
413 } 437 }
414 return; 438 return;
415 } 439 }
@@ -555,11 +579,11 @@ namespace OpenSim.Framework.Communications.Cache
555 { 579 {
556 // System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); 580 // System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber);
557 //check to see if texture is in local cache, if not request from asset server 581 //check to see if texture is in local cache, if not request from asset server
558 if (!AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) 582 if (!m_avatarReceivedTextures.ContainsKey(userInfo.AgentId))
559 { 583 {
560 AvatarRecievedTextures.Add(userInfo.AgentId, new List<LLUUID>()); 584 m_avatarReceivedTextures.Add(userInfo.AgentId, new List<LLUUID>());
561 } 585 }
562 /* if(this.AvatarRecievedTextures[userInfo.AgentId].Contains(imageID)) 586 /* if(this.m_avatarReceivedTextures[userInfo.AgentId].Contains(imageID))
563 { 587 {
564 //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); 588 //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them");
565 return; 589 return;
@@ -576,7 +600,7 @@ namespace OpenSim.Framework.Communications.Cache
576 request.IsTextureRequest = true; 600 request.IsTextureRequest = true;
577 request.DiscardLevel = discard; 601 request.DiscardLevel = discard;
578 RequestedTextures.Add(imageID, request); 602 RequestedTextures.Add(imageID, request);
579 _assetServer.RequestAsset(imageID, true); 603 m_assetServer.RequestAsset(imageID, true);
580 } 604 }
581 return; 605 return;
582 } 606 }
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index 4ff1024..7692057 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -23,7 +23,7 @@ namespace OpenSim.Framework.Communications.Cache
23 23
24 public void LoadDefaultAssets() 24 public void LoadDefaultAssets()
25 { 25 {
26 MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); 26 MainLog.Instance.Verbose("ASSETSERVER", "Setting up asset database");
27 27
28 ForEachDefaultAsset(StoreAsset); 28 ForEachDefaultAsset(StoreAsset);
29 ForEachXmlAsset(StoreAsset); 29 ForEachXmlAsset(StoreAsset);
@@ -106,24 +106,6 @@ namespace OpenSim.Framework.Communications.Cache
106 public virtual List<AssetBase> GetDefaultAssets() 106 public virtual List<AssetBase> GetDefaultAssets()
107 { 107 {
108 List<AssetBase> assets = new List<AssetBase>(); 108 List<AssetBase> assets = new List<AssetBase>();
109 // These assets have been moved into the OpenSimAssetSet.XML file
110 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000001", "Bricks", "bricks.jp2"));
111 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000002", "Plywood", "plywood.jp2"));
112 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000003", "Rocks", "rocks.jp2"));
113 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000004", "Granite", "granite.jp2"));
114 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000005", "Hardwood", "hardwood.jp2"));
115 //assets.Add(CreateImageAsset("00000000-0000-1111-5005-000000000005", "Prim Base Texture", "plywood.jp2"));
116 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000006", "Map Base Texture", "map_base.jp2"));
117 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000007", "Map Texture", "map1.jp2"));
118 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000010", "Female Body Texture", "femalebody.jp2"));
119 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2"));
120 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000012", "Female Face Texture", "femaleface.jp2"));
121
122 //assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false));
123 //assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false));
124 //assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false));
125 //assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false));
126
127 return assets; 109 return assets;
128 } 110 }
129 111