Exemplo n.º 1
0
 public static Container RegisterConreignApi(this Container container, IOrleansClientInitializer initializer,
                                             ConreignApiConfiguration configuration)
 {
     if (container == null)
     {
         throw new ArgumentNullException(nameof(container));
     }
     if (initializer == null)
     {
         throw new ArgumentNullException(nameof(initializer));
     }
     if (configuration == null)
     {
         throw new ArgumentNullException(nameof(configuration));
     }
     container.Register(() => Log.Logger.ForContext("ApplicationId", "Conreign.Api"), Lifestyle.Singleton);
     container.Register(() => OrleansClient.Initialize(initializer).Result, Lifestyle.Singleton);
     container.Register <GameHubCountersCollection>(Lifestyle.Singleton);
     container.RegisterCollection <HubPipelineModule>(new[] { Assembly.GetExecutingAssembly() });
     RegisterHubs(container);
     container.RegisterSingleton(new SlowConnectionBehaviourOptions(TimeSpan.FromSeconds(3)));
     container.RegisterClientHandlerFactory(c =>
     {
         // c.Behaviours.Add(typeof(SlowConnectionBehaviour<,>));
     });
     return(container);
 }
Exemplo n.º 2
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, OrleansClient orleansClient)
 {
     loggerFactory.AddConsole(Configuration.GetSection("Logging"));
     loggerFactory.AddDebug();
     orleansClient.Initialize();
     app.UseMvc();
     app.UseDeveloperExceptionPage();
 }
 protected void Application_Start()
 {
     OrleansClient.Initialize(Server.MapPath("~/DevTestClientConfiguration.xml"));
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
Exemplo n.º 4
0
        private static async Task TestHandler()
        {
            var config = ClientConfiguration.LocalhostSilo();

            config.AddSimpleMessageStreamProvider(StreamConstants.ProviderName);
            var host   = new OrleansClientInitializer(config);
            var client = await OrleansClient.Initialize(host);

            var container = new Container();

            container.RegisterClientHandlerFactory();
            var handlerFactory = container.GetInstance <ClientHandlerFactory>();

            using (var connection = await client.Connect(Guid.NewGuid()))
            {
                var handler = handlerFactory.Create(connection);
                handler.Events.Subscribe(Write);
                var meta          = new Metadata();
                var loginResponse = await handler.Handle(new LoginCommand(), meta);

                Write(loginResponse);
                meta = new Metadata {
                    AccessToken = loginResponse.AccessToken
                };
                var joinRoom = new JoinRoomCommand {
                    RoomId = "conreign"
                };
                await handler.Handle(joinRoom, meta);

                var updatePlayer = new UpdatePlayerOptionsCommand
                {
                    RoomId  = "conreign",
                    Options = new PlayerOptionsData
                    {
                        Nickname = "smolyakoff",
                        Color    = "#010101"
                    }
                };
                await handler.Handle(updatePlayer, meta);

                var write = new SendMessageCommand
                {
                    RoomId = "conreign",
                    Text   = "Hello!"
                };
                await handler.Handle(write, meta);

                var getState = new GetRoomStateCommand
                {
                    RoomId = "conreign"
                };
                var state = await handler.Handle(getState, meta);

                Write(state);
            }
        }
Exemplo n.º 5
0
        private static async Task RunOrleansBot(string roomId, int i, int total)
        {
            var config = ClientConfiguration.LoadFromFile("OrleansClientConfiguration.xml");
            var host   = new OrleansClientInitializer(config);
            var client = await OrleansClient.Initialize(host);

            using (var connection = await client.Connect(Guid.NewGuid()))
            {
                await RunBot(connection, roomId, i, total);
            }
        }
Exemplo n.º 6
0
        public OrleansSiloForTesting()
        {
            domain = AppDomain.CreateDomain("OrleansSiloForTesting", null, new AppDomainSetup
            {
                AppDomainInitializer          = Start,
                AppDomainInitializerArguments = new string[0],
                ApplicationBase = AppDomain.CurrentDomain.BaseDirectory
            });

            var clientConfigFileName = ConfigurationFilePath("OrleansClientConfigurationForTesting.xml");

            OrleansClient.Initialize(clientConfigFileName);
        }
Exemplo n.º 7
0
 protected void Application_Start()
 {
     if (RoleEnvironment.IsAvailable)
     {
         // running in Azure
         OrleansAzureClient.Initialize(Server.MapPath(@"~/AzureConfiguration.xml"));
     }
     else
     {
         // not running in Azure
         OrleansClient.Initialize(Server.MapPath(@"~/LocalConfiguration.xml"));
     }
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
 }
Exemplo n.º 8
0
        static void Main()
        {
            Console.WriteLine("Make sure that local silo is started. Press Enter to proceed ...");
            Console.ReadLine();

            Console.Write("Enter number of clients: ");
            var numberOfClients = int.Parse(Console.ReadLine() ?? Environment.ProcessorCount.ToString("D"));

            Console.Write("Enter number of repeated pings per client (thousands): ");
            var numberOfRepeatsPerClient = int.Parse(Console.ReadLine() ?? "15");

            OrleansClient.Initialize("DevTestClientConfiguration.xml");

            benchmark = new Benchmark(numberOfClients, numberOfRepeatsPerClient * 1000);
            benchmark.Run();

            Console.ReadLine();
        }
Exemplo n.º 9
0
        public static void Main()
        {
            var args = new[]
            {
                "UseDevelopmentStorage=true" // # TopicStorageAccount
            };

            var hostDomain = AppDomain.CreateDomain("OrleansHost", null, new AppDomainSetup
            {
                AppDomainInitializer          = StartSilo,
                AppDomainInitializerArguments = args,
            });

            OrleansClient.Initialize("ClientConfiguration.xml");
            RunClient();

            Console.WriteLine("Press Enter to terminate ...");
            Console.ReadLine();

            hostDomain.DoCallBack(StopSilo);
        }
Exemplo n.º 10
0
        const string URL      = "http://devicetracker.cloudapp.net:8080/api/devices/processmessage"; // Change to point to the web site under test

        /// <summary>
        /// Start the simulation via the controller grain.
        /// </summary>
        /// <returns></returns>
        public async Task Run()
        {
            OrleansClient.Initialize();

            // create an aggregator grain to track results from the load test
            IAggregatorGrain aggregator = AggregatorGrainFactory.GetGrain(0);

            // set this SimulationController class as an observer on the aggregator grain
            observer = await SimulationObserverFactory.CreateObjectReference(this); // convert our class into a grain reference

            await aggregator.SetObserver(observer);                                 // then set ourselves up to receive notifications on ReportResults()

            // Instantiate the manager grains and start the simulations
            // Pause between each batch to ramp up load gradually
            for (int i = 0; i < BATCH_COUNT; i++)
            {
                Console.WriteLine("Starting batch #{0}", i + 1);
                IManagerGrain manager = ManagerGrainFactory.GetGrain(i);
                managers.Add(manager);                                                // store grain reference

                await manager.SetAggregator(aggregator);                              // link in the aggregator

                await manager.StartSimulators(i *DELAY_STEPS *1000, BATCH_SIZE, URL); // start the sinulation
            }

            // Sleep for the duration of the test
            Console.WriteLine("Running test...");
            Thread.Sleep(RUN_TIME * 1000);  // low value just for test

            // Gradually stop simulators
            foreach (var i in managers)
            {
                Console.WriteLine("Stopping step #{0}", managers.IndexOf(i) + 1);
                await i.StopSimulators();

                Thread.Sleep(DELAY_STEPS * 1000);
            }
        }