* Added better logging to AssetCache
* AssetCache now ignores duplicate uploads * some m_ refactoring * ignored some binsafrisby
parent
06e7b6bd98
commit
ee1fcc729c
|
@ -58,37 +58,40 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
//Textures requested from the asset server
|
||||
|
||||
public Dictionary<LLUUID, TextureSender> SendingTextures = new Dictionary<LLUUID, TextureSender>();
|
||||
private BlockingQueue<TextureSender> QueueTextures = new BlockingQueue<TextureSender>();
|
||||
|
||||
private Dictionary<LLUUID, List<LLUUID>> AvatarRecievedTextures = new Dictionary<LLUUID, List<LLUUID>>();
|
||||
|
||||
private Dictionary<LLUUID, Dictionary<LLUUID, int>> TimesTextureSent =
|
||||
new Dictionary<LLUUID, Dictionary<LLUUID, int>>();
|
||||
|
||||
public Dictionary<LLUUID, AssetRequestsList> RequestLists = new Dictionary<LLUUID, AssetRequestsList>();
|
||||
|
||||
private IAssetServer _assetServer;
|
||||
private Thread _assetCacheThread;
|
||||
private BlockingQueue<TextureSender> m_queueTextures = new BlockingQueue<TextureSender>();
|
||||
private Dictionary<LLUUID, List<LLUUID>> m_avatarReceivedTextures = new Dictionary<LLUUID, List<LLUUID>>();
|
||||
|
||||
private Thread TextureSenderThread;
|
||||
private Dictionary<LLUUID, Dictionary<LLUUID, int>> m_timesTextureSent =
|
||||
new Dictionary<LLUUID, Dictionary<LLUUID, int>>();
|
||||
|
||||
|
||||
private IAssetServer m_assetServer;
|
||||
|
||||
private Thread m_assetCacheThread;
|
||||
private Thread m_textureSenderThread;
|
||||
private LogBase m_log;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
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<LLUUID, AssetInfo>();
|
||||
Textures = new Dictionary<LLUUID, TextureImage>();
|
||||
_assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
|
||||
_assetCacheThread.IsBackground = true;
|
||||
_assetCacheThread.Start();
|
||||
m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
|
||||
m_assetCacheThread.IsBackground = true;
|
||||
m_assetCacheThread.Start();
|
||||
|
||||
TextureSenderThread = new Thread(new ThreadStart(ProcessTextureSenders));
|
||||
TextureSenderThread.IsBackground = true;
|
||||
TextureSenderThread.Start();
|
||||
m_textureSenderThread = new Thread(new ThreadStart(ProcessTextureSenders));
|
||||
m_textureSenderThread.IsBackground = true;
|
||||
m_textureSenderThread.Start();
|
||||
m_log = log;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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<LLUUID>());
|
||||
m_avatarReceivedTextures.Add(userInfo.AgentId, new List<LLUUID>());
|
||||
}
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
@ -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<AssetBase> GetDefaultAssets()
|
||||
{
|
||||
List<AssetBase> assets = new List<AssetBase>();
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,24 +58,25 @@ namespace OpenSim.Region.Capabilities
|
|||
//private string m_requestTexture = "0003/";
|
||||
private string m_notecardUpdatePath = "0004/";
|
||||
//private string eventQueue = "0100/";
|
||||
private BaseHttpServer httpListener;
|
||||
private LLUUID agentID;
|
||||
private AssetCache assetCache;
|
||||
private int eventQueueCount = 1;
|
||||
private Queue<string> CapsEventQueue = new Queue<string>();
|
||||
public NewInventoryItem AddNewInventoryItem = null;
|
||||
public ItemUpdatedCallback ItemUpdatedCall = null;
|
||||
private BaseHttpServer m_httpListener;
|
||||
private LLUUID m_agentID;
|
||||
private AssetCache m_assetCache;
|
||||
private int m_eventQueueCount = 1;
|
||||
private Queue<string> m_capsEventQueue = new Queue<string>();
|
||||
private bool m_dumpAssetsToFile;
|
||||
|
||||
public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath,
|
||||
public NewInventoryItem AddNewInventoryItem = null;
|
||||
public ItemUpdatedCallback ItemUpdatedCall = null;
|
||||
|
||||
public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath,
|
||||
LLUUID agent, bool dumpAssetsToFile)
|
||||
{
|
||||
assetCache = assetCach;
|
||||
m_assetCache = assetCache;
|
||||
m_capsObjectPath = capsPath;
|
||||
httpListener = httpServer;
|
||||
m_httpListener = httpServer;
|
||||
m_httpListenerHostName = httpListen;
|
||||
m_httpListenPort = httpPort;
|
||||
agentID = agent;
|
||||
m_agentID = agent;
|
||||
m_dumpAssetsToFile = dumpAssetsToFile;
|
||||
}
|
||||
|
||||
|
@ -88,17 +89,17 @@ namespace OpenSim.Region.Capabilities
|
|||
string capsBase = "/CAPS/" + m_capsObjectPath;
|
||||
try
|
||||
{
|
||||
httpListener.AddStreamHandler(
|
||||
m_httpListener.AddStreamHandler(
|
||||
new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath,
|
||||
GetMapLayer));
|
||||
httpListener.AddStreamHandler(
|
||||
m_httpListener.AddStreamHandler(
|
||||
new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST",
|
||||
capsBase + m_newInventory,
|
||||
NewAgentInventoryRequest));
|
||||
|
||||
AddLegacyCapsHandler(httpListener, m_requestPath, CapsRequest);
|
||||
//AddLegacyCapsHandler(httpListener, m_requestTexture , RequestTexture);
|
||||
AddLegacyCapsHandler(httpListener, m_notecardUpdatePath, NoteCardAgentInventory);
|
||||
AddLegacyCapsHandler(m_httpListener, m_requestPath, CapsRequest);
|
||||
//AddLegacyCapsHandler(m_httpListener, m_requestTexture , RequestTexture);
|
||||
AddLegacyCapsHandler(m_httpListener, m_notecardUpdatePath, NoteCardAgentInventory);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -198,11 +199,11 @@ namespace OpenSim.Region.Capabilities
|
|||
{
|
||||
string res = "";
|
||||
|
||||
if (CapsEventQueue.Count > 0)
|
||||
if (m_capsEventQueue.Count > 0)
|
||||
{
|
||||
lock (CapsEventQueue)
|
||||
lock (m_capsEventQueue)
|
||||
{
|
||||
string item = CapsEventQueue.Dequeue();
|
||||
string item = m_capsEventQueue.Dequeue();
|
||||
res = item;
|
||||
}
|
||||
}
|
||||
|
@ -222,13 +223,13 @@ namespace OpenSim.Region.Capabilities
|
|||
public string CreateEstablishAgentComms(string caps, string ipAddressPort)
|
||||
{
|
||||
LLSDCapEvent eventItem = new LLSDCapEvent();
|
||||
eventItem.id = eventQueueCount;
|
||||
eventItem.id = m_eventQueueCount;
|
||||
//should be creating a EstablishAgentComms item, but there isn't a class for it yet
|
||||
eventItem.events.Array.Add(new LLSDEmpty());
|
||||
string res = LLSDHelpers.SerialiseLLSDReply(eventItem);
|
||||
eventQueueCount++;
|
||||
m_eventQueueCount++;
|
||||
|
||||
CapsEventQueue.Enqueue(res);
|
||||
m_capsEventQueue.Enqueue(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -239,10 +240,10 @@ namespace OpenSim.Region.Capabilities
|
|||
public string CreateEmptyEventResponse()
|
||||
{
|
||||
LLSDCapEvent eventItem = new LLSDCapEvent();
|
||||
eventItem.id = eventQueueCount;
|
||||
eventItem.id = m_eventQueueCount;
|
||||
eventItem.events.Array.Add(new LLSDEmpty());
|
||||
string res = LLSDHelpers.SerialiseLLSDReply(eventItem);
|
||||
eventQueueCount++;
|
||||
m_eventQueueCount++;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -266,10 +267,10 @@ namespace OpenSim.Region.Capabilities
|
|||
string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
|
||||
|
||||
ItemUpdater uploader =
|
||||
new ItemUpdater(newInvItem, capsBase + uploaderPath, httpListener, m_dumpAssetsToFile);
|
||||
new ItemUpdater(newInvItem, capsBase + uploaderPath, m_httpListener, m_dumpAssetsToFile);
|
||||
uploader.OnUpLoad += ItemUpdated;
|
||||
|
||||
httpListener.AddStreamHandler(
|
||||
m_httpListener.AddStreamHandler(
|
||||
new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
|
||||
string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase +
|
||||
uploaderPath;
|
||||
|
@ -300,8 +301,8 @@ namespace OpenSim.Region.Capabilities
|
|||
|
||||
AssetUploader uploader =
|
||||
new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
|
||||
llsdRequest.asset_type, capsBase + uploaderPath, httpListener, m_dumpAssetsToFile);
|
||||
httpListener.AddStreamHandler(
|
||||
llsdRequest.asset_type, capsBase + uploaderPath, m_httpListener, m_dumpAssetsToFile);
|
||||
m_httpListener.AddStreamHandler(
|
||||
new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
|
||||
string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase +
|
||||
uploaderPath;
|
||||
|
@ -344,11 +345,11 @@ namespace OpenSim.Region.Capabilities
|
|||
asset.InvType = inType;
|
||||
asset.Name = assetName;
|
||||
asset.Data = data;
|
||||
assetCache.AddAsset(asset);
|
||||
m_assetCache.AddAsset(asset);
|
||||
|
||||
InventoryItemBase item = new InventoryItemBase();
|
||||
item.avatarID = agentID;
|
||||
item.creatorsID = agentID;
|
||||
item.avatarID = m_agentID;
|
||||
item.creatorsID = m_agentID;
|
||||
item.inventoryID = inventoryItem;
|
||||
item.assetID = asset.FullID;
|
||||
item.inventoryDescription = assetDescription;
|
||||
|
@ -361,7 +362,7 @@ namespace OpenSim.Region.Capabilities
|
|||
|
||||
if (AddNewInventoryItem != null)
|
||||
{
|
||||
AddNewInventoryItem(agentID, item);
|
||||
AddNewInventoryItem(m_agentID, item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,7 +370,7 @@ namespace OpenSim.Region.Capabilities
|
|||
{
|
||||
if (ItemUpdatedCall != null)
|
||||
{
|
||||
return ItemUpdatedCall(agentID, itemID, data);
|
||||
return ItemUpdatedCall(m_agentID, itemID, data);
|
||||
}
|
||||
return LLUUID.Zero;
|
||||
}
|
||||
|
|
|
@ -386,7 +386,7 @@ namespace OpenSim
|
|||
assetServer = sqlAssetServer;
|
||||
}
|
||||
|
||||
m_assetCache = new AssetCache(assetServer);
|
||||
m_assetCache = new AssetCache(assetServer, m_log);
|
||||
// m_assetCache = new assetCache("OpenSim.Region.GridInterfaces.Local.dll", m_networkServersInfo.AssetURL, m_networkServersInfo.AssetSendKey);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace SimpleApp
|
|||
|
||||
LocalAssetServer assetServer = new LocalAssetServer();
|
||||
|
||||
m_assetCache = new AssetCache(assetServer);
|
||||
m_assetCache = new AssetCache(assetServer, m_log);
|
||||
}
|
||||
|
||||
public void Run()
|
||||
|
|
Loading…
Reference in New Issue