diff options
author | diva | 2009-05-17 01:38:43 +0000 |
---|---|---|
committer | diva | 2009-05-17 01:38:43 +0000 |
commit | aac8ca041170f6d1d648c6c5244dc3dfad428587 (patch) | |
tree | 190873d49a54f7462190331344aa308d8b6eb15f | |
parent | Send the owner name, not the client name on SendDialog. (diff) | |
download | opensim-SC_OLD-aac8ca041170f6d1d648c6c5244dc3dfad428587.zip opensim-SC_OLD-aac8ca041170f6d1d648c6c5244dc3dfad428587.tar.gz opensim-SC_OLD-aac8ca041170f6d1d648c6c5244dc3dfad428587.tar.bz2 opensim-SC_OLD-aac8ca041170f6d1d648c6c5244dc3dfad428587.tar.xz |
HG asset transfers starting to work -- GETs only for now.
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs | 62 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs | 76 | ||||
-rw-r--r-- | OpenSim/Servers/Connectors/Asset/AssetServiceConnector.cs | 11 | ||||
-rw-r--r-- | OpenSim/Services/AssetService/AssetService.cs | 1 | ||||
-rw-r--r-- | OpenSim/Services/AssetService/HGAssetService.cs | 80 | ||||
-rw-r--r-- | bin/OpenSim.ini.example | 9 | ||||
-rw-r--r-- | prebuild.xml | 1 |
7 files changed, 138 insertions, 102 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs index d537d7b..c3a878e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetBroker.cs | |||
@@ -35,6 +35,7 @@ using OpenSim.Servers.Base; | |||
35 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using OpenMetaverse; | ||
38 | 39 | ||
39 | namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | 40 | namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset |
40 | { | 41 | { |
@@ -46,7 +47,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
46 | MethodBase.GetCurrentMethod().DeclaringType); | 47 | MethodBase.GetCurrentMethod().DeclaringType); |
47 | 48 | ||
48 | private IImprovedAssetCache m_Cache = null; | 49 | private IImprovedAssetCache m_Cache = null; |
49 | private IAssetService m_LocalService; | 50 | private IAssetService m_GridService; |
50 | private IAssetService m_HGService; | 51 | private IAssetService m_HGService; |
51 | 52 | ||
52 | private bool m_Enabled = false; | 53 | private bool m_Enabled = false; |
@@ -67,29 +68,29 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
67 | IConfig assetConfig = source.Configs["AssetService"]; | 68 | IConfig assetConfig = source.Configs["AssetService"]; |
68 | if (assetConfig == null) | 69 | if (assetConfig == null) |
69 | { | 70 | { |
70 | m_log.Error("[ASSET CONNECTOR]: AssetService missing from OpanSim.ini"); | 71 | m_log.Error("[HG ASSET CONNECTOR]: AssetService missing from OpenSim.ini"); |
71 | return; | 72 | return; |
72 | } | 73 | } |
73 | 74 | ||
74 | string localDll = assetConfig.GetString("LocalModule", | 75 | string localDll = assetConfig.GetString("LocalGridAssetService", |
75 | String.Empty); | 76 | String.Empty); |
76 | string HGDll = assetConfig.GetString("HypergridModule", | 77 | string HGDll = assetConfig.GetString("HypergridAssetService", |
77 | String.Empty); | 78 | String.Empty); |
78 | 79 | ||
79 | if (localDll == String.Empty) | 80 | if (localDll == String.Empty) |
80 | { | 81 | { |
81 | m_log.Error("[ASSET CONNECTOR]: No LocalModule named in section AssetService"); | 82 | m_log.Error("[HG ASSET CONNECTOR]: No LocalGridAssetService named in section AssetService"); |
82 | return; | 83 | return; |
83 | } | 84 | } |
84 | 85 | ||
85 | if (HGDll == String.Empty) | 86 | if (HGDll == String.Empty) |
86 | { | 87 | { |
87 | m_log.Error("[ASSET CONNECTOR]: No HypergridModule named in section AssetService"); | 88 | m_log.Error("[HG ASSET CONNECTOR]: No HypergridAssetService named in section AssetService"); |
88 | return; | 89 | return; |
89 | } | 90 | } |
90 | 91 | ||
91 | Object[] args = new Object[] { source }; | 92 | Object[] args = new Object[] { source }; |
92 | m_LocalService = | 93 | m_GridService = |
93 | ServerUtils.LoadPlugin<IAssetService>(localDll, | 94 | ServerUtils.LoadPlugin<IAssetService>(localDll, |
94 | args); | 95 | args); |
95 | 96 | ||
@@ -97,19 +98,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
97 | ServerUtils.LoadPlugin<IAssetService>(HGDll, | 98 | ServerUtils.LoadPlugin<IAssetService>(HGDll, |
98 | args); | 99 | args); |
99 | 100 | ||
100 | if (m_LocalService == null) | 101 | if (m_GridService == null) |
101 | { | 102 | { |
102 | m_log.Error("[ASSET CONNECTOR]: Can't load local asset service"); | 103 | m_log.Error("[HG ASSET CONNECTOR]: Can't load local asset service"); |
103 | return; | 104 | return; |
104 | } | 105 | } |
105 | if (m_HGService == null) | 106 | if (m_HGService == null) |
106 | { | 107 | { |
107 | m_log.Error("[ASSET CONNECTOR]: Can't load hypergrid asset service"); | 108 | m_log.Error("[HG ASSET CONNECTOR]: Can't load hypergrid asset service"); |
108 | return; | 109 | return; |
109 | } | 110 | } |
110 | 111 | ||
111 | m_Enabled = true; | 112 | m_Enabled = true; |
112 | m_log.Info("[ASSET CONNECTOR]: HG asset broker enabled"); | 113 | m_log.Info("[HG ASSET CONNECTOR]: HG asset broker enabled"); |
113 | } | 114 | } |
114 | } | 115 | } |
115 | } | 116 | } |
@@ -147,11 +148,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
147 | m_Cache = null; | 148 | m_Cache = null; |
148 | } | 149 | } |
149 | 150 | ||
150 | m_log.InfoFormat("[ASSET CONNECTOR]: Enabled hypergrid asset broker for region {0}", scene.RegionInfo.RegionName); | 151 | m_log.InfoFormat("[HG ASSET CONNECTOR]: Enabled hypergrid asset broker for region {0}", scene.RegionInfo.RegionName); |
151 | 152 | ||
152 | if (m_Cache != null) | 153 | if (m_Cache != null) |
153 | { | 154 | { |
154 | m_log.InfoFormat("[ASSET CONNECTOR]: Enabled asset caching for region {0}", scene.RegionInfo.RegionName); | 155 | m_log.InfoFormat("[HG ASSET CONNECTOR]: Enabled asset caching for region {0}", scene.RegionInfo.RegionName); |
155 | } | 156 | } |
156 | } | 157 | } |
157 | 158 | ||
@@ -168,20 +169,36 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
168 | 169 | ||
169 | public AssetBase Get(string id) | 170 | public AssetBase Get(string id) |
170 | { | 171 | { |
172 | m_log.DebugFormat("[HG ASSET CONNECTOR]: Get {0}", id); | ||
171 | AssetBase asset = null; | 173 | AssetBase asset = null; |
172 | 174 | ||
173 | if (m_Cache != null) | 175 | if (m_Cache != null) |
174 | { | 176 | { |
175 | m_Cache.Get(id); | 177 | asset = m_Cache.Get(id); |
176 | 178 | ||
177 | if (asset != null) | 179 | if (asset != null) |
178 | return asset; | 180 | return asset; |
181 | else | ||
182 | m_log.DebugFormat("[HG ASSSET CONNECTOR]: Requested asset is not in cache. This shouldn't happen."); | ||
179 | } | 183 | } |
180 | 184 | ||
181 | if (IsHG(id)) | 185 | if (IsHG(id)) |
186 | { | ||
182 | asset = m_HGService.Get(id); | 187 | asset = m_HGService.Get(id); |
188 | if (asset != null) | ||
189 | { | ||
190 | // Now store it locally | ||
191 | // For now, let me just do it for textures and scripts | ||
192 | if (((AssetType)asset.Type == AssetType.Texture) || | ||
193 | ((AssetType)asset.Type == AssetType.LSLBytecode) || | ||
194 | ((AssetType)asset.Type == AssetType.LSLText)) | ||
195 | { | ||
196 | m_GridService.Store(asset); | ||
197 | } | ||
198 | } | ||
199 | } | ||
183 | else | 200 | else |
184 | asset = m_LocalService.Get(id); | 201 | asset = m_GridService.Get(id); |
185 | 202 | ||
186 | if (asset != null) | 203 | if (asset != null) |
187 | { | 204 | { |
@@ -210,7 +227,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
210 | if (IsHG(id)) | 227 | if (IsHG(id)) |
211 | metadata = m_HGService.GetMetadata(id); | 228 | metadata = m_HGService.GetMetadata(id); |
212 | else | 229 | else |
213 | metadata = m_LocalService.GetMetadata(id); | 230 | metadata = m_GridService.GetMetadata(id); |
214 | 231 | ||
215 | return metadata; | 232 | return metadata; |
216 | } | 233 | } |
@@ -231,7 +248,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
231 | if (IsHG(id)) | 248 | if (IsHG(id)) |
232 | asset = m_HGService.Get(id); | 249 | asset = m_HGService.Get(id); |
233 | else | 250 | else |
234 | asset = m_LocalService.Get(id); | 251 | asset = m_GridService.Get(id); |
235 | 252 | ||
236 | if (asset != null) | 253 | if (asset != null) |
237 | { | 254 | { |
@@ -267,7 +284,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
267 | } | 284 | } |
268 | else | 285 | else |
269 | { | 286 | { |
270 | return m_LocalService.Get(id, sender, delegate (string assetID, Object s, AssetBase a) | 287 | return m_GridService.Get(id, sender, delegate (string assetID, Object s, AssetBase a) |
271 | { | 288 | { |
272 | if (a != null && m_Cache != null) | 289 | if (a != null && m_Cache != null) |
273 | m_Cache.Cache(a); | 290 | m_Cache.Cache(a); |
@@ -281,10 +298,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
281 | if (m_Cache != null) | 298 | if (m_Cache != null) |
282 | m_Cache.Cache(asset); | 299 | m_Cache.Cache(asset); |
283 | 300 | ||
301 | if (asset.Temporary || asset.Local) | ||
302 | return asset.ID; | ||
303 | |||
284 | if (IsHG(asset.ID)) | 304 | if (IsHG(asset.ID)) |
285 | return m_HGService.Store(asset); | 305 | return m_HGService.Store(asset); |
286 | else | 306 | else |
287 | return m_LocalService.Store(asset); | 307 | return m_GridService.Store(asset); |
288 | } | 308 | } |
289 | 309 | ||
290 | public bool UpdateContent(string id, byte[] data) | 310 | public bool UpdateContent(string id, byte[] data) |
@@ -303,7 +323,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
303 | if (IsHG(id)) | 323 | if (IsHG(id)) |
304 | return m_HGService.UpdateContent(id, data); | 324 | return m_HGService.UpdateContent(id, data); |
305 | else | 325 | else |
306 | return m_LocalService.UpdateContent(id, data); | 326 | return m_GridService.UpdateContent(id, data); |
307 | } | 327 | } |
308 | 328 | ||
309 | public bool Delete(string id) | 329 | public bool Delete(string id) |
@@ -314,7 +334,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
314 | if (IsHG(id)) | 334 | if (IsHG(id)) |
315 | return m_HGService.Delete(id); | 335 | return m_HGService.Delete(id); |
316 | else | 336 | else |
317 | return m_LocalService.Delete(id); | 337 | return m_GridService.Delete(id); |
318 | } | 338 | } |
319 | } | 339 | } |
320 | } | 340 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index 985ee98..e659ad1 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs | |||
@@ -108,50 +108,16 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
108 | return m_assetMap.ContainsKey(uuid); | 108 | return m_assetMap.ContainsKey(uuid); |
109 | } | 109 | } |
110 | 110 | ||
111 | private bool FetchAsset(GridAssetClient asscli, UUID assetID, bool isTexture) | 111 | private AssetBase FetchAsset(string url, UUID assetID, bool isTexture) |
112 | { | 112 | { |
113 | // I'm not going over 3 seconds since this will be blocking processing of all the other inbound | 113 | AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString()); |
114 | // packets from the client. | ||
115 | int pollPeriod = 200; | ||
116 | int maxPolls = 15; | ||
117 | 114 | ||
118 | AssetBase asset; | 115 | if (asset != null) |
119 | |||
120 | // Maybe it came late, and it's already here. Check first. | ||
121 | if (m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset)) | ||
122 | { | 116 | { |
123 | m_log.Debug("[HGScene]: Asset already in asset cache. " + assetID); | 117 | m_log.Debug("[HGScene]: Asset made it to asset cache. " + asset.Name + " " + assetID); |
124 | return true; | 118 | return asset; |
125 | } | 119 | } |
126 | 120 | return null; | |
127 | |||
128 | asscli.RequestAsset(assetID, isTexture); | ||
129 | |||
130 | do | ||
131 | { | ||
132 | Thread.Sleep(pollPeriod); | ||
133 | |||
134 | if (m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset) && (asset != null)) | ||
135 | { | ||
136 | m_log.Debug("[HGScene]: Asset made it to asset cache. " + asset.Name + " " + assetID); | ||
137 | // I think I need to store it in the asset DB too. | ||
138 | // For now, let me just do it for textures and scripts | ||
139 | if (((AssetType)asset.Type == AssetType.Texture) || | ||
140 | ((AssetType)asset.Type == AssetType.LSLBytecode) || | ||
141 | ((AssetType)asset.Type == AssetType.LSLText)) | ||
142 | { | ||
143 | AssetBase asset1 = new AssetBase(); | ||
144 | Copy(asset, asset1); | ||
145 | m_scene.CommsManager.AssetCache.AssetServer.StoreAsset(asset1); | ||
146 | } | ||
147 | return true; | ||
148 | } | ||
149 | } while (--maxPolls > 0); | ||
150 | |||
151 | m_log.WarnFormat("[HGScene]: {0} {1} was not received before the retrieval timeout was reached", | ||
152 | isTexture ? "texture" : "asset", assetID.ToString()); | ||
153 | |||
154 | return false; | ||
155 | } | 121 | } |
156 | 122 | ||
157 | private bool PostAsset(GridAssetClient asscli, UUID assetID, bool isTexture) | 123 | private bool PostAsset(GridAssetClient asscli, UUID assetID, bool isTexture) |
@@ -291,39 +257,25 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
291 | 257 | ||
292 | public void Get(UUID assetID, UUID ownerID) | 258 | public void Get(UUID assetID, UUID ownerID) |
293 | { | 259 | { |
294 | if (!IsInAssetMap(assetID) && !IsLocalUser(ownerID)) | 260 | if (!IsLocalUser(ownerID)) |
295 | { | 261 | { |
296 | // Get the item from the remote asset server onto the local AssetCache | 262 | // Get the item from the remote asset server onto the local AssetCache |
297 | // and place an entry in m_assetMap | 263 | // and place an entry in m_assetMap |
298 | 264 | ||
299 | GridAssetClient asscli = null; | ||
300 | string userAssetURL = UserAssetURL(ownerID); | 265 | string userAssetURL = UserAssetURL(ownerID); |
301 | if (userAssetURL != null) | 266 | if (userAssetURL != null) |
302 | { | 267 | { |
303 | m_assetServers.TryGetValue(userAssetURL, out asscli); | ||
304 | if (asscli == null) | ||
305 | { | ||
306 | m_log.Debug("[HGScene]: Starting new GridAssetClient for " + userAssetURL); | ||
307 | asscli = new GridAssetClient(userAssetURL); | ||
308 | asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache! | ||
309 | m_assetServers.Add(userAssetURL, asscli); | ||
310 | asscli.Start(); | ||
311 | } | ||
312 | |||
313 | m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL); | 268 | m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL); |
314 | bool success = FetchAsset(asscli, assetID, false); // asscli.RequestAsset(item.ItemID, false); | 269 | AssetBase asset = FetchAsset(userAssetURL, assetID, false); |
315 | 270 | ||
316 | // OK, now fetch the inside. | 271 | if (asset != null) |
317 | Dictionary<UUID, bool> ids = SniffUUIDs(assetID); | ||
318 | Dump(ids); | ||
319 | foreach (KeyValuePair<UUID, bool> kvp in ids) | ||
320 | FetchAsset(asscli, kvp.Key, kvp.Value); | ||
321 | |||
322 | |||
323 | if (success) | ||
324 | { | 272 | { |
325 | m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL); | 273 | m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL); |
326 | m_assetMap.Add(assetID, asscli); | 274 | // OK, now fetch the inside. |
275 | Dictionary<UUID, bool> ids = SniffUUIDs(asset); | ||
276 | Dump(ids); | ||
277 | foreach (KeyValuePair<UUID, bool> kvp in ids) | ||
278 | FetchAsset(userAssetURL, kvp.Key, kvp.Value); | ||
327 | } | 279 | } |
328 | else | 280 | else |
329 | m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); | 281 | m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); |
diff --git a/OpenSim/Servers/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Servers/Connectors/Asset/AssetServiceConnector.cs index 8888c87..b2b4cc2 100644 --- a/OpenSim/Servers/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Servers/Connectors/Asset/AssetServiceConnector.cs | |||
@@ -45,10 +45,15 @@ namespace OpenSim.Servers.Connectors | |||
45 | MethodBase.GetCurrentMethod().DeclaringType); | 45 | MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private string m_ServerURI = String.Empty; | 47 | private string m_ServerURI = String.Empty; |
48 | private IImprovedAssetCache m_Cache = null; | 48 | private IImprovedAssetCache m_Cache = null; |
49 | |||
50 | public AssetServicesConnector() | ||
51 | { | ||
52 | } | ||
49 | 53 | ||
50 | public AssetServicesConnector() | 54 | public AssetServicesConnector(string serverURI) |
51 | { | 55 | { |
56 | m_ServerURI = serverURI; | ||
52 | } | 57 | } |
53 | 58 | ||
54 | public AssetServicesConnector(IConfigSource source) | 59 | public AssetServicesConnector(IConfigSource source) |
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index af3a746..968cf5c 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs | |||
@@ -66,6 +66,7 @@ namespace OpenSim.Services.AssetService | |||
66 | 66 | ||
67 | public AssetBase Get(string id) | 67 | public AssetBase Get(string id) |
68 | { | 68 | { |
69 | m_log.DebugFormat("[ASSET SERVICE]: Get asset {0}", id); | ||
69 | UUID assetID; | 70 | UUID assetID; |
70 | 71 | ||
71 | if (!UUID.TryParse(id, out assetID)) | 72 | if (!UUID.TryParse(id, out assetID)) |
diff --git a/OpenSim/Services/AssetService/HGAssetService.cs b/OpenSim/Services/AssetService/HGAssetService.cs index 87e42fe..0b6389f 100644 --- a/OpenSim/Services/AssetService/HGAssetService.cs +++ b/OpenSim/Services/AssetService/HGAssetService.cs | |||
@@ -28,11 +28,13 @@ | |||
28 | using log4net; | 28 | using log4net; |
29 | using Nini.Config; | 29 | using Nini.Config; |
30 | using System; | 30 | using System; |
31 | using System.Collections.Generic; | ||
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Servers.Connectors; | ||
33 | using OpenSim.Services.Interfaces; | 35 | using OpenSim.Services.Interfaces; |
34 | 36 | ||
35 | namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | 37 | namespace OpenSim.Services.AssetService |
36 | { | 38 | { |
37 | public class HGAssetService : IAssetService | 39 | public class HGAssetService : IAssetService |
38 | { | 40 | { |
@@ -40,6 +42,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
40 | LogManager.GetLogger( | 42 | LogManager.GetLogger( |
41 | MethodBase.GetCurrentMethod().DeclaringType); | 43 | MethodBase.GetCurrentMethod().DeclaringType); |
42 | 44 | ||
45 | private Dictionary<string, AssetServicesConnector> m_connectors = new Dictionary<string, AssetServicesConnector>(); | ||
46 | |||
43 | public HGAssetService(IConfigSource source) | 47 | public HGAssetService(IConfigSource source) |
44 | { | 48 | { |
45 | IConfig moduleConfig = source.Configs["ServiceConnectors"]; | 49 | IConfig moduleConfig = source.Configs["ServiceConnectors"]; |
@@ -50,27 +54,68 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
50 | IConfig assetConfig = source.Configs["AssetService"]; | 54 | IConfig assetConfig = source.Configs["AssetService"]; |
51 | if (assetConfig == null) | 55 | if (assetConfig == null) |
52 | { | 56 | { |
53 | m_log.Error("[ASSET CONNECTOR]: AssetService missing from OpanSim.ini"); | 57 | m_log.Error("[HG ASSET SERVICE]: AssetService missing from OpanSim.ini"); |
54 | return; | 58 | return; |
55 | } | 59 | } |
56 | 60 | ||
57 | m_log.Info("[ASSET CONNECTOR]: HG asset service enabled"); | 61 | m_log.Info("[HG ASSET SERVICE]: HG asset service enabled"); |
58 | } | 62 | } |
59 | } | 63 | } |
60 | 64 | ||
61 | // | 65 | private bool StringToUrlAndAssetID(string id, out string url, out string assetID) |
62 | // Note to Diva: | 66 | { |
63 | // | 67 | url = String.Empty; |
64 | // This is not the broker! | 68 | assetID = String.Empty; |
65 | // This module is not supposed to route anything anywhere. This is where | 69 | |
66 | // the code to access remote assets (by URL) goes. It can be assumed | 70 | Uri assetUri; |
67 | // that the ID is a URL. The broker makes sure of that. | 71 | |
68 | // | 72 | if (Uri.TryCreate(id, UriKind.Absolute, out assetUri) && |
69 | // This is a disposable comment :) Feel free to remove it | 73 | assetUri.Scheme == Uri.UriSchemeHttp) |
70 | // | 74 | { |
75 | url = "http://" + assetUri.Authority; | ||
76 | assetID = assetUri.LocalPath; | ||
77 | return true; | ||
78 | } | ||
79 | |||
80 | return false; | ||
81 | } | ||
82 | |||
83 | private IAssetService GetConnector(string url) | ||
84 | { | ||
85 | AssetServicesConnector connector = null; | ||
86 | lock (m_connectors) | ||
87 | { | ||
88 | if (m_connectors.ContainsKey(url)) | ||
89 | { | ||
90 | connector = m_connectors[url]; | ||
91 | } | ||
92 | else | ||
93 | { | ||
94 | // We're instantiating this class explicitly, but this won't | ||
95 | // work in general, because the remote grid may be running | ||
96 | // an asset server that has a different protocol. | ||
97 | // Eventually we will want a piece of meta-protocol asking | ||
98 | // the remote server about its kind, and even asking it | ||
99 | // to send its own connector, which we would instantiate | ||
100 | // dynamically. Definitely coo, thing to do! | ||
101 | connector = new AssetServicesConnector(url); | ||
102 | m_connectors.Add(url, connector); | ||
103 | } | ||
104 | } | ||
105 | return connector; | ||
106 | } | ||
71 | 107 | ||
72 | public AssetBase Get(string id) | 108 | public AssetBase Get(string id) |
73 | { | 109 | { |
110 | string url = string.Empty; | ||
111 | string assetID = string.Empty; | ||
112 | |||
113 | if (StringToUrlAndAssetID(id, out url, out assetID)) | ||
114 | { | ||
115 | IAssetService connector = GetConnector(url); | ||
116 | return connector.Get(assetID); | ||
117 | } | ||
118 | |||
74 | return null; | 119 | return null; |
75 | } | 120 | } |
76 | 121 | ||
@@ -86,6 +131,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | |||
86 | 131 | ||
87 | public bool Get(string id, Object sender, AssetRetrieved handler) | 132 | public bool Get(string id, Object sender, AssetRetrieved handler) |
88 | { | 133 | { |
134 | string url = string.Empty; | ||
135 | string assetID = string.Empty; | ||
136 | |||
137 | if (StringToUrlAndAssetID(id, out url, out assetID)) | ||
138 | { | ||
139 | IAssetService connector = GetConnector(url); | ||
140 | return connector.Get(assetID, sender, handler); | ||
141 | } | ||
142 | |||
89 | return false; | 143 | return false; |
90 | } | 144 | } |
91 | 145 | ||
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index e84cd57..6d061bb 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example | |||
@@ -1297,9 +1297,12 @@ | |||
1297 | 1297 | ||
1298 | ; Paremeters for the Hypergrid connector | 1298 | ; Paremeters for the Hypergrid connector |
1299 | 1299 | ||
1300 | ; Parameters for the HG Broker | 1300 | ;; Parameters for the HG Broker |
1301 | ;LocalModule = "OpenSim.Services.AssetService.dll:AssetService" | 1301 | ; Use this one if you have a standalone grid |
1302 | ;HypergridModule = "OpenSim.Services.AssetService.dll:HGAssetService" | 1302 | LocalGridAssetService = "OpenSim.Services.AssetService.dll:AssetService" |
1303 | ; Use this one if this sim is connected to a grid-wide asset server | ||
1304 | ;LocalGridAssetService = "OpenSim.Servers.Connectors.dll:AssetServiceConnector" | ||
1305 | HypergridAssetService = "OpenSim.Services.AssetService.dll:HGAssetService" | ||
1303 | 1306 | ||
1304 | [AssetCache] | 1307 | [AssetCache] |
1305 | ; Number of buckets for assets | 1308 | ; Number of buckets for assets |
diff --git a/prebuild.xml b/prebuild.xml index 38ab757..d2ed73e 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -1318,6 +1318,7 @@ | |||
1318 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | 1318 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> |
1319 | <Reference name="OpenSim.Services.Interfaces"/> | 1319 | <Reference name="OpenSim.Services.Interfaces"/> |
1320 | <Reference name="OpenSim.Services.Base"/> | 1320 | <Reference name="OpenSim.Services.Base"/> |
1321 | <Reference name="OpenSim.Servers.Connectors"/> | ||
1321 | <Reference name="OpenSim.Data"/> | 1322 | <Reference name="OpenSim.Data"/> |
1322 | <Reference name="Nini.dll" /> | 1323 | <Reference name="Nini.dll" /> |
1323 | <Reference name="log4net.dll"/> | 1324 | <Reference name="log4net.dll"/> |