aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
authorlbsa712008-02-09 21:17:47 +0000
committerlbsa712008-02-09 21:17:47 +0000
commit176a1fe3824f8e988efafb6be8e8e12e40132e7c (patch)
tree7e1daeb9eed243efd4d283af2998d94b9fe96dd6 /OpenSim/Framework/Communications
parentAdded undocumented "modules list" command, lists shared region modules. (diff)
downloadopensim-SC_OLD-176a1fe3824f8e988efafb6be8e8e12e40132e7c.zip
opensim-SC_OLD-176a1fe3824f8e988efafb6be8e8e12e40132e7c.tar.gz
opensim-SC_OLD-176a1fe3824f8e988efafb6be8e8e12e40132e7c.tar.bz2
opensim-SC_OLD-176a1fe3824f8e988efafb6be8e8e12e40132e7c.tar.xz
* added two new commands (for debug/disaster recovery)
'show assets' shows the current state of the asset cache (number of cached assets, requests, et c) 'clear-assets' forcibly re-initializes the asset cache thereby freeing all cached items. 'clear-assets' is not to be used lightly, as it probably introduces mem inconsistencies and doubling up of textures.
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs80
1 files changed, 55 insertions, 25 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 158a9bd..0134f18 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -49,31 +49,61 @@ namespace OpenSim.Framework.Communications.Cache
49 public Dictionary<LLUUID, AssetInfo> Assets; 49 public Dictionary<LLUUID, AssetInfo> Assets;
50 public Dictionary<LLUUID, TextureImage> Textures; 50 public Dictionary<LLUUID, TextureImage> Textures;
51 51
52 public List<AssetRequest> AssetRequests = new List<AssetRequest>(); //assets ready to be sent to viewers 52 public List<AssetRequest> AssetRequests; //assets ready to be sent to viewers
53 public List<AssetRequest> TextureRequests = new List<AssetRequest>(); //textures ready to be sent 53 public List<AssetRequest> TextureRequests; //textures ready to be sent
54 54
55 public Dictionary<LLUUID, AssetRequest> RequestedAssets = new Dictionary<LLUUID, AssetRequest>(); 55 public Dictionary<LLUUID, AssetRequest> RequestedAssets;
56 //Assets requested from the asset server 56 //Assets requested from the asset server
57 57
58 public Dictionary<LLUUID, AssetRequest> RequestedTextures = new Dictionary<LLUUID, AssetRequest>(); 58 public Dictionary<LLUUID, AssetRequest> RequestedTextures;
59 //Textures requested from the asset server 59 //Textures requested from the asset server
60 60
61 public Dictionary<LLUUID, AssetRequestsList> RequestLists = new Dictionary<LLUUID, AssetRequestsList>(); 61 public Dictionary<LLUUID, AssetRequestsList> RequestLists;
62 62
63 private readonly IAssetServer m_assetServer; 63 private readonly IAssetServer m_assetServer;
64 64
65 private readonly Thread m_assetCacheThread; 65 private readonly Thread m_assetCacheThread;
66 66
67 /// <summary> 67 public void ShowState()
68 /// 68 {
69 /// </summary> 69 m_log.InfoFormat("Assets:{0} Testures:{1} AssetRequests:{2} TextureRequests:{3} RequestedAssets:{4} RequestedTextures:{5} RequestLists:{6}",
70 Assets.Count,
71 Textures.Count,
72 AssetRequests.Count,
73 TextureRequests.Count,
74 RequestedAssets.Count,
75 RequestedTextures.Count,
76 RequestLists.Count );
77 }
78
79 public void Clear()
80 {
81 m_log.Info("[ASSETSTORAGE]: Clearing Asset cache");
82 Initialize();
83 }
84
85 private void Initialize()
86 {
87 Assets = new Dictionary<LLUUID, AssetInfo>();
88 Textures = new Dictionary<LLUUID, TextureImage>();
89 AssetRequests = new List<AssetRequest>(); //assets ready to be sent to viewers
90 TextureRequests = new List<AssetRequest>(); //textures ready to be sent
91
92 RequestedAssets = new Dictionary<LLUUID, AssetRequest>();
93 RequestedTextures = new Dictionary<LLUUID, AssetRequest>();
94 RequestLists = new Dictionary<LLUUID, AssetRequestsList>();
95 }
96
97
70 public AssetCache(IAssetServer assetServer) 98 public AssetCache(IAssetServer assetServer)
71 { 99 {
72 m_log.Info("[ASSETSTORAGE]: Creating Asset cache"); 100 m_log.Info("[ASSETSTORAGE]: Creating Asset cache");
101 Initialize();
102
73 m_assetServer = assetServer; 103 m_assetServer = assetServer;
74 m_assetServer.SetReceiver(this); 104 m_assetServer.SetReceiver(this);
75 Assets = new Dictionary<LLUUID, AssetInfo>(); 105
76 Textures = new Dictionary<LLUUID, TextureImage>(); 106
77 m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); 107 m_assetCacheThread = new Thread(new ThreadStart(RunAssetManager));
78 m_assetCacheThread.IsBackground = true; 108 m_assetCacheThread.IsBackground = true;
79 m_assetCacheThread.Start(); 109 m_assetCacheThread.Start();
@@ -222,13 +252,13 @@ namespace OpenSim.Framework.Communications.Cache
222 result = "Duplicate ignored."; 252 result = "Duplicate ignored.";
223 } 253 }
224 else 254 else
225 { 255 {
226 TextureImage textur = new TextureImage(asset); 256 TextureImage textur = new TextureImage(asset);
227 Textures.Add(textur.FullID, textur); 257 Textures.Add(textur.FullID, textur);
228 258
229 if (StatsManager.SimExtraStats != null) 259 if (StatsManager.SimExtraStats != null)
230 StatsManager.SimExtraStats.AddTexture(textur); 260 StatsManager.SimExtraStats.AddTexture(textur);
231 261
232 if (asset.Temporary) 262 if (asset.Temporary)
233 { 263 {
234 result = "Added to cache"; 264 result = "Added to cache";
@@ -250,10 +280,10 @@ namespace OpenSim.Framework.Communications.Cache
250 { 280 {
251 AssetInfo assetInf = new AssetInfo(asset); 281 AssetInfo assetInf = new AssetInfo(asset);
252 Assets.Add(assetInf.FullID, assetInf); 282 Assets.Add(assetInf.FullID, assetInf);
253 283
254 if (StatsManager.SimExtraStats != null) 284 if (StatsManager.SimExtraStats != null)
255 StatsManager.SimExtraStats.AddAsset(assetInf); 285 StatsManager.SimExtraStats.AddAsset(assetInf);
256 286
257 if (asset.Temporary) 287 if (asset.Temporary)
258 { 288 {
259 result = "Added to cache"; 289 result = "Added to cache";
@@ -302,12 +332,12 @@ namespace OpenSim.Framework.Communications.Cache
302 332
303 TextureImage image = new TextureImage(asset); 333 TextureImage image = new TextureImage(asset);
304 if (!Textures.ContainsKey(image.FullID)) 334 if (!Textures.ContainsKey(image.FullID))
305 { 335 {
306 Textures.Add(image.FullID, image); 336 Textures.Add(image.FullID, image);
307 337
308 if (StatsManager.SimExtraStats != null) 338 if (StatsManager.SimExtraStats != null)
309 StatsManager.SimExtraStats.AddTexture(image); 339 StatsManager.SimExtraStats.AddTexture(image);
310 340
311 if (RequestedTextures.ContainsKey(image.FullID)) 341 if (RequestedTextures.ContainsKey(image.FullID))
312 { 342 {
313 AssetRequest req = RequestedTextures[image.FullID]; 343 AssetRequest req = RequestedTextures[image.FullID];
@@ -326,10 +356,10 @@ namespace OpenSim.Framework.Communications.Cache
326 if (!Assets.ContainsKey(assetInf.FullID)) 356 if (!Assets.ContainsKey(assetInf.FullID))
327 { 357 {
328 Assets.Add(assetInf.FullID, assetInf); 358 Assets.Add(assetInf.FullID, assetInf);
329 359
330 if (StatsManager.SimExtraStats != null) 360 if (StatsManager.SimExtraStats != null)
331 StatsManager.SimExtraStats.AddAsset(assetInf); 361 StatsManager.SimExtraStats.AddAsset(assetInf);
332 362
333 if (RequestedAssets.ContainsKey(assetInf.FullID)) 363 if (RequestedAssets.ContainsKey(assetInf.FullID))
334 { 364 {
335 AssetRequest req = RequestedAssets[assetInf.FullID]; 365 AssetRequest req = RequestedAssets[assetInf.FullID];
@@ -384,7 +414,7 @@ namespace OpenSim.Framework.Communications.Cache
384 { 414 {
385 // over max number of bytes so split up file 415 // over max number of bytes so split up file
386 long restData = data.LongLength - m_maxPacketSize; 416 long restData = data.LongLength - m_maxPacketSize;
387 int restPackets = (int) ((restData + m_maxPacketSize - 1)/m_maxPacketSize); 417 int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
388 numPackets += restPackets; 418 numPackets += restPackets;
389 } 419 }
390 420
@@ -465,7 +495,7 @@ namespace OpenSim.Framework.Communications.Cache
465 AssetRequest req; 495 AssetRequest req;
466 for (int i = 0; i < num; i++) 496 for (int i = 0; i < num; i++)
467 { 497 {
468 req = (AssetRequest) AssetRequests[i]; 498 req = (AssetRequest)AssetRequests[i];
469 //Console.WriteLine("sending asset " + req.RequestAssetID); 499 //Console.WriteLine("sending asset " + req.RequestAssetID);
470 TransferInfoPacket Transfer = new TransferInfoPacket(); 500 TransferInfoPacket Transfer = new TransferInfoPacket();
471 Transfer.TransferInfo.ChannelType = 2; 501 Transfer.TransferInfo.ChannelType = 2;
@@ -475,7 +505,7 @@ namespace OpenSim.Framework.Communications.Cache
475 { 505 {
476 Transfer.TransferInfo.Params = new byte[20]; 506 Transfer.TransferInfo.Params = new byte[20];
477 Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); 507 Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
478 int assType = (int) req.AssetInf.Type; 508 int assType = (int)req.AssetInf.Type;
479 Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); 509 Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
480 } 510 }
481 else if (req.AssetRequestSource == 3) 511 else if (req.AssetRequestSource == 3)
@@ -485,7 +515,7 @@ namespace OpenSim.Framework.Communications.Cache
485 //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); 515 //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
486 //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); 516 //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
487 } 517 }
488 Transfer.TransferInfo.Size = (int) req.AssetInf.Data.Length; 518 Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length;
489 Transfer.TransferInfo.TransferID = req.TransferRequestID; 519 Transfer.TransferInfo.TransferID = req.TransferRequestID;
490 req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset); 520 req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset);
491 521