diff options
author | lbsa71 | 2008-02-09 21:17:47 +0000 |
---|---|---|
committer | lbsa71 | 2008-02-09 21:17:47 +0000 |
commit | 176a1fe3824f8e988efafb6be8e8e12e40132e7c (patch) | |
tree | 7e1daeb9eed243efd4d283af2998d94b9fe96dd6 /OpenSim | |
parent | Added undocumented "modules list" command, lists shared region modules. (diff) | |
download | opensim-SC-176a1fe3824f8e988efafb6be8e8e12e40132e7c.zip opensim-SC-176a1fe3824f8e988efafb6be8e8e12e40132e7c.tar.gz opensim-SC-176a1fe3824f8e988efafb6be8e8e12e40132e7c.tar.bz2 opensim-SC-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')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetCache.cs | 80 | ||||
-rw-r--r-- | OpenSim/Region/Application/OpenSimMain.cs | 10 |
2 files changed, 65 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 | ||
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 0aeb53a..73cfb9a 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs | |||
@@ -651,6 +651,10 @@ namespace OpenSim | |||
651 | 651 | ||
652 | switch (command) | 652 | switch (command) |
653 | { | 653 | { |
654 | case "clear-assets": | ||
655 | m_assetCache.Clear(); | ||
656 | break; | ||
657 | |||
654 | case "set-time": | 658 | case "set-time": |
655 | m_sceneManager.SetCurrentSceneTimePhase(Convert.ToInt32(cmdparams[0])); | 659 | m_sceneManager.SetCurrentSceneTimePhase(Convert.ToInt32(cmdparams[0])); |
656 | break; | 660 | break; |
@@ -679,6 +683,7 @@ namespace OpenSim | |||
679 | m_console.Notice(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive."); | 683 | m_console.Notice(" alert [First] [Last] [Message] - send an alert to a user. Case sensitive."); |
680 | m_console.Notice(" alert general [Message] - send an alert to all users."); | 684 | m_console.Notice(" alert general [Message] - send an alert to all users."); |
681 | m_console.Notice("backup - trigger a simulator backup"); | 685 | m_console.Notice("backup - trigger a simulator backup"); |
686 | m_console.Notice("clear-assets - clear asset cache"); | ||
682 | m_console.Notice("create user - adds a new user"); | 687 | m_console.Notice("create user - adds a new user"); |
683 | m_console.Notice("change-region [name] - sets the region that many of these commands affect."); | 688 | m_console.Notice("change-region [name] - sets the region that many of these commands affect."); |
684 | m_console.Notice("command-script [filename] - Execute command in a file."); | 689 | m_console.Notice("command-script [filename] - Execute command in a file."); |
@@ -697,6 +702,7 @@ namespace OpenSim | |||
697 | m_console.Notice("save-xml2 [filename] - save prims to XML using version 2 format"); | 702 | m_console.Notice("save-xml2 [filename] - save prims to XML using version 2 format"); |
698 | m_console.Notice("script - manually trigger scripts? or script commands?"); | 703 | m_console.Notice("script - manually trigger scripts? or script commands?"); |
699 | m_console.Notice("set-time [x] - set the current scene time phase"); | 704 | m_console.Notice("set-time [x] - set the current scene time phase"); |
705 | m_console.Notice("show assets - show state of asset cache."); | ||
700 | m_console.Notice("show users - show info about connected users."); | 706 | m_console.Notice("show users - show info about connected users."); |
701 | m_console.Notice("show modules - shows info aboutloaded modules."); | 707 | m_console.Notice("show modules - shows info aboutloaded modules."); |
702 | m_console.Notice("show stats - statistical information for this server not displayed in the client"); | 708 | m_console.Notice("show stats - statistical information for this server not displayed in the client"); |
@@ -989,6 +995,10 @@ namespace OpenSim | |||
989 | 995 | ||
990 | switch (ShowWhat) | 996 | switch (ShowWhat) |
991 | { | 997 | { |
998 | case "assets": | ||
999 | m_assetCache.ShowState(); | ||
1000 | break; | ||
1001 | |||
992 | case "users": | 1002 | case "users": |
993 | m_console.Notice( | 1003 | m_console.Notice( |
994 | String.Format("{0,-16}{1,-16}{2,-37}{3,-16}{4,-22}{5,-16}", "Firstname", "Lastname", | 1004 | String.Format("{0,-16}{1,-16}{2,-37}{3,-16}{4,-22}{5,-16}", "Firstname", "Lastname", |