Exemplo n.º 1
0
        /// <summary>
        /// Called back by the asset cache when it has the asset
        /// </summary>
        /// <param name="assetID"></param>
        /// <param name="asset"></param>
        public void AssetRequestCallback(UUID assetID, AssetBase asset)
        {
            //m_log.DebugFormat("[ARCHIVER]: Received callback for asset {0}", assetID);

            if (asset != null)
            {
                // Make sure that we don't run out of memory by hogging assets in the cache
                m_assetCache.ExpireAsset(assetID);

                m_foundAssetUuids.Add(assetID);
                m_assetsArchiver.WriteAsset(asset);
            }
            else
            {
                m_notFoundAssetUuids.Add(assetID);
            }

            if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count == m_repliesRequired)
            {
                m_log.DebugFormat(
                    "[ARCHIVER]: Successfully received {0} assets and notification of {1} missing assets",
                    m_foundAssetUuids.Count, m_notFoundAssetUuids.Count);

                // We want to stop using the asset cache thread asap
                // as we now need to do the work of producing the rest of the archive
                Thread newThread = new Thread(PerformAssetsRequestCallback);
                newThread.Name = "OpenSimulator archiving thread post assets receipt";
                newThread.Start();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called back by the asset cache when it has the asset
        /// </summary>
        /// <param name="assetID"></param>
        /// <param name="asset"></param>
        public void AssetRequestCallback(string id, object sender, AssetBase asset)
        {
            Culture.SetCurrentCulture();

            try
            {
                lock (this)
                {
                    //m_log.DebugFormat("[ARCHIVER]: Received callback for asset {0}", id);

                    m_requestCallbackTimer.Stop();

                    if ((m_requestState == RequestState.Aborted) || (m_requestState == RequestState.Completed))
                    {
                        m_log.WarnFormat(
                            "[ARCHIVER]: Received information about asset {0} while in state {1}.  Ignoring.",
                            id, m_requestState);

                        return;
                    }

                    if (asset != null)
                    {
//                        m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id);
                        m_foundAssetUuids.Add(asset.FullID);

                        m_assetsArchiver.WriteAsset(PostProcess(asset));
                    }
                    else
                    {
//                        m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as not found", id);
                        m_notFoundAssetUuids.Add(new UUID(id));
                    }

                    if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count >= m_repliesRequired)
                    {
                        m_requestState = RequestState.Completed;

                        m_log.DebugFormat(
                            "[ARCHIVER]: Successfully added {0} assets ({1} assets not found but these may be expected invalid references)",
                            m_foundAssetUuids.Count, m_notFoundAssetUuids.Count);

                        // We want to stop using the asset cache thread asap
                        // as we now need to do the work of producing the rest of the archive
                        WorkManager.RunInThread(PerformAssetsRequestCallback, false, "Archive Assets Request Callback");
                    }
                    else
                    {
                        m_requestCallbackTimer.Start();
                    }
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[ARCHIVER]: AssetRequestCallback failed with {0}", e);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called back by the asset cache when it has the asset
        /// </summary>
        /// <param name="assetID"></param>
        /// <param name="asset"></param>
        public void AssetRequestCallback(string id, object sender, AssetBase asset)
        {
            try
            {
                lock (this)
                {
                    //m_log.DebugFormat("[ARCHIVER]: Received callback for asset {0}", id);

                    m_requestCallbackTimer.Stop();

                    if (m_requestState == RequestState.Aborted)
                    {
                        m_log.WarnFormat(
                            "[ARCHIVER]: Received information about asset {0} after archive save abortion.  Ignoring.",
                            id);

                        return;
                    }

                    if (asset != null)
                    {
//                        m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as found", id);
                        m_foundAssetUuids.Add(asset.FullID);
                        m_assetsArchiver.WriteAsset(asset);
                    }
                    else
                    {
//                        m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as not found", id);
                        m_notFoundAssetUuids.Add(new UUID(id));
                    }

                    if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count == m_repliesRequired)
                    {
                        m_requestState = RequestState.Completed;

                        m_log.DebugFormat(
                            "[ARCHIVER]: Successfully added {0} assets ({1} assets notified missing)",
                            m_foundAssetUuids.Count, m_notFoundAssetUuids.Count);

                        // We want to stop using the asset cache thread asap
                        // as we now need to do the work of producing the rest of the archive
                        Thread newThread = new Thread(PerformAssetsRequestCallback);
                        newThread.Name = "OpenSimulator archiving thread post assets receipt";
                        newThread.Start();
                    }
                    else
                    {
                        m_requestCallbackTimer.Start();
                    }
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[ARCHIVER]: AssetRequestCallback failed with {0}", e);
            }
        }
Exemplo n.º 4
0
        protected internal void Execute()
        {
            Culture.SetCurrentCulture();
            // We can stop here if there are no assets to fetch
            if (m_repliesRequired == 0)
            {
                PerformAssetsRequestCallback(false);
                return;
            }

            m_timeOutTimer           = new System.Timers.Timer(60000);
            m_timeOutTimer.AutoReset = false;
            m_timeOutTimer.Elapsed  += OnTimeout;
            m_timeout = false;
            int gccontrol = 0;

            foreach (KeyValuePair <UUID, sbyte> kvp in m_uuids)
            {
                string thiskey = kvp.Key.ToString();
                try
                {
                    m_timeOutTimer.Enabled = true;
                    AssetBase asset = m_assetService.Get(thiskey);
                    if (m_timeout)
                    {
                        break;
                    }

                    m_timeOutTimer.Enabled = false;

                    if (asset == null)
                    {
                        m_notFoundAssetUuids.Add(new UUID(thiskey));
                        continue;
                    }

                    sbyte assetType = kvp.Value;
                    if (asset != null && assetType == (sbyte)AssetType.Unknown)
                    {
                        m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", thiskey, SLUtil.AssetTypeFromCode(assetType));
                        asset.Type = assetType;
                    }

                    m_foundAssetUuids.Add(asset.FullID);
                    m_assetsArchiver.WriteAsset(PostProcess(asset));
                    if (++gccontrol > 10000)
                    {
                        gccontrol = 0;
                        GC.Collect();
                    }
                }

                catch (Exception e)
                {
                    m_log.ErrorFormat("[ARCHIVER]: Execute failed with {0}", e);
                }
            }

            m_timeOutTimer.Dispose();
            int totalerrors = m_notFoundAssetUuids.Count + m_previousErrorsCount;

            if (m_timeout)
            {
                m_log.DebugFormat("[ARCHIVER]: Aborted because AssetService request timeout. Successfully added {0} assets", m_foundAssetUuids.Count);
            }
            else if (totalerrors == 0)
            {
                m_log.DebugFormat("[ARCHIVER]: Successfully added all {0} assets", m_foundAssetUuids.Count);
            }
            else
            {
                m_log.DebugFormat("[ARCHIVER]: Successfully added {0} assets ({1} of total possible assets requested were not found, were damaged or were not assets)",
                                  m_foundAssetUuids.Count, totalerrors);
            }

            GC.Collect();
            PerformAssetsRequestCallback(m_timeout);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called back by the asset cache when it has the asset
        /// </summary>
        /// <param name="assetID"></param>
        /// <param name="asset"></param>
        public void AssetRequestCallback(string id, object sender, AssetBase asset)
        {
            Culture.SetCurrentCulture();

            try
            {
                lock (this)
                {
                    //m_log.DebugFormat("[ARCHIVER]: Received callback for asset {0}", id);

                    m_requestCallbackTimer.Stop();

                    if (m_requestState == RequestState.Aborted)
                    {
                        m_log.WarnFormat(
                            "[ARCHIVER]: Received information about asset {0} after archive save abortion.  Ignoring.",
                            id);

                        return;
                    }

                    if (asset != null)
                    {
                        if (m_options.ContainsKey("verbose"))
                        {
                            m_log.InfoFormat("[ARCHIVER]: Writing asset {0}", id);
                        }

                        m_foundAssetUuids.Add(asset.FullID);

                        m_assetsArchiver.WriteAsset(PostProcess(asset));
                    }
                    else
                    {
                        if (m_options.ContainsKey("verbose"))
                        {
                            m_log.InfoFormat("[ARCHIVER]: Recording asset {0} as not found", id);
                        }

                        m_notFoundAssetUuids.Add(new UUID(id));
                    }

                    if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count == m_repliesRequired)
                    {
                        m_requestState = RequestState.Completed;

                        m_log.DebugFormat(
                            "[ARCHIVER]: Successfully added {0} assets ({1} assets notified missing)",
                            m_foundAssetUuids.Count, m_notFoundAssetUuids.Count);

                        // We want to stop using the asset cache thread asap
                        // as we now need to do the work of producing the rest of the archive
                        Util.FireAndForget(PerformAssetsRequestCallback);
                    }
                    else
                    {
                        m_requestCallbackTimer.Start();
                    }
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[ARCHIVER]: AssetRequestCallback failed with {0}", e);
            }
        }