aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs69
1 files changed, 61 insertions, 8 deletions
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
index 2bfa597..c753c6a 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Services.Connectors
56 // Keeps track of concurrent requests for the same asset, so that it's only loaded once. 56 // Keeps track of concurrent requests for the same asset, so that it's only loaded once.
57 // Maps: Asset ID -> Handlers which will be called when the asset has been loaded 57 // Maps: Asset ID -> Handlers which will be called when the asset has been loaded
58 private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>(); 58 private Dictionary<string, AssetRetrievedEx> m_AssetHandlers = new Dictionary<string, AssetRetrievedEx>();
59 59 private Dictionary<string, string> m_UriMap = new Dictionary<string, string>();
60 60
61 public AssetServicesConnector() 61 public AssetServicesConnector()
62 { 62 {
@@ -98,6 +98,34 @@ namespace OpenSim.Services.Connectors
98 m_retryTimer = new Timer(); 98 m_retryTimer = new Timer();
99 m_retryTimer.Elapsed += new ElapsedEventHandler(retryCheck); 99 m_retryTimer.Elapsed += new ElapsedEventHandler(retryCheck);
100 m_retryTimer.Interval = 60000; 100 m_retryTimer.Interval = 60000;
101
102 Uri serverUri = new Uri(m_ServerURI);
103
104 string groupHost = serverUri.Host;
105
106 for (int i = 0 ; i < 256 ; i++)
107 {
108 string prefix = i.ToString("x2");
109 groupHost = assetConfig.GetString("AssetServerHost_"+prefix, groupHost);
110
111 m_UriMap[prefix] = groupHost;
112 //m_log.DebugFormat("[ASSET]: Using {0} for prefix {1}", groupHost, prefix);
113 }
114 }
115
116 private string MapServer(string id)
117 {
118 UriBuilder serverUri = new UriBuilder(m_ServerURI);
119
120 string prefix = id.Substring(0, 2).ToLower();
121
122 string host = m_UriMap[prefix];
123
124 serverUri.Host = host;
125
126 // m_log.DebugFormat("[ASSET]: Using {0} for host name for prefix {1}", host, prefix);
127
128 return serverUri.Uri.AbsoluteUri;
101 } 129 }
102 130
103 protected void retryCheck(object source, ElapsedEventArgs e) 131 protected void retryCheck(object source, ElapsedEventArgs e)
@@ -152,7 +180,7 @@ namespace OpenSim.Services.Connectors
152 180
153 public AssetBase Get(string id) 181 public AssetBase Get(string id)
154 { 182 {
155 string uri = m_ServerURI + "/assets/" + id; 183 string uri = MapServer(id) + "/assets/" + id;
156 184
157 AssetBase asset = null; 185 AssetBase asset = null;
158 if (m_Cache != null) 186 if (m_Cache != null)
@@ -187,7 +215,7 @@ namespace OpenSim.Services.Connectors
187 return fullAsset.Metadata; 215 return fullAsset.Metadata;
188 } 216 }
189 217
190 string uri = m_ServerURI + "/assets/" + id + "/metadata"; 218 string uri = MapServer(id) + "/assets/" + id + "/metadata";
191 219
192 AssetMetadata asset = SynchronousRestObjectRequester. 220 AssetMetadata asset = SynchronousRestObjectRequester.
193 MakeRequest<int, AssetMetadata>("GET", uri, 0); 221 MakeRequest<int, AssetMetadata>("GET", uri, 0);
@@ -204,7 +232,7 @@ namespace OpenSim.Services.Connectors
204 return fullAsset.Data; 232 return fullAsset.Data;
205 } 233 }
206 234
207 RestClient rc = new RestClient(m_ServerURI); 235 RestClient rc = new RestClient(MapServer(id));
208 rc.AddResourcePath("assets"); 236 rc.AddResourcePath("assets");
209 rc.AddResourcePath(id); 237 rc.AddResourcePath(id);
210 rc.AddResourcePath("data"); 238 rc.AddResourcePath("data");
@@ -229,7 +257,7 @@ namespace OpenSim.Services.Connectors
229 257
230 public bool Get(string id, Object sender, AssetRetrieved handler) 258 public bool Get(string id, Object sender, AssetRetrieved handler)
231 { 259 {
232 string uri = m_ServerURI + "/assets/" + id; 260 string uri = MapServer(id) + "/assets/" + id;
233 261
234 AssetBase asset = null; 262 AssetBase asset = null;
235 if (m_Cache != null) 263 if (m_Cache != null)
@@ -295,6 +323,31 @@ namespace OpenSim.Services.Connectors
295 323
296 public string Store(AssetBase asset) 324 public string Store(AssetBase asset)
297 { 325 {
326 // Have to assign the asset ID here. This isn't likely to
327 // trigger since current callers don't pass emtpy IDs
328 // We need the asset ID to route the request to the proper
329 // cluster member, so we can't have the server assign one.
330 if (asset.ID == string.Empty)
331 {
332 if (asset.FullID == UUID.Zero)
333 {
334 asset.FullID = UUID.Random();
335 }
336 asset.ID = asset.FullID.ToString();
337 }
338 else if (asset.FullID == UUID.Zero)
339 {
340 UUID uuid = UUID.Zero;
341 if (UUID.TryParse(asset.ID, out uuid))
342 {
343 asset.FullID = uuid;
344 }
345 else
346 {
347 asset.FullID = UUID.Random();
348 }
349 }
350
298 if (m_Cache != null) 351 if (m_Cache != null)
299 m_Cache.Cache(asset); 352 m_Cache.Cache(asset);
300 if (asset.Temporary || asset.Local) 353 if (asset.Temporary || asset.Local)
@@ -302,7 +355,7 @@ namespace OpenSim.Services.Connectors
302 return asset.ID; 355 return asset.ID;
303 } 356 }
304 357
305 string uri = m_ServerURI + "/assets/"; 358 string uri = MapServer(asset.FullID.ToString()) + "/assets/";
306 359
307 string newID = string.Empty; 360 string newID = string.Empty;
308 try 361 try
@@ -379,7 +432,7 @@ namespace OpenSim.Services.Connectors
379 } 432 }
380 asset.Data = data; 433 asset.Data = data;
381 434
382 string uri = m_ServerURI + "/assets/" + id; 435 string uri = MapServer(id) + "/assets/" + id;
383 436
384 if (SynchronousRestObjectRequester. 437 if (SynchronousRestObjectRequester.
385 MakeRequest<AssetBase, bool>("POST", uri, asset)) 438 MakeRequest<AssetBase, bool>("POST", uri, asset))
@@ -394,7 +447,7 @@ namespace OpenSim.Services.Connectors
394 447
395 public bool Delete(string id) 448 public bool Delete(string id)
396 { 449 {
397 string uri = m_ServerURI + "/assets/" + id; 450 string uri = MapServer(id) + "/assets/" + id;
398 451
399 if (SynchronousRestObjectRequester. 452 if (SynchronousRestObjectRequester.
400 MakeRequest<int, bool>("DELETE", uri, 0)) 453 MakeRequest<int, bool>("DELETE", uri, 0))