From ee1fcc729c9fe4df367a12ffe4a0d90c7378c160 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 6 Nov 2007 11:10:45 +0000 Subject: * Added better logging to AssetCache * AssetCache now ignores duplicate uploads * some m_ refactoring * ignored some bins --- .../Framework/Communications/Cache/AssetCache.cs | 108 +++++++++++++-------- .../Communications/Cache/AssetServerBase.cs | 20 +--- 2 files changed, 67 insertions(+), 61 deletions(-) (limited to 'OpenSim/Framework/Communications/Cache') 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 //Textures requested from the asset server public Dictionary SendingTextures = new Dictionary(); - private BlockingQueue QueueTextures = new BlockingQueue(); - private Dictionary> AvatarRecievedTextures = new Dictionary>(); + public Dictionary RequestLists = new Dictionary(); + + private BlockingQueue m_queueTextures = new BlockingQueue(); + private Dictionary> m_avatarReceivedTextures = new Dictionary>(); - private Dictionary> TimesTextureSent = + private Dictionary> m_timesTextureSent = new Dictionary>(); - public Dictionary RequestLists = new Dictionary(); - private IAssetServer _assetServer; - private Thread _assetCacheThread; + private IAssetServer m_assetServer; - private Thread TextureSenderThread; + private Thread m_assetCacheThread; + private Thread m_textureSenderThread; + private LogBase m_log; /// /// /// - public AssetCache(IAssetServer assetServer) + public AssetCache(IAssetServer assetServer, LogBase log) { - MainLog.Instance.Verbose("ASSETSTORAGE", "Creating Asset cache"); - _assetServer = assetServer; - _assetServer.SetReceiver(this); + log.Verbose("ASSETSTORAGE", "Creating Asset cache"); + m_assetServer = assetServer; + m_assetServer.SetReceiver(this); Assets = new Dictionary(); Textures = new Dictionary(); - _assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); - _assetCacheThread.IsBackground = true; - _assetCacheThread.Start(); - - TextureSenderThread = new Thread(new ThreadStart(ProcessTextureSenders)); - TextureSenderThread.IsBackground = true; - TextureSenderThread.Start(); + m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); + m_assetCacheThread.IsBackground = true; + m_assetCacheThread.Start(); + + m_textureSenderThread = new Thread(new ThreadStart(ProcessTextureSenders)); + m_textureSenderThread.IsBackground = true; + m_textureSenderThread.Start(); + m_log = log; } /// @@ -161,7 +164,7 @@ namespace OpenSim.Framework.Communications.Cache RequestLists.Add(assetID, reqList); } } - _assetServer.RequestAsset(assetID, false); + m_assetServer.RequestAsset(assetID, false); } } @@ -171,46 +174,67 @@ namespace OpenSim.Framework.Communications.Cache AssetBase asset = GetAsset(assetID); if (asset == null) { - _assetServer.RequestAsset(assetID, isTexture); + m_assetServer.RequestAsset(assetID, isTexture); } return asset; } public void AddAsset(AssetBase asset) { - //System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); + string temporary = asset.Temporary ? "temporary" : ""; + string type = asset.Type == 0 ? "texture" : "asset"; + + string result = "Ignored"; + if (asset.Type == 0) { - //Console.WriteLine("which is a texture"); - if (!Textures.ContainsKey(asset.FullID)) + if(Textures.ContainsKey(asset.FullID)) { - //texture - TextureImage textur = new TextureImage(asset); - Textures.Add(textur.FullID, textur); - if (!asset.Temporary) - _assetServer.StoreAndCommitAsset(asset); + result = "Duplicate ignored."; } else { TextureImage textur = new TextureImage(asset); - Textures[asset.FullID] = textur; + Textures.Add(textur.FullID, textur); + if (asset.Temporary) + { + result = "Added to cache"; + } + else + { + m_assetServer.StoreAndCommitAsset(asset); + result = "Added to server"; + } } } else { - if (!Assets.ContainsKey(asset.FullID)) + if (Assets.ContainsKey(asset.FullID)) + { + result = "Duplicate ignored."; + } + else { AssetInfo assetInf = new AssetInfo(asset); Assets.Add(assetInf.FullID, assetInf); - if (!asset.Temporary) - _assetServer.StoreAndCommitAsset(asset); + if (asset.Temporary) + { + result = "Added to cache"; + } + else + { + m_assetServer.StoreAndCommitAsset(asset); + result = "Added to server"; + } } } + + m_log.Verbose("ASSETCACHE", "Adding {0} {1} [{2}]: {3}.", temporary, type, asset.FullID, result); } public void DeleteAsset(LLUUID assetID) { - // this._assetServer.DeleteAsset(assetID); + // this.m_assetServer.DeleteAsset(assetID); //Todo should delete it from memory too } @@ -238,7 +262,7 @@ namespace OpenSim.Framework.Communications.Cache TextureSender sender = new TextureSender(req); //sender.OnComplete += this.TextureSent; SendingTextures.Add(req.ImageInfo.FullID, sender); - QueueTextures.Enqueue(sender); + m_queueTextures.Enqueue(sender); } } @@ -249,7 +273,7 @@ namespace OpenSim.Framework.Communications.Cache { while (true) { - TextureSender sender = QueueTextures.Dequeue(); + TextureSender sender = m_queueTextures.Dequeue(); bool finished = sender.SendTexture(); if (finished) @@ -259,7 +283,7 @@ namespace OpenSim.Framework.Communications.Cache else { // Console.WriteLine("readding texture"); - QueueTextures.Enqueue(sender); + m_queueTextures.Enqueue(sender); } } } @@ -273,7 +297,7 @@ namespace OpenSim.Framework.Communications.Cache if (SendingTextures.ContainsKey(sender.request.ImageInfo.FullID)) { SendingTextures.Remove(sender.request.ImageInfo.FullID); - // this.AvatarRecievedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); + // this.m_avatarReceivedTextures[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID); } } @@ -409,7 +433,7 @@ namespace OpenSim.Framework.Communications.Cache request.AssetRequestSource = source; request.Params = transferRequest.TransferInfo.Params; RequestedAssets.Add(requestID, request); - _assetServer.RequestAsset(requestID, false); + m_assetServer.RequestAsset(requestID, false); } return; } @@ -555,11 +579,11 @@ namespace OpenSim.Framework.Communications.Cache { // System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); //check to see if texture is in local cache, if not request from asset server - if (!AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) + if (!m_avatarReceivedTextures.ContainsKey(userInfo.AgentId)) { - AvatarRecievedTextures.Add(userInfo.AgentId, new List()); + m_avatarReceivedTextures.Add(userInfo.AgentId, new List()); } - /* if(this.AvatarRecievedTextures[userInfo.AgentId].Contains(imageID)) + /* if(this.m_avatarReceivedTextures[userInfo.AgentId].Contains(imageID)) { //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); return; @@ -576,7 +600,7 @@ namespace OpenSim.Framework.Communications.Cache request.IsTextureRequest = true; request.DiscardLevel = discard; RequestedTextures.Add(imageID, request); - _assetServer.RequestAsset(imageID, true); + m_assetServer.RequestAsset(imageID, true); } return; } 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 public void LoadDefaultAssets() { - MainLog.Instance.Verbose("SQL ASSET SERVER", "Setting up asset database"); + MainLog.Instance.Verbose("ASSETSERVER", "Setting up asset database"); ForEachDefaultAsset(StoreAsset); ForEachXmlAsset(StoreAsset); @@ -106,24 +106,6 @@ namespace OpenSim.Framework.Communications.Cache public virtual List GetDefaultAssets() { List assets = new List(); - // These assets have been moved into the OpenSimAssetSet.XML file - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000001", "Bricks", "bricks.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000002", "Plywood", "plywood.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000003", "Rocks", "rocks.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000004", "Granite", "granite.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000005", "Hardwood", "hardwood.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-5005-000000000005", "Prim Base Texture", "plywood.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000006", "Map Base Texture", "map_base.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000007", "Map Texture", "map1.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000010", "Female Body Texture", "femalebody.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); - //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000012", "Female Face Texture", "femaleface.jp2")); - - //assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); - //assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); - //assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); - //assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); - return assets; } -- cgit v1.1