diff options
author | Justin Clark-Casey (justincc) | 2013-03-15 21:53:39 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-03-15 21:53:39 +0000 |
commit | 924d6e892a7b5a61e900b910a5a35de488963529 (patch) | |
tree | 90a557f03dba4e61444cc2b3708cc808b25f6442 /OpenSim/Services/AssetService/XAssetService.cs | |
parent | Add example code to DOExampleModule to pull data from that previously saved b... (diff) | |
download | opensim-SC-924d6e892a7b5a61e900b910a5a35de488963529.zip opensim-SC-924d6e892a7b5a61e900b910a5a35de488963529.tar.gz opensim-SC-924d6e892a7b5a61e900b910a5a35de488963529.tar.bz2 opensim-SC-924d6e892a7b5a61e900b910a5a35de488963529.tar.xz |
Make it possible to chain another asset service underneath the de-duplicating XAssetService.
This makes it possible to use the dedupliicating service without needing to migrate all the existing asset data beforehand.
Currently controlled by a ChainedServiceModule setting in [AssetService] (e.g. ChainedServiceModule = "OpenSim.Services.AssetService.dll:AssetService")
Not yet ready for use.
Diffstat (limited to 'OpenSim/Services/AssetService/XAssetService.cs')
-rw-r--r-- | OpenSim/Services/AssetService/XAssetService.cs | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/OpenSim/Services/AssetService/XAssetService.cs b/OpenSim/Services/AssetService/XAssetService.cs index a1d10ed..7dd48c9 100644 --- a/OpenSim/Services/AssetService/XAssetService.cs +++ b/OpenSim/Services/AssetService/XAssetService.cs | |||
@@ -39,8 +39,7 @@ using OpenMetaverse; | |||
39 | namespace OpenSim.Services.AssetService | 39 | namespace OpenSim.Services.AssetService |
40 | { | 40 | { |
41 | /// <summary> | 41 | /// <summary> |
42 | /// This will be developed into a de-duplicating asset service. | 42 | /// A de-duplicating asset service. |
43 | /// XXX: Currently it's a just a copy of the existing AssetService. so please don't attempt to use it. | ||
44 | /// </summary> | 43 | /// </summary> |
45 | public class XAssetService : XAssetServiceBase, IAssetService | 44 | public class XAssetService : XAssetServiceBase, IAssetService |
46 | { | 45 | { |
@@ -48,7 +47,9 @@ namespace OpenSim.Services.AssetService | |||
48 | 47 | ||
49 | protected static XAssetService m_RootInstance; | 48 | protected static XAssetService m_RootInstance; |
50 | 49 | ||
51 | public XAssetService(IConfigSource config) : base(config) | 50 | public XAssetService(IConfigSource config) : this(config, "AssetService") {} |
51 | |||
52 | public XAssetService(IConfigSource config, string configName) : base(config, configName) | ||
52 | { | 53 | { |
53 | if (m_RootInstance == null) | 54 | if (m_RootInstance == null) |
54 | { | 55 | { |
@@ -56,22 +57,21 @@ namespace OpenSim.Services.AssetService | |||
56 | 57 | ||
57 | if (m_AssetLoader != null) | 58 | if (m_AssetLoader != null) |
58 | { | 59 | { |
59 | IConfig assetConfig = config.Configs["AssetService"]; | 60 | IConfig assetConfig = config.Configs[configName]; |
60 | if (assetConfig == null) | 61 | if (assetConfig == null) |
61 | throw new Exception("No AssetService configuration"); | 62 | throw new Exception("No AssetService configuration"); |
62 | 63 | ||
63 | string loaderArgs = assetConfig.GetString("AssetLoaderArgs", | 64 | string loaderArgs = assetConfig.GetString("AssetLoaderArgs", String.Empty); |
64 | String.Empty); | ||
65 | 65 | ||
66 | bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true); | 66 | bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true); |
67 | 67 | ||
68 | if (assetLoaderEnabled) | 68 | if (assetLoaderEnabled && !HasChainedAssetService) |
69 | { | 69 | { |
70 | m_log.DebugFormat("[XASSET SERVICE]: Loading default asset set from {0}", loaderArgs); | 70 | m_log.DebugFormat("[XASSET SERVICE]: Loading default asset set from {0}", loaderArgs); |
71 | 71 | ||
72 | m_AssetLoader.ForEachDefaultXmlAsset( | 72 | m_AssetLoader.ForEachDefaultXmlAsset( |
73 | loaderArgs, | 73 | loaderArgs, |
74 | delegate(AssetBase a) | 74 | a => |
75 | { | 75 | { |
76 | AssetBase existingAsset = Get(a.ID); | 76 | AssetBase existingAsset = Get(a.ID); |
77 | // AssetMetadata existingMetadata = GetMetadata(a.ID); | 77 | // AssetMetadata existingMetadata = GetMetadata(a.ID); |
@@ -103,7 +103,14 @@ namespace OpenSim.Services.AssetService | |||
103 | 103 | ||
104 | try | 104 | try |
105 | { | 105 | { |
106 | return m_Database.GetAsset(assetID); | 106 | AssetBase asset = m_Database.GetAsset(assetID); |
107 | |||
108 | if (asset != null) | ||
109 | return asset; | ||
110 | else if (HasChainedAssetService) | ||
111 | return m_ChainedAssetService.Get(id); | ||
112 | else | ||
113 | return null; | ||
107 | } | 114 | } |
108 | catch (Exception e) | 115 | catch (Exception e) |
109 | { | 116 | { |
@@ -128,9 +135,17 @@ namespace OpenSim.Services.AssetService | |||
128 | 135 | ||
129 | AssetBase asset = m_Database.GetAsset(assetID); | 136 | AssetBase asset = m_Database.GetAsset(assetID); |
130 | if (asset != null) | 137 | if (asset != null) |
138 | { | ||
131 | return asset.Metadata; | 139 | return asset.Metadata; |
132 | 140 | } | |
133 | return null; | 141 | else if (HasChainedAssetService) |
142 | { | ||
143 | return m_ChainedAssetService.GetMetadata(id); | ||
144 | } | ||
145 | else | ||
146 | { | ||
147 | return null; | ||
148 | } | ||
134 | } | 149 | } |
135 | 150 | ||
136 | public virtual byte[] GetData(string id) | 151 | public virtual byte[] GetData(string id) |
@@ -143,7 +158,13 @@ namespace OpenSim.Services.AssetService | |||
143 | return null; | 158 | return null; |
144 | 159 | ||
145 | AssetBase asset = m_Database.GetAsset(assetID); | 160 | AssetBase asset = m_Database.GetAsset(assetID); |
146 | return asset.Data; | 161 | |
162 | if (asset != null) | ||
163 | return asset.Data; | ||
164 | else if (HasChainedAssetService) | ||
165 | return m_ChainedAssetService.GetData(id); | ||
166 | else | ||
167 | return null; | ||
147 | } | 168 | } |
148 | 169 | ||
149 | public virtual bool Get(string id, Object sender, AssetRetrieved handler) | 170 | public virtual bool Get(string id, Object sender, AssetRetrieved handler) |
@@ -157,6 +178,9 @@ namespace OpenSim.Services.AssetService | |||
157 | 178 | ||
158 | AssetBase asset = m_Database.GetAsset(assetID); | 179 | AssetBase asset = m_Database.GetAsset(assetID); |
159 | 180 | ||
181 | if (asset == null && HasChainedAssetService) | ||
182 | asset = m_ChainedAssetService.Get(id); | ||
183 | |||
160 | //m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset); | 184 | //m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset); |
161 | 185 | ||
162 | handler(id, sender, asset); | 186 | handler(id, sender, asset); |
@@ -194,6 +218,9 @@ namespace OpenSim.Services.AssetService | |||
194 | if (!UUID.TryParse(id, out assetID)) | 218 | if (!UUID.TryParse(id, out assetID)) |
195 | return false; | 219 | return false; |
196 | 220 | ||
221 | // Don't bother deleting from a chained asset service. This isn't a big deal since deleting happens | ||
222 | // very rarely. | ||
223 | |||
197 | return m_Database.Delete(id); | 224 | return m_Database.Delete(id); |
198 | } | 225 | } |
199 | } | 226 | } |