public void Post(UUID assetID, UUID ownerID, string userAssetURL) { // Post the item from the local AssetCache onto the remote asset server // and place an entry in m_assetMap m_log.Debug("[HG ASSET MAPPER]: Posting object " + assetID + " to asset server " + userAssetURL); AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); if (asset != null) { Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty); uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids, m_scene); foreach (UUID uuid in ids.Keys) { asset = m_scene.AssetService.Get(uuid.ToString()); if (asset == null) m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid); else PostAsset(userAssetURL, asset); } // maybe all pieces got there... m_log.DebugFormat("[HG ASSET MAPPER]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL); } else m_log.DebugFormat("[HG ASSET MAPPER]: Something wrong with asset {0}, it could not be found", assetID); }
public override bool HandleIncomingSceneObject(SceneObjectGroup so, Vector3 newPosition) { UUID OwnerID = so.OwnerID; if (Scene.RegionInfo.EstateSettings.IsBanned(OwnerID)) { m_log.DebugFormat( "[HG TRANSFER MODULE]: Denied prim crossing of {0} {1} into {2} for banned avatar {3}", so.Name, so.UUID, Scene.Name, so.OwnerID); return(false); } // FIXME: We must make it so that we can use SOG.IsAttachment here. At the moment it is always null! if (!so.IsAttachmentCheckFull()) { return(base.HandleIncomingSceneObject(so, newPosition)); } // Equally, we can't use so.AttachedAvatar here. if (OwnerID == UUID.Zero || Scene.UserManagementModule.IsLocalGridUser(OwnerID)) { return(base.HandleIncomingSceneObject(so, newPosition)); } // foreign user AgentCircuitData aCircuit = Scene.AuthenticateHandler.GetAgentCircuitData(OwnerID); if (aCircuit != null) { if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) == 0) { // We have already pulled the necessary attachments from the source grid. base.HandleIncomingSceneObject(so, newPosition); } else { if (aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) { SceneObjectGroup defso = so; m_incomingSceneObjectEngine.QueueJob( string.Format("HG UUID Gather for attachment {0} for {1}", defso.Name, aCircuit.Name), () => { string url = aCircuit.ServiceURLs["AssetServerURI"].ToString(); // m_log.DebugFormat( // "[HG ENTITY TRANSFER MODULE]: Incoming attachment {0} for HG user {1} with asset service {2}", // so.Name, so.AttachedAvatar, url); IDictionary <UUID, sbyte> ids = new Dictionary <UUID, sbyte>(); HGUuidGatherer uuidGatherer = new HGUuidGatherer(Scene.AssetService, url, ids); uuidGatherer.AddForInspection(defso); while (!uuidGatherer.Complete) { int tickStart = Util.EnvironmentTickCount(); uuidGatherer.GatherNext(); // m_log.DebugFormat( // "[HG ENTITY TRANSFER]: Gathered attachment asset uuid {0} for object {1} for HG user {2} took {3} ms with asset service {4}", // nextUuid, so.Name, so.OwnerID, Util.EnvironmentTickCountSubtract(tickStart), url); int ticksElapsed = Util.EnvironmentTickCountSubtract(tickStart); if (ticksElapsed > 30000) { m_log.WarnFormat( "[HG ENTITY TRANSFER]: Removing incoming scene object jobs for HG user {0} as gather of {1} from {2} took {3} ms to respond (> {4} ms)", so.OwnerID, so.Name, url, ticksElapsed, 30000); RemoveIncomingSceneObjectJobs(OwnerID.ToString()); return; } } // m_log.DebugFormat( // "[HG ENTITY TRANSFER]: Fetching {0} assets for attachment {1} for HG user {2} with asset service {3}", // ids.Count, so.Name, so.OwnerID, url); foreach (UUID id in ids.Keys) { int tickStart = Util.EnvironmentTickCount(); uuidGatherer.FetchAsset(id); int ticksElapsed = Util.EnvironmentTickCountSubtract(tickStart); if (ticksElapsed > 30000) { m_log.WarnFormat( "[HG ENTITY TRANSFER]: Removing incoming scene object jobs for HG user {0} as fetch of {1} from {2} took {3} ms to respond (> {4} ms)", so.OwnerID, id, url, ticksElapsed, 30000); RemoveIncomingSceneObjectJobs(OwnerID.ToString()); return; } } base.HandleIncomingSceneObject(defso, newPosition); defso = null; aCircuit = null; uuidGatherer = null; // m_log.DebugFormat( // "[HG ENTITY TRANSFER MODULE]: Completed incoming attachment {0} for HG user {1} with asset server {2}", // so.Name, so.OwnerID, url); }, OwnerID.ToString()); } } } return(true); }
// private void Dump(Dictionary<UUID, bool> lst) // { // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); // foreach (KeyValuePair<UUID, bool> kvp in lst) // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")"); // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); // } #endregion #region Public interface public void Get(UUID assetID, UUID ownerID, string userAssetURL) { // Get the item from the remote asset server onto the local AssetCache // and place an entry in m_assetMap m_log.Debug("[HG ASSET MAPPER]: Fetching object " + assetID + " from asset server " + userAssetURL); AssetBase asset = FetchAsset(userAssetURL, assetID); if (asset != null) { // OK, now fetch the inside. Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL); uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids, m_scene); if (ids.ContainsKey(assetID)) ids.Remove(assetID); foreach (UUID uuid in ids.Keys) FetchAsset(userAssetURL, uuid); m_log.DebugFormat("[HG ASSET MAPPER]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL); } else m_log.Warn("[HG ASSET MAPPER]: Could not fetch asset from remote asset server " + userAssetURL); }
public void Post(UUID assetID, UUID ownerID, string userAssetURL) { m_log.DebugFormat("[HG ASSET MAPPER]: Starting to send asset {0} with children to asset server {1}", assetID, userAssetURL); // Find all the embedded assets AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); if (asset == null) { m_log.DebugFormat("[HG ASSET MAPPER]: Something wrong with asset {0}, it could not be found", assetID); return; } HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); uuidGatherer.AddForInspection(asset.FullID); uuidGatherer.GatherAll(); // Check which assets already exist in the destination server string url = userAssetURL; if (!url.EndsWith("/") && !url.EndsWith("=")) url = url + "/"; string[] remoteAssetIDs = new string[uuidGatherer.GatheredUuids.Count]; int i = 0; foreach (UUID id in uuidGatherer.GatheredUuids.Keys) remoteAssetIDs[i++] = url + id.ToString(); bool[] exist = m_scene.AssetService.AssetsExist(remoteAssetIDs); var existSet = new HashSet<string>(); i = 0; foreach (UUID id in uuidGatherer.GatheredUuids.Keys) { if (exist[i]) existSet.Add(id.ToString()); ++i; } // Send only those assets which don't already exist in the destination server bool success = true; foreach (UUID uuid in uuidGatherer.GatheredUuids.Keys) { if (!existSet.Contains(uuid.ToString())) { asset = m_scene.AssetService.Get(uuid.ToString()); if (asset == null) { m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid); } else { try { success &= PostAsset(userAssetURL, asset); } catch (Exception e) { m_log.Error( string.Format( "[HG ASSET MAPPER]: Failed to post asset {0} (type {1}, length {2}) referenced from {3} to {4} with exception ", asset.ID, asset.Type, asset.Data.Length, assetID, userAssetURL), e); // For debugging purposes for now we will continue to throw the exception up the stack as was already happening. However, after // debugging we may want to simply report the failure if we can tell this is due to a failure // with a particular asset and not a destination network failure where all asset posts will fail (and // generate large amounts of log spam). throw e; } } } else { m_log.DebugFormat( "[HG ASSET MAPPER]: Didn't post asset {0} referenced from {1} because it already exists in asset server {2}", uuid, assetID, userAssetURL); } } if (!success) m_log.DebugFormat("[HG ASSET MAPPER]: Problems sending asset {0} with children to asset server {1}", assetID, userAssetURL); else m_log.DebugFormat("[HG ASSET MAPPER]: Successfully sent asset {0} with children to asset server {1}", assetID, userAssetURL); }
// TODO: unused // private void Dump(Dictionary<UUID, bool> lst) // { // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); // foreach (KeyValuePair<UUID, bool> kvp in lst) // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")"); // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); // } #endregion #region Public interface public void Get(UUID assetID, UUID ownerID, string userAssetURL) { // Get the item from the remote asset server onto the local AssetService AssetMetadata meta = FetchMetadata(userAssetURL, assetID); if (meta == null) return; // The act of gathering UUIDs downloads some assets from the remote server // but not all... HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL); uuidGatherer.AddForInspection(assetID); uuidGatherer.GatherAll(); m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", uuidGatherer.GatheredUuids.Count); bool success = true; foreach (UUID uuid in uuidGatherer.GatheredUuids.Keys) if (FetchAsset(userAssetURL, uuid) == null) success = false; // maybe all pieces got here... if (!success) m_log.DebugFormat("[HG ASSET MAPPER]: Problems getting item {0} from asset server {1}", assetID, userAssetURL); else m_log.DebugFormat("[HG ASSET MAPPER]: Successfully got item {0} from asset server {1}", assetID, userAssetURL); }
public void Post(UUID assetID, UUID ownerID, string userAssetURL) { m_log.DebugFormat("[HG ASSET MAPPER]: Starting to send asset {0} with children to asset server {1}", assetID, userAssetURL); // Find all the embedded assets AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); if (asset == null) { m_log.DebugFormat("[HG ASSET MAPPER]: Something wrong with asset {0}, it could not be found", assetID); return; } Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); uuidGatherer.GatherAssetUuids(asset.FullID, asset.Type, ids); // Check which assets already exist in the destination server string url = userAssetURL; if (!url.EndsWith("/") && !url.EndsWith("=")) url = url + "/"; string[] remoteAssetIDs = new string[ids.Count]; int i = 0; foreach (UUID id in ids.Keys) remoteAssetIDs[i++] = url + id.ToString(); bool[] exist = m_scene.AssetService.AssetsExist(remoteAssetIDs); var existSet = new HashSet<string>(); i = 0; foreach (UUID id in ids.Keys) { if (exist[i]) existSet.Add(id.ToString()); ++i; } // Send only those assets which don't already exist in the destination server bool success = true; foreach (UUID uuid in ids.Keys) { if (!existSet.Contains(uuid.ToString())) { asset = m_scene.AssetService.Get(uuid.ToString()); if (asset == null) m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid); else success &= PostAsset(userAssetURL, asset); } else m_log.DebugFormat("[HG ASSET MAPPER]: Didn't post asset {0} because it already exists in asset server {1}", uuid, userAssetURL); } if (!success) m_log.DebugFormat("[HG ASSET MAPPER]: Problems sending asset {0} with children to asset server {1}", assetID, userAssetURL); else m_log.DebugFormat("[HG ASSET MAPPER]: Successfully sent asset {0} with children to asset server {1}", assetID, userAssetURL); }
// TODO: unused // private void Dump(Dictionary<UUID, bool> lst) // { // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); // foreach (KeyValuePair<UUID, bool> kvp in lst) // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")"); // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); // } #endregion #region Public interface public void Get(UUID assetID, UUID ownerID, string userAssetURL) { // Get the item from the remote asset server onto the local AssetService AssetMetadata meta = FetchMetadata(userAssetURL, assetID); if (meta == null) return; // The act of gathering UUIDs downloads the assets from the remote server Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL); uuidGatherer.GatherAssetUuids(assetID, (AssetType)meta.Type, ids); }