예제 #1
0
        public async Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            this.logger = providerRuntime.GetLogger("Dashboard");

            var router = new Router();
            new DashboardController(router, TaskScheduler.Current,  providerRuntime);

            var options = new StartOptions
            {
                ServerFactory = "Nowin",
                Port = config.Properties.ContainsKey("Port") ? int.Parse(config.Properties["Port"]) : 8080,
            };

            var username = config.Properties.ContainsKey("Username") ? config.Properties["Username"] : null;
            var password = config.Properties.ContainsKey("Password") ? config.Properties["Password"] : null;
            try
            {
                host = WebApp.Start(options, app => new WebServer(router, username, password).Configuration(app));
            }
            catch (Exception ex)
            {
                this.logger.Error(10001, ex.ToString());
            }

            this.logger.Verbose($"Dashboard listening on {options.Port}");

            this.profiler = new GrainProfiler(TaskScheduler.Current, providerRuntime);

            var dashboardGrain = providerRuntime.GrainFactory.GetGrain<IDashboardGrain>(0);
            await dashboardGrain.Init();

            var siloGrain = providerRuntime.GrainFactory.GetGrain<ISiloGrain>(providerRuntime.ToSiloAddress());
            await siloGrain.SetOrleansVersion(typeof(SiloAddress).Assembly.GetName().Version.ToString());
        }
예제 #2
0
        public Task ReportStats(List <ICounter> statsCounters)
        {
            if (dispatcher.CanDispatch())
            {
                var grain = runtime.GrainFactory.GetGrain <ISiloGrain>(runtime.ToSiloAddress());

                var values = statsCounters.Select(x => new StatCounter
                {
                    Name  = x.Name,
                    Value = x.GetValueString(),
                    Delta = x.IsValueDelta ? x.GetDeltaString() : null
                }).OrderBy(x => x.Name).ToArray();

                dispatcher.DispatchAsync(() => grain.ReportCounters(values));
            }

            return(Task.CompletedTask);
        }
예제 #3
0
        public async Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            this.Name = name;

            this.logger = providerRuntime.GetLogger("Dashboard");

            this.dashboardTraceListener = new DashboardTraceListener();

            var router = new Router();

            this.controller = new DashboardController(router, TaskScheduler.Current, providerRuntime, dashboardTraceListener);

            var options = new StartOptions
            {
                ServerFactory = "Nowin",
                Port          = config.Properties.ContainsKey("Port") ? int.Parse(config.Properties["Port"]) : 8080,
            };

            var username = config.Properties.ContainsKey("Username") ? config.Properties["Username"] : null;
            var password = config.Properties.ContainsKey("Password") ? config.Properties["Password"] : null;

            try
            {
                host = WebApp.Start(options, app => new WebServer(router, username, password).Configuration(app));
                Trace.Listeners.Remove("HostingTraceListener");
            }
            catch (Exception ex)
            {
                this.logger.Error(10001, ex.ToString());
            }

            this.logger.Verbose($"Dashboard listening on {options.Port}");


            this.profiler = new GrainProfiler(TaskScheduler.Current, providerRuntime);


            var dashboardGrain = providerRuntime.GrainFactory.GetGrain <IDashboardGrain>(0);
            await dashboardGrain.Init();


            var siloGrain = providerRuntime.GrainFactory.GetGrain <ISiloGrain>(providerRuntime.ToSiloAddress());
            await siloGrain.SetOrleansVersion(typeof(SiloAddress).Assembly.GetName().Version.ToString());

            Trace.Listeners.Add(dashboardTraceListener);



            // horrible hack to grab the scheduler
            // to allow the stats publisher to push
            // counters to grains
            OrleansScheduler = TaskScheduler.Current;
        }
예제 #4
0
        public async Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            this.Name = name;

            this.logger = providerRuntime.GetLogger("Dashboard");

            this.dashboardTraceListener = new DashboardTraceListener();

            var port     = config.Properties.ContainsKey("Port") ? int.Parse(config.Properties["Port"]) : 8080;
            var hostname = config.Properties.ContainsKey("Host") ? config.Properties["Host"] : "*";

            var username = config.Properties.ContainsKey("Username") ? config.Properties["Username"] : null;
            var password = config.Properties.ContainsKey("Password") ? config.Properties["Password"] : null;

            var credentials = new UserCredentials(username, password);


            try
            {
                var builder = new WebHostBuilder()
                              .ConfigureServices(s => s
                                                 .AddSingleton(TaskScheduler.Current)
                                                 .AddSingleton(providerRuntime)
                                                 .AddSingleton(dashboardTraceListener)
                                                 )
                              .ConfigureServices(services =>
                {
                    services
                    .AddMvcCore()
                    .AddApplicationPart(typeof(DashboardController).Assembly)
                    .AddJsonFormatters();
                })
                              .Configure(app =>
                {
                    if (credentials.HasValue())
                    {
                        // only when usename and password are configured
                        // do we inject basicauth middleware in the pipeline
                        app.UseMiddleware <BasicAuthMiddleware>(credentials);
                    }

                    app.UseMvc();
                })
                              .UseKestrel()
                              .UseUrls($"http://{hostname}:{port}");
                host = builder.Build();
                host.Start();
            }
            catch (Exception ex)
            {
                this.logger.Error(10001, ex.ToString());
            }

            this.logger.Verbose($"Dashboard listening on {port}");

            this.profiler = new GrainProfiler(TaskScheduler.Current, providerRuntime);

            var dashboardGrain = providerRuntime.GrainFactory.GetGrain <IDashboardGrain>(0);
            await dashboardGrain.Init();

            var siloGrain = providerRuntime.GrainFactory.GetGrain <ISiloGrain>(providerRuntime.ToSiloAddress());
            await siloGrain.SetOrleansVersion(typeof(SiloAddress).Assembly.GetName().Version.ToString());

            Trace.Listeners.Add(dashboardTraceListener);

            // horrible hack to grab the scheduler
            // to allow the stats publisher to push
            // counters to grains
            OrleansScheduler = TaskScheduler.Current;
        }
예제 #5
0
        private static async Task ActivateSiloGrainAsync(IProviderRuntime providerRuntime)
        {
            var siloGrain = providerRuntime.GrainFactory.GetGrain <ISiloGrain>(providerRuntime.ToSiloAddress());

            await siloGrain.SetOrleansVersion(typeof(SiloAddress).GetTypeInfo().Assembly.GetName().Version.ToString());
        }