//        private int m_timeout = 1000;   //  increase timeout 250; now use the event one
        public PollServiceRequestManager(
            BaseHttpServer pSrv, bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout)
        {
            m_server = pSrv;
            PerformResponsesAsync = performResponsesAsync;
            m_WorkerThreadCount = pWorkerThreadCount;
            m_workerThreads = new Thread[m_WorkerThreadCount];

            StatsManager.RegisterStat(
                new Stat(
                    "QueuedPollResponses",
                    "Number of poll responses queued for processing.",
                    "",
                    "",
                    "httpserver",
                    m_server.Port.ToString(),
                    StatType.Pull,
                    MeasuresOfInterest.AverageChangeOverTime,
                    stat => stat.Value = m_requests.Count(),
                    StatVerbosity.Debug));

            StatsManager.RegisterStat(
                new Stat(
                    "ProcessedPollResponses",
                    "Number of poll responses processed.",
                    "",
                    "",
                    "httpserver",
                    m_server.Port.ToString(),
                    StatType.Pull,
                    MeasuresOfInterest.AverageChangeOverTime,
                    stat => stat.Value = ResponsesProcessed,
                    StatVerbosity.Debug));
        }
        public void RegisterHandlers(BaseHttpServer httpServer)
        {
            m_httpServer = httpServer;

            m_httpServer.AddXmlRPCHandler("get_avatar_appearance", XmlRPCGetAvatarAppearance);
            m_httpServer.AddXmlRPCHandler("update_avatar_appearance", XmlRPCUpdateAvatarAppearance);
        }
        public void TestChildAgentSingleRegionCapabilities()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID spUuid = TestHelpers.ParseTail(0x1);

            // XXX: This is not great since the use of statics will mean that this has to be manually cleaned up for
            // any subsequent test.
            // XXX: May replace with a mock IHttpServer later.
            BaseHttpServer httpServer = new BaseHttpServer(99999);
            MainServer.AddHttpServer(httpServer);
            MainServer.Instance = httpServer;

            CapabilitiesModule capsMod = new CapabilitiesModule();
            TestScene scene = new SceneHelpers().SetupScene();
            SceneHelpers.SetupSceneModules(scene, capsMod);

            ScenePresence sp = SceneHelpers.AddChildScenePresence(scene, spUuid);
            Assert.That(capsMod.GetCapsForUser(spUuid), Is.Not.Null);

            // TODO: Need to add tests for other ICapabiltiesModule methods.

            scene.CloseAgent(sp.UUID, false);
            Assert.That(capsMod.GetCapsForUser(spUuid), Is.Null);

            // TODO: Need to add tests for other ICapabiltiesModule methods.
        }
Exemplo n.º 4
0
        protected override void ReadConfig()
        {
            IConfig networkConfig = m_Config.Configs["Network"];

            if (networkConfig == null)
            {
                System.Console.WriteLine("Section 'Network' not found, server can't start");
                Thread.CurrentThread.Abort();
            }
            uint port = (uint)networkConfig.GetInt("port", 0);

            if (port == 0)
            {
                System.Console.WriteLine("Port number not specified or 0, server can't start");
                Thread.CurrentThread.Abort();
            }

            m_HttpServer = new BaseHttpServer(port);

            MainServer.Instance = m_HttpServer;

            if (MainConsole.Instance is RemoteConsole)
            {
                ((RemoteConsole)MainConsole.Instance).SetServer(m_HttpServer);
            }
        }
Exemplo n.º 5
0
        public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout)
        {
            m_server = pSrv;
            m_WorkerThreadCount = pWorkerThreadCount;
            m_workerThreads = new Thread[m_WorkerThreadCount];
            m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount];

            //startup worker threads
            for (uint i = 0; i < m_WorkerThreadCount; i++)
            {
                m_PollServiceWorkerThreads[i] = new PollServiceWorkerThread(m_server, pTimeout);
                m_PollServiceWorkerThreads[i].ReQueue += ReQueueEvent;

                m_workerThreads[i]
                    = Watchdog.StartThread(
                        m_PollServiceWorkerThreads[i].ThreadStart,
                        String.Format("PollServiceWorkerThread{0}", i),
                        ThreadPriority.Normal,
                        false,
                        true,
                        null,
                        int.MaxValue);
            }

            Watchdog.StartThread(
                this.ThreadStart,
                "PollServiceWatcherThread",
                ThreadPriority.Normal,
                false,
                true,
                null,
                1000 * 60 * 10);
        }
 public HGCommunicationsStandalone(
     ConfigSettings configSettings,                          
     NetworkServersInfo serversInfo,
     BaseHttpServer httpServer,
     HGGridServices gridService, 
     LibraryRootFolder libraryRootFolder, 
     bool dumpAssetsToFile)
     : base(serversInfo, libraryRootFolder)
 {           
     LocalUserServices localUserService =
         new LocalUserServices(
             serversInfo.DefaultHomeLocX, serversInfo.DefaultHomeLocY, this);
     localUserService.AddPlugin(configSettings.StandaloneUserPlugin, configSettings.StandaloneUserSource); 
     
     HGUserServices hgUserService = new HGUserServices(this, localUserService);
     // This plugin arrangement could eventually be configurable rather than hardcoded here.
     hgUserService.AddPlugin(new TemporaryUserProfilePlugin());
     hgUserService.AddPlugin(new HGUserDataPlugin(this, hgUserService));
     
     m_userService = hgUserService;            
     m_userAdminService = hgUserService;            
     m_avatarService = hgUserService;
     m_messageService = hgUserService;
     
     gridService.UserProfileCache = m_userProfileCacheService;
     m_gridService = gridService;                        
 }
        public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout)
        {
            m_server = pSrv;
            m_WorkerThreadCount = pWorkerThreadCount;
            m_workerThreads = new Thread[m_WorkerThreadCount];
            m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount];

            //startup worker threads
            for (uint i=0;i<m_WorkerThreadCount;i++)
            {
                m_PollServiceWorkerThreads[i] = new PollServiceWorkerThread(m_server, pTimeout);
                m_PollServiceWorkerThreads[i].ReQueue += ReQueueEvent;
               
                m_workerThreads[i] = new Thread(m_PollServiceWorkerThreads[i].ThreadStart);
                m_workerThreads[i].Name = String.Format("PollServiceWorkerThread{0}",i);
                //Can't add to thread Tracker here Referencing OpenSim.Framework creates circular reference
                m_workerThreads[i].Start();
                
            }

            //start watcher threads
            m_watcherThread = new Thread(ThreadStart);
            m_watcherThread.Name = "PollServiceWatcherThread";
            m_watcherThread.Start();
        }
Exemplo n.º 8
0
        private void SetupNeighbourRegions(TestScene sceneA, TestScene sceneB)
        {            
            // XXX: HTTP server is not (and should not be) necessary for this test, though it's absence makes the 
            // CapabilitiesModule complain when it can't set up HTTP endpoints.
            BaseHttpServer httpServer = new BaseHttpServer(99999);
            MainServer.AddHttpServer(httpServer);
            MainServer.Instance = httpServer;

            // We need entity transfer modules so that when sp2 logs into the east region, the region calls 
            // EntityTransferModuleto set up a child agent on the west region.
            // XXX: However, this is not an entity transfer so is misleading.
            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            config.AddConfig("Chat");
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, new ChatModule());           
            SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB, new ChatModule());
        }
Exemplo n.º 9
0
        public override void SetUp()
        {
            base.SetUp();

            uint port = 9999;
            uint sslPort = 9998;

            // This is an unfortunate bit of clean up we have to do because MainServer manages things through static
            // variables and the VM is not restarted between tests.
            MainServer.RemoveHttpServer(port);

            BaseHttpServer server = new BaseHttpServer(port, false, sslPort, "");
            MainServer.AddHttpServer(server);
            MainServer.Instance = server;

            IConfigSource config = new IniConfigSource();
            config.AddConfig("Startup");
            config.Configs["Startup"].Set("EventQueue", "true");

            CapabilitiesModule capsModule = new CapabilitiesModule();
            EventQueueGetModule eqgModule = new EventQueueGetModule();

            m_scene = new SceneHelpers().SetupScene();
            SceneHelpers.SetupSceneModules(m_scene, config, capsModule, eqgModule);
        }
Exemplo n.º 10
0
 // Create an instance of the server for the region represented by |scene|.
 public Server(Scene scene)
 {
     m_Scene = scene;
     m_CircuitManager = m_Scene.AuthenticateHandler;
     m_HttpServer = MainServer.Instance;
     //            m_configSource = m_Scene.Config;
 }
Exemplo n.º 11
0
        public CommunicationsLocal(
            ConfigSettings configSettings,                                   
            NetworkServersInfo serversInfo,
            BaseHttpServer httpServer,
            IAssetCache assetCache,
            LibraryRootFolder libraryRootFolder) 
            : base(serversInfo, httpServer, assetCache, libraryRootFolder)
        {
            PluginLoader<IInventoryStoragePlugin> loader = new PluginLoader<IInventoryStoragePlugin>();
            loader.Add("/OpenSim/InventoryStorage", new PluginProviderFilter(configSettings.InventoryPlugin));
            loader.Load();

            loader.Plugin.Initialize(configSettings);
            

            LocalUserServices lus 
                = new LocalUserServices(
                    serversInfo.DefaultHomeLocX, serversInfo.DefaultHomeLocY, this);
            //lus.AddPlugin(new TemporaryUserProfilePlugin());
            lus.AddPlugin(configSettings.StandaloneUserPlugin, configSettings.StandaloneUserSource);            
            m_userService = lus;
            m_userAdminService = lus;            
            m_avatarService = lus;
            m_messageService = lus;

            m_gridService = new LocalBackEndServices();                   
        }
Exemplo n.º 12
0
        protected override void StartupSpecific()
        {
            InventoryConfig config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml")));

            m_inventoryService = new GridInventoryService(config.UserServerURL);
            m_inventoryService.DoLookup = config.SessionLookUp;
            m_inventoryService.AddPlugin(config.DatabaseProvider, config.DatabaseConnect);


            m_log.Info("[" + LogName + "]: Starting HTTP server ...");

            m_httpServer = new BaseHttpServer(config.HttpPort);

            AddHttpHandlers(config.RegionAccessToAgentsInventory);

            m_httpServer.Start();

            m_log.Info("[" + LogName + "]: Started HTTP server");

            new HGInventoryService(m_inventoryService, config.AssetServerURL, config.UserServerURL, m_httpServer, config.InventoryServerURL);

            base.StartupSpecific();

            m_console.Commands.AddCommand("inventoryserver", false, "add user",
                    "add user",
                    "Add a random user inventory", HandleAddUser);
        }
Exemplo n.º 13
0
 public void RegisterHandlers(BaseHttpServer httpServer)
 {
     m_httpServer = httpServer;
     m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info",
                                                        m_gridInfoService.RestGetGridInfoMethod));
     m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
 }
Exemplo n.º 14
0
        public void RegisterHandlers(BaseHttpServer httpServer)
        {
            m_httpServer = httpServer;

            httpServer.AddXmlRPCHandler("hg_login", XmlRpcLoginMethod);
            httpServer.AddXmlRPCHandler("hg_new_auth_key", XmlRpcGenerateKeyMethod);
            httpServer.AddXmlRPCHandler("hg_verify_auth_key", XmlRpcVerifyKeyMethod);
        }
 public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout)
 {
     m_server = pSrv;
     m_WorkerThreadCount = pWorkerThreadCount;
     m_workerThreads = new Thread[m_WorkerThreadCount];
     m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount];
     m_timeOut = pTimeout;
 }
Exemplo n.º 16
0
 public void Initialise(OpenSimBase openSim)
 {
     //将opensim的引用记为内部成员变量
     m_log.Info("[MapDataAdapter]: initialized!");
     m_openSim = openSim;
     m_server = openSim.HttpServer;
     m_regions = new List<MapRegion>();
 }
Exemplo n.º 17
0
        public void RegisterHandlers(BaseHttpServer httpServer)
        {
            m_httpServer = httpServer;

            m_httpServer.AddXmlRPCHandler("add_new_user_friend", XmlRpcResponseXmlRPCAddUserFriend);
            m_httpServer.AddXmlRPCHandler("remove_user_friend", XmlRpcResponseXmlRPCRemoveUserFriend);
            m_httpServer.AddXmlRPCHandler("update_user_friend_perms", XmlRpcResponseXmlRPCUpdateUserFriendPerms);
            m_httpServer.AddXmlRPCHandler("get_user_friend_list", XmlRpcResponseXmlRPCGetUserFriendList);
        }
Exemplo n.º 18
0
        public HGGridServicesStandalone(NetworkServersInfo servers_info, BaseHttpServer httpServe, IAssetCache asscache, SceneManager sman)
            : base(servers_info, sman)
        {
            //Respond to Grid Services requests
            MainServer.Instance.AddXmlRPCHandler("logoff_user", LogOffUser);
            MainServer.Instance.AddXmlRPCHandler("check", PingCheckReply);
            MainServer.Instance.AddXmlRPCHandler("land_data", LandData);

        }
Exemplo n.º 19
0
//        private int m_timeout = 1000;   //  increase timeout 250; now use the event one

        public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout)
        {
			if (m_log.IsDebugEnabled) {
				m_log.DebugFormat ("{0} called", System.Reflection.MethodBase.GetCurrentMethod ().Name);
			}

            m_server = pSrv;
            m_WorkerThreadCount = pWorkerThreadCount;
            m_workerThreads = new Thread[m_WorkerThreadCount];
        }
Exemplo n.º 20
0
        public void Initialise(OpenSimBase openSim)
        {
            m_openSim = openSim;
            m_httpServer = openSim.HttpServer;
            MainServer.Instance = m_httpServer;

            InitialiseCommsManager(openSim);
            if (m_commsManager != null)
            {
                m_openSim.ApplicationRegistry.RegisterInterface<IUserService>(m_commsManager.UserService);
            }
        }
Exemplo n.º 21
0
        public void RegisterHandlers(BaseHttpServer httpServer)
        {
            m_httpServer = httpServer;

            // Rest
            m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info", m_gridInfoService.RestGetGridInfoMethod));

            // XmlRpc
            m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);

            // New Style
            m_httpServer.AddStreamHandler(new XmlRpcStreamHandler("POST", Util.XmlRpcRequestPrefix("get_grid_info"), m_gridInfoService.XmlRpcGridInfoMethod));
        }
Exemplo n.º 22
0
        public IHttpServer GetHttpServer(uint port)
        {
            m_Log.InfoFormat("[SERVER]: Requested port {0}", port);
            if (port == m_Port)
                return HttpServer;

            if (m_Servers.ContainsKey(port))
                return m_Servers[port];

            m_Servers[port] = new BaseHttpServer(port);
            m_Servers[port].Start();

            return m_Servers[port];
        }
Exemplo n.º 23
0
        public static IHttpServer GetHttpServer(uint port)
        {
            if (port == 0)
                return Instance;
            if (port == Instance.Port)
                return Instance;

            if (m_Servers.ContainsKey(port))
                return m_Servers[port];

            m_Servers[port] = new BaseHttpServer(port);
            m_Servers[port].Start();

            return m_Servers[port];
        }
Exemplo n.º 24
0
        public override void SetUp()
        {
            base.SetUp();

            uint port = 9999;
            uint sslPort = 9998;

            // This is an unfortunate bit of clean up we have to do because MainServer manages things through static
            // variables and the VM is not restarted between tests.
            MainServer.RemoveHttpServer(port);

            BaseHttpServer server = new BaseHttpServer(port, false, sslPort, "");
            MainServer.AddHttpServer(server);
            MainServer.Instance = server;
        }
Exemplo n.º 25
0
        protected override void StartupSpecific()
        {
            SceneManager = SceneManager.Instance;

            Initialize();

            m_httpServer 
                = new BaseHttpServer(
                    m_httpServerPort, m_networkServersInfo.HttpUsesSSL, m_networkServersInfo.httpSSLPort, 
                    m_networkServersInfo.HttpSSLCN);
            
            if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort))
            {
                m_log.Error("[REGION SERVER]: HTTP Server config failed.   HTTP Server and HTTPS server must be on different ports");
            }

            m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0}", m_httpServerPort);
            m_httpServer.Start();

            MainServer.AddHttpServer(m_httpServer);
            MainServer.Instance = m_httpServer;

            // "OOB" Server
            if (m_networkServersInfo.ssl_listener)
            {
                if (!m_networkServersInfo.ssl_external)
                {
                    BaseHttpServer server = new BaseHttpServer(
                        m_networkServersInfo.https_port, m_networkServersInfo.ssl_listener, m_networkServersInfo.cert_path,
                        m_networkServersInfo.cert_pass);

                    m_log.InfoFormat("[REGION SERVER]: Starting HTTPS server on port {0}", server.Port);
                    MainServer.AddHttpServer(server);
                    server.Start();
                }
                else
                {
                    BaseHttpServer server = new BaseHttpServer(
                        m_networkServersInfo.https_port);

                    m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0} for external HTTPS", server.Port);
                    MainServer.AddHttpServer(server);
                    server.Start();
                }
            }
            
            base.StartupSpecific();
        }
Exemplo n.º 26
0
        public static IHttpServer GetHttpServer(uint port)
        {
            if (port == 0)
                return Instance;
            if (instance != null && port == Instance.Port)
                return Instance;

            if (m_Servers.ContainsKey(port))
                return m_Servers[port];

            m_Servers[port] = new BaseHttpServer(port);

            m_log.InfoFormat("[MAIN HTTP SERVER]: Starting main http server on port {0}", port);
            m_Servers[port].Start();

            return m_Servers[port];
        }
Exemplo n.º 27
0
        public void RegisterHandlers(BaseHttpServer httpServer)
        {
            m_httpServer = httpServer;

            m_httpServer.AddXmlRPCHandler("add_new_user_friend", XmlRpcResponseXmlRPCAddUserFriend);
            m_httpServer.AddXmlRPCHandler("remove_user_friend", XmlRpcResponseXmlRPCRemoveUserFriend);
            m_httpServer.AddXmlRPCHandler("update_user_friend_perms", XmlRpcResponseXmlRPCUpdateUserFriendPerms);
            m_httpServer.AddXmlRPCHandler("get_user_friend_list", XmlRpcResponseXmlRPCGetUserFriendList);

            // New Style
            m_httpServer.AddStreamHandler(new XmlRpcStreamHandler("POST", Util.XmlRpcRequestPrefix("add_new_user_friend"), XmlRpcResponseXmlRPCAddUserFriend));
            m_httpServer.AddStreamHandler(new XmlRpcStreamHandler("POST", Util.XmlRpcRequestPrefix("remove_user_friend"), XmlRpcResponseXmlRPCRemoveUserFriend));
            m_httpServer.AddStreamHandler(new XmlRpcStreamHandler("POST", Util.XmlRpcRequestPrefix("update_user_friend_perms"), XmlRpcResponseXmlRPCUpdateUserFriendPerms));
            m_httpServer.AddStreamHandler(new XmlRpcStreamHandler("POST", Util.XmlRpcRequestPrefix("get_user_friend_list"), XmlRpcResponseXmlRPCGetUserFriendList));

            // Protobuf Handlers
            m_httpServer.AddStreamHandler(new BufferStreamHandler("POST", "/get_user_friend_list2/", HandleGetUserFriendList2));
        }
        public PollServiceRequestManager(
            BaseHttpServer pSrv, bool performResponsesAsync, uint pWorkerThreadCount, int pTimeout)
        {
            m_server = pSrv;
            m_WorkerThreadCount = pWorkerThreadCount;
            m_workerThreads = new Thread[m_WorkerThreadCount];

            PollServiceHttpRequestComparer preqCp = new PollServiceHttpRequestComparer();
            m_bycontext = new Dictionary<PollServiceHttpRequest, Queue<PollServiceHttpRequest>>(preqCp);

            STPStartInfo startInfo = new STPStartInfo();
            startInfo.IdleTimeout = 30000;
            startInfo.MaxWorkerThreads = 20;
            startInfo.MinWorkerThreads = 1;
            startInfo.ThreadPriority = ThreadPriority.Normal;
            startInfo.StartSuspended = true;
            startInfo.ThreadPoolName = "PoolService";

            m_threadPool = new SmartThreadPool(startInfo);
		
        }
        internal void DoHTTPGruntWork(BaseHttpServer server, Hashtable responsedata)
        {
            OSHttpResponse response
                = new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext);

            byte[] buffer = server.DoHTTPGruntWork(responsedata, response);

            response.SendChunked = false;
            response.ContentLength64 = buffer.Length;
            response.ContentEncoding = Encoding.UTF8;

            try
            {
                response.OutputStream.Write(buffer, 0, buffer.Length);
            }
            catch (Exception ex)
            {
                m_log.Warn(string.Format("[POLL SERVICE WORKER THREAD]: Error ", ex));
            }
            finally
            {
                //response.OutputStream.Close();
                try
                {
                    response.OutputStream.Flush();
                    response.Send();

                    //if (!response.KeepAlive && response.ReuseContext)
                    //    response.FreeContext();
                }
                catch (Exception e)
                {
                    m_log.Warn(String.Format("[POLL SERVICE WORKER THREAD]: Error ", e));
                }

                PollServiceArgs.RequestsHandled++;
            }
        }
Exemplo n.º 30
0
        public static Scene CreateScene(ushort httpPort, uint xloc, uint yloc)
        {
            //2130706433 = 127.0.0.1
            BaseHttpServer server = new BaseHttpServer(httpPort, new System.Net.IPAddress(2130706433));
            var commsManager = new OpenSim.Framework.Communications.CommunicationsManager(new OpenSim.Framework.NetworkServersInfo(), server,
                    new AssetCache(), new LibraryRootFolder("."));
            var gridSvc = new SceneCommunicationService(commsManager);
            var regionInfo =  new OpenSim.Framework.RegionInfo(xloc, yloc,
                    new System.Net.IPEndPoint(new System.Net.IPAddress(2130706433), 9001),
                    "localhost");

            var restComms = new RESTInterregionComms();
            gridSvc.UnitTest_SetCommsOut(restComms);
            Scene scene = new Scene(regionInfo, commsManager, gridSvc);

            restComms.Initialise_Unittest(scene);

            server.Start();

            

            return scene;
        }