Пример #1
0
        private IAssetService GetConnector(string url)
        {
            IAssetService connector = null;

            lock (m_connectors)
            {
                if (m_connectors.ContainsKey(url))
                {
                    connector = m_connectors[url];
                }
                else
                {
                    // Still not as flexible as I would like this to be,
                    // but good enough for now
                    string connectorType = new HeloServicesConnector(url).Helo();
                    m_log.DebugFormat("[HG ASSET SERVICE]: HELO returned {0}", connectorType);
                    if (connectorType == "opensim-simian")
                    {
                        connector = new SimianAssetServiceConnector(url);
                    }
                    else
                    {
                        connector = new AssetServicesConnector(url);
                    }

                    m_connectors.Add(url, connector);
                }
            }
            return(connector);
        }
Пример #2
0
        private IAssetService GetConnector(string url)
        {
            IAssetService connector = null;

            m_connectorsRwLock.AcquireReaderLock(-1);
            try
            {
                if (m_connectors.ContainsKey(url))
                {
                    connector = m_connectors[url];
                }
                else
                {
                    LockCookie lc = m_connectorsRwLock.UpgradeToWriterLock(-1);
                    try
                    {
                        /* recheck since other thread may have created it */
                        if (m_connectors.ContainsKey(url))
                        {
                            connector = m_connectors[url];
                        }
                        else
                        {
                            // Still not as flexible as I would like this to be,
                            // but good enough for now
                            string connectorType = new HeloServicesConnector(url).Helo();
                            m_log.DebugFormat("[HG ASSET SERVICE]: HELO returned {0}", connectorType);
                            if (connectorType == "opensim-simian")
                            {
                                connector = new SimianAssetServiceConnector(url);
                            }
                            else
                            {
                                connector = new AssetServicesConnector(url);
                            }

                            m_connectors.Add(url, connector);
                        }
                    }
                    finally
                    {
                        m_connectorsRwLock.DowngradeFromWriterLock(ref lc);
                    }
                }
            }
            finally
            {
                m_connectorsRwLock.ReleaseReaderLock();
            }
            return(connector);
        }
Пример #3
0
        public static void Main(string[] args)
        {
            ConsoleAppender consoleAppender = new ConsoleAppender();
            consoleAppender.Layout =
                new PatternLayout("[%thread] - %message%newline");
            log4net.Config.BasicConfigurator.Configure(consoleAppender);

            string serverURI = "http://127.0.0.1:8003";
            if (args.Length > 1)
                serverURI = args[1];
            int max1, max2;
            ThreadPool.GetMaxThreads(out max1, out max2);
            m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} max threads = {1} - {2}", serverURI, max1, max2);
            ThreadPool.GetMinThreads(out max1, out max2);
            m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} min threads = {1} - {2}", serverURI, max1, max2);

            if (!ThreadPool.SetMinThreads(1, 1))
                m_log.WarnFormat("[ASSET CLIENT]: Failed to set min threads");

            if (!ThreadPool.SetMaxThreads(10, 3))
                m_log.WarnFormat("[ASSET CLIENT]: Failed to set max threads");

            ThreadPool.GetMaxThreads(out max1, out max2);
            m_log.InfoFormat("[ASSET CLIENT]: Post set max threads = {1} - {2}", serverURI, max1, max2);
            ThreadPool.GetMinThreads(out max1, out max2);
            m_log.InfoFormat("[ASSET CLIENT]: Post set min threads = {1} - {2}", serverURI, max1, max2);

            ServicePointManager.DefaultConnectionLimit = 12;

            AssetServicesConnector m_Connector = new AssetServicesConnector(serverURI);
            m_Connector.MaxAssetRequestConcurrency = 30;

            for (int i = 0; i < NREQS; i++)
            {
                UUID uuid = UUID.Random();
                m_Connector.Get(uuid.ToString(), null, ResponseReceived);
                m_log.InfoFormat("[ASSET CLIENT]: [{0}] requested asset {1}", i, uuid);
            }

            for (int i = 0; i < 500; i++)
            {
                var x = i;
                ThreadPool.QueueUserWorkItem(delegate
                {
                    Dummy(x);
                });
            }

            Thread.Sleep(30 * 1000);
            m_log.InfoFormat("[ASSET CLIENT]: Received responses {0}", m_NReceived);
        }
Пример #4
0
        private AssetServicesConnector GetConnector(string url)
        {
            AssetServicesConnector connector = null;

            lock (m_connectors)
            {
                if (!m_connectors.TryGetValue(url, 60000, out connector))
                {
                    connector = new AssetServicesConnector(url);
                    m_connectors.Add(url, connector);
                }
            }
            return(connector);
        }
Пример #5
0
        public string Store(AssetBase asset)
        {
            string url     = string.Empty;
            string assetID = string.Empty;

            if (Util.ParseForeignAssetID(asset.ID, out url, out assetID) > 0)
            {
                AssetServicesConnector connector = GetConnector(url);
                // Restore the assetID to a simple UUID
                asset.ID = assetID;
                lock ((connector.ConnectorLock))
                    return(connector.Store(asset));
            }

            return(string.Empty);
        }
Пример #6
0
        public virtual bool[] AssetsExist(string[] ids)
        {
            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) > 0)
                {
                    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)
            {
                AssetServicesConnector connector = GetConnector(url);
                lock (connector.ConnectorLock)
                {
                    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);
        }
Пример #7
0
        public void Initialize(IConfigSource config, IRegistryCore registry)
        {
            IConfig handlerConfig = config.Configs["Handlers"];
            if (handlerConfig.GetString("AssetHandler", "") != Name)
                return;
            
            string localAssetHandler = handlerConfig.GetString("LocalAssetHandler", "AssetService");
            List<IAssetService> services = Aurora.Framework.AuroraModuleLoader.PickupModules<IAssetService>();
            foreach(IAssetService s in services)
                if(s.GetType().Name == localAssetHandler)
                    m_localService = s;

            if(m_localService == null)
                m_localService = new AssetService();
            m_localService.Configure(config, registry);
            m_remoteService = new AssetServicesConnector();
            m_remoteService.Initialize(config, registry);
            registry.RegisterModuleInterface<IAssetService>(this);
            m_registry = registry;
        }
Пример #8
0
        private IAssetService GetConnector(string url)
        {
            IAssetService connector = null;

            lock (m_connectors)
            {
                if (m_connectors.ContainsKey(url))
                {
                    connector = m_connectors[url];
                }
                else
                {
                    // Still not as flexible as I would like this to be,
                    // but good enough for now
                    connector = new AssetServicesConnector(url);
                    m_connectors.Add(url, connector);
                }
            }
            return(connector);
        }
Пример #9
0
        private IAssetService GetConnector(string url)
        {
            AssetServicesConnector connector = null;

            lock (m_connectors)
            {
                if (m_connectors.ContainsKey(url))
                {
                    connector = m_connectors[url];
                }
                else
                {
                    // We're instantiating this class explicitly, but this won't
                    // work in general, because the remote grid may be running
                    // an asset server that has a different protocol.
                    // Eventually we will want a piece of protocol asking
                    // the remote server about its kind. Definitely cool thing to do!
                    connector = new AssetServicesConnector(url);
                    m_connectors.Add(url, connector);
                }
            }
            return(connector);
        }
Пример #10
0
        private IAssetService GetConnector(string url)
        {
            IAssetService connector = null;
            lock (m_connectors)
            {
                if (m_connectors.ContainsKey(url))
                {
                    connector = m_connectors[url];
                }
                else
                {
                    // Still not as flexible as I would like this to be,
                    // but good enough for now
                    string connectorType = new HeloServicesConnector(url).Helo();
                    m_log.DebugFormat("[HG ASSET SERVICE]: HELO returned {0}", connectorType);
                    if (connectorType == "opensim-simian")
                    {
                        connector = new SimianAssetServiceConnector(url);
                    }
                    else
                        connector = new AssetServicesConnector(url);

                    m_connectors.Add(url, connector);
                }
            }
            return connector;
        }
 private IAssetService GetConnector(string url)
 {
     AssetServicesConnector connector = null;
     lock (m_connectors)
     {
         if (m_connectors.ContainsKey(url))
         {
             connector = m_connectors[url];
         }
         else
         {
             // We're instantiating this class explicitly, but this won't
             // work in general, because the remote grid may be running
             // an asset server that has a different protocol.
             // Eventually we will want a piece of protocol asking
             // the remote server about its kind. Definitely cool thing to do!
             connector = new AssetServicesConnector(url);
             m_connectors.Add(url, connector);
         }
     }
     return connector;
 }
        private IAssetService GetConnector(string url)
        {
            IAssetService connector = null;
            m_connectorsRwLock.AcquireReaderLock(-1);
            try
            {
                if (m_connectors.ContainsKey(url))
                {
                    connector = m_connectors[url];
                }
                else
                {
                    LockCookie lc = m_connectorsRwLock.UpgradeToWriterLock(-1);
                    try
                    {
                        /* recheck since other thread may have created it */
                        if (m_connectors.ContainsKey(url))
                        {
                            connector = m_connectors[url];
                        }
                        else
                        {
                            // Still not as flexible as I would like this to be,
                            // but good enough for now
                            string connectorType = new HeloServicesConnector(url).Helo();
                            m_log.DebugFormat("[HG ASSET SERVICE]: HELO returned {0}", connectorType);
                            if (connectorType == "opensim-simian")
                            {
                                connector = new SimianAssetServiceConnector(url);
                            }
                            else
                                connector = new AssetServicesConnector(url);

                            m_connectors.Add(url, connector);
                        }
                    }
                    finally
                    {
                        m_connectorsRwLock.DowngradeFromWriterLock(ref lc);
                    }
                }
            }
            finally
            {
                m_connectorsRwLock.ReleaseReaderLock();
            }
            return connector;
        }