From 363a99593d69c55f084f3438c335d38262beddf8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 6 Oct 2011 15:39:21 +0200 Subject: [PATCH 1/2] Change the asset connector to allow connection to different asset servers depending on the first two digits of the asset id. --- .../Connectors/Asset/AssetServiceConnector.cs | 68 +++++++++++++++++-- 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index 565e4f2895..7db2a8119d 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs @@ -51,6 +51,7 @@ namespace OpenSim.Services.Connectors private int m_retryCounter; private Dictionary> m_retryQueue = new Dictionary>(); private Timer m_retryTimer; + private Dictionary m_UriMap = new Dictionary(); public AssetServicesConnector() { } @@ -91,6 +92,34 @@ namespace OpenSim.Services.Connectors m_retryTimer = new Timer(); m_retryTimer.Elapsed += new ElapsedEventHandler(retryCheck); m_retryTimer.Interval = 60000; + + Uri serverUri = new Uri(m_ServerURI); + + string groupHost = serverUri.Host; + + for (int i = 0 ; i < 256 ; i++) + { + string prefix = i.ToString("x2"); + groupHost = assetConfig.GetString("AssetServerHost_"+prefix, groupHost); + + m_UriMap[prefix] = groupHost; + //m_log.DebugFormat("[ASSET]: Using {0} for prefix {1}", groupHost, prefix); + } + } + + private string MapServer(string id) + { + UriBuilder serverUri = new UriBuilder(m_ServerURI); + + string prefix = id.Substring(0, 2).ToLower(); + + string host = m_UriMap[prefix]; + + serverUri.Host = host; + + // m_log.DebugFormat("[ASSET]: Using {0} for host name for prefix {1}", host, prefix); + + return serverUri.Uri.AbsoluteUri; } protected void retryCheck(object source, ElapsedEventArgs e) @@ -145,7 +174,7 @@ namespace OpenSim.Services.Connectors public AssetBase Get(string id) { - string uri = m_ServerURI + "/assets/" + id; + string uri = MapServer(id) + "/assets/" + id; AssetBase asset = null; if (m_Cache != null) @@ -180,7 +209,7 @@ namespace OpenSim.Services.Connectors return fullAsset.Metadata; } - string uri = m_ServerURI + "/assets/" + id + "/metadata"; + string uri = MapServer(id) + "/assets/" + id + "/metadata"; AssetMetadata asset = SynchronousRestObjectRequester. MakeRequest("GET", uri, 0); @@ -197,7 +226,7 @@ namespace OpenSim.Services.Connectors return fullAsset.Data; } - RestClient rc = new RestClient(m_ServerURI); + RestClient rc = new RestClient(MapServer(id)); rc.AddResourcePath("assets"); rc.AddResourcePath(id); rc.AddResourcePath("data"); @@ -222,7 +251,7 @@ namespace OpenSim.Services.Connectors public bool Get(string id, Object sender, AssetRetrieved handler) { - string uri = m_ServerURI + "/assets/" + id; + string uri = MapServer(id) + "/assets/" + id; AssetBase asset = null; if (m_Cache != null) @@ -255,6 +284,31 @@ namespace OpenSim.Services.Connectors public string Store(AssetBase asset) { + // Have to assign the asset ID here. This isn't likely to + // trigger since current callers don't pass emtpy IDs + // We need the asset ID to route the request to the proper + // cluster member, so we can't have the server assign one. + if (asset.ID == string.Empty) + { + if (asset.FullID == UUID.Zero) + { + asset.FullID = UUID.Random(); + } + asset.ID = asset.FullID.ToString(); + } + else if (asset.FullID == UUID.Zero) + { + UUID uuid = UUID.Zero; + if (UUID.TryParse(asset.ID, out uuid)) + { + asset.FullID = uuid; + } + else + { + asset.FullID = UUID.Random(); + } + } + if (m_Cache != null) m_Cache.Cache(asset); if (asset.Temporary || asset.Local) @@ -262,7 +316,7 @@ namespace OpenSim.Services.Connectors return asset.ID; } - string uri = m_ServerURI + "/assets/"; + string uri = MapServer(asset.FullID.ToString()) + "/assets/"; string newID = string.Empty; try @@ -339,7 +393,7 @@ namespace OpenSim.Services.Connectors } asset.Data = data; - string uri = m_ServerURI + "/assets/" + id; + string uri = MapServer(id) + "/assets/" + id; if (SynchronousRestObjectRequester. MakeRequest("POST", uri, asset)) @@ -354,7 +408,7 @@ namespace OpenSim.Services.Connectors public bool Delete(string id) { - string uri = m_ServerURI + "/assets/" + id; + string uri = MapServer(id) + "/assets/" + id; if (SynchronousRestObjectRequester. MakeRequest("DELETE", uri, 0)) From 300d357573a272ef0042ebbe0912ab88de958f65 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 6 Oct 2011 17:55:20 +0200 Subject: [PATCH 2/2] Fix physics proxy position when linking and rotating the root prim only --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 6c476458c0..58f25865e4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2397,6 +2397,7 @@ namespace OpenSim.Region.Framework.Scenes Quaternion oldRootRotation = linkPart.RotationOffset; linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; + linkPart.ParentID = m_rootPart.LocalId; linkPart.GroupPosition = AbsolutePosition; Vector3 axPos = linkPart.OffsetPosition; @@ -3431,14 +3432,17 @@ namespace OpenSim.Region.Framework.Scenes if (prim.UUID != m_rootPart.UUID) { prim.IgnoreUndoUpdate = true; + + Quaternion NewRot = oldParentRot * prim.RotationOffset; + NewRot = Quaternion.Inverse(axRot) * NewRot; + prim.RotationOffset = NewRot; + Vector3 axPos = prim.OffsetPosition; axPos *= oldParentRot; axPos *= Quaternion.Inverse(axRot); prim.OffsetPosition = axPos; - prim.RotationOffset *= Quaternion.Inverse(prim.GetWorldRotation()) * (oldParentRot * prim.RotationOffset); - prim.IgnoreUndoUpdate = false; } }