예제 #1
0
        public virtual bool[] AssetsExist(string[] ids)
        {
            int numHG = 0;

            foreach (string id in ids)
            {
                if (IsHG(id))
                {
                    ++numHG;
                }
            }

            if (numHG == 0)
            {
                return(m_GridService.AssetsExist(ids));
            }
            else if (numHG == ids.Length)
            {
                return(m_HGService.AssetsExist(ids));
            }
            else
            {
                throw new Exception("[HG ASSET CONNECTOR]: AssetsExist: all the assets must be either local or foreign");
            }
        }
예제 #2
0
        public bool[] AssetsExist(string[] ids)
        {
            if (checkForError())
            {
                return(new bool[0]);
            }

            try
            {
                Boolean   foundAllAssets = true;
                Boolean[] result         = m_assetService.AssetsExist(ids);

                foreach (bool thisBool in result)
                {
                    if (thisBool == false)
                    {
                        foundAllAssets = false;
                    }
                }

                if (foundAllAssets == true)
                {
                    return(result);
                }

                List <Boolean[]> results = new List <Boolean[]>();
                foreach (AssetServerProxy service in m_extraAssetServers)
                {
                    if (service != null)
                    {
                        results.Add(service.AssetsExist(ids));
                    }
                }

                for (int i = 0; i < ids.Length; i++)
                {
                    if (result[i] != true)
                    {
                        foreach (Boolean[] resultset in results)
                        {
                            if (resultset[i] == true)
                            {
                                result[i] = true;
                            }
                        }
                    }
                }

                return(result);
            }
            catch
            {
                m_errorCount++;
                m_lastError = Tools.getUnixTime();
                m_log.Error("[AssetServerProxy]: Add remote asset server to temporary blacklist: " + m_assetServiceURL);
            }

            return(null);
        }
예제 #3
0
        public virtual bool[] AssetsExist(string[] ids)
        {
            // This method is a bit complicated because it works even if the assets belong to different
            // servers; that requires sending separate requests to each server.

            // Group the assets by the server they belong to

            var url2assets = new Dictionary <string, List <AssetAndIndex> >();

            for (int i = 0; i < ids.Length; i++)
            {
                string url     = string.Empty;
                string assetID = string.Empty;

                if (Util.ParseForeignAssetID(ids[i], out url, out assetID))
                {
                    if (!url2assets.ContainsKey(url))
                    {
                        url2assets.Add(url, new List <AssetAndIndex>());
                    }
                    url2assets[url].Add(new AssetAndIndex(UUID.Parse(assetID), i));
                }
            }

            // Query each of the servers in turn

            bool[] exist = new bool[ids.Length];

            foreach (string url in url2assets.Keys)
            {
                IAssetService connector = GetConnector(url);
                lock (EndPointLock(connector))
                {
                    List <AssetAndIndex> curAssets = url2assets[url];
                    string[]             assetIDs  = curAssets.ConvertAll(a => a.assetID.ToString()).ToArray();
                    bool[] curExist = connector.AssetsExist(assetIDs);

                    int i = 0;
                    foreach (AssetAndIndex ai in curAssets)
                    {
                        exist[ai.index] = curExist[i];
                        ++i;
                    }
                }
            }

            return(exist);
        }
        protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            XmlSerializer xs;

            string[] ids;
            try
            {
                xs  = new XmlSerializer(typeof(string[]));
                ids = (string[])xs.Deserialize(request);
            }
            catch (Exception)
            {
                httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
                return(null);
            }

            bool[] exist = m_AssetService.AssetsExist(ids);

            xs = new XmlSerializer(typeof(bool[]));
            return(ServerUtils.SerializeResult(xs, exist));
        }
예제 #5
0
        public bool[] AssetsExist(string[] ids)
        {
            int numHG = 0;

            foreach (string id in ids)
            {
                if (IsHG(id))
                {
                    ++numHG;
                }
            }
            if (numHG == 0)
            {
                return(m_localConnector.AssetsExist(ids));
            }
            else if (m_HGConnector != null)
            {
                return(m_HGConnector.AssetsExist(ids));
            }
            return(null);
        }
예제 #6
0
 public bool[] AssetsExist(string[] ids)
 {
     return(m_AssetService.AssetsExist(ids));
 }
예제 #7
0
 public bool[] AssetsExist(string[] ids)
 {
     return(m_assetConnector.AssetsExist(ids));
 }