aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs138
1 files changed, 0 insertions, 138 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs
deleted file mode 100644
index b7fd170..0000000
--- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs
+++ /dev/null
@@ -1,138 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Threading;
32using OpenMetaverse;
33using log4net;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38
39namespace OpenSim.Region.Environment.Modules.World.Archiver
40{
41 /// <summary>
42 /// Encapsulate the asynchronous requests for the assets required for an archive operation
43 /// </summary>
44 class AssetsRequest
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 /// <summary>
49 /// uuids to request
50 /// </summary>
51 protected ICollection<UUID> m_uuids;
52
53 /// <summary>
54 /// Callback used when all the assets requested have been received.
55 /// </summary>
56 protected AssetsRequestCallback m_assetsRequestCallback;
57
58 /// <summary>
59 /// Assets retrieved in this request
60 /// </summary>
61 protected Dictionary<UUID, AssetBase> m_assets = new Dictionary<UUID, AssetBase>();
62
63 /// <summary>
64 /// Maintain a list of assets that could not be found. This will be passed back to the requester.
65 /// </summary>
66 protected List<UUID> m_notFoundAssetUuids = new List<UUID>();
67
68 /// <summary>
69 /// Record the number of asset replies required so we know when we've finished
70 /// </summary>
71 private int m_repliesRequired;
72
73 /// <summary>
74 /// Asset cache used to request the assets
75 /// </summary>
76 protected IAssetCache m_assetCache;
77
78 protected internal AssetsRequest(ICollection<UUID> uuids, IAssetCache assetCache, AssetsRequestCallback assetsRequestCallback)
79 {
80 m_uuids = uuids;
81 m_assetsRequestCallback = assetsRequestCallback;
82 m_assetCache = assetCache;
83 m_repliesRequired = uuids.Count;
84 }
85
86 protected internal void Execute()
87 {
88 // We can stop here if there are no assets to fetch
89 if (m_repliesRequired == 0)
90 m_assetsRequestCallback(m_assets, m_notFoundAssetUuids);
91
92 foreach (UUID uuid in m_uuids)
93 {
94 m_assetCache.GetAsset(uuid, AssetRequestCallback, true);
95 }
96 }
97
98 /// <summary>
99 /// Called back by the asset cache when it has the asset
100 /// </summary>
101 /// <param name="assetID"></param>
102 /// <param name="asset"></param>
103 public void AssetRequestCallback(UUID assetID, AssetBase asset)
104 {
105 if (asset != null)
106 m_assets[assetID] = asset;
107 else
108 m_notFoundAssetUuids.Add(assetID);
109
110 //m_log.DebugFormat(
111 // "[ARCHIVER]: Received {0} assets and notification of {1} missing assets", m_assets.Count, m_notFoundAssetUuids.Count);
112
113 if (m_assets.Count + m_notFoundAssetUuids.Count == m_repliesRequired)
114 {
115 // We want to stop using the asset cache thread asap as we now need to do the actual work of producing the archive
116 Thread newThread = new Thread(PerformAssetsRequestCallback);
117 newThread.Name = "OpenSimulator archiving thread post assets receipt";
118 newThread.Start();
119 }
120 }
121
122 /// <summary>
123 /// Perform the callback on the original requester of the assets
124 /// </summary>
125 protected void PerformAssetsRequestCallback()
126 {
127 try
128 {
129 m_assetsRequestCallback(m_assets, m_notFoundAssetUuids);
130 }
131 catch (Exception e)
132 {
133 m_log.ErrorFormat(
134 "[ARCHIVER]: Terminating archive creation since asset requster callback failed with {0}", e);
135 }
136 }
137 }
138}