예제 #1
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;
        }
        public DashboardController(Router router, TaskScheduler taskScheduler, IProviderRuntime providerRuntime, DashboardTraceListener traceListener)
        {
            this.traceListener   = traceListener;
            this.TaskScheduler   = taskScheduler;
            this.ProviderRuntime = providerRuntime;

            Action <string, Func <IOwinContext, IDictionary <string, string>, Task> > add = router.Add;

            add("/", Index);
            add("/index.min.js", IndexJs);
            add("/DashboardCounters", GetDashboardCounters);
            add("/RuntimeStats/:address", GetRuntimeStats);
            add("/HistoricalStats/:address", GetHistoricalStats);
            add("/GrainStats/:grain", GetGrainStats);
            add("/SiloProperties/:address", GetSiloExtendedProperties);
            add("/Trace", Trace);
            add("/ClusterStats", GetClusterStats);
            add("/SiloStats/:address", GetSiloStats);
        }
예제 #3
0
 public TraceWriter(DashboardTraceListener traceListener, IOwinContext context)
 {
     this.traceListener = traceListener;
     this.traceListener.Add(this.Write);
     this.context = context;
 }
예제 #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;
        }
 public DashboardController(TaskScheduler taskScheduler, IProviderRuntime providerRuntime, DashboardTraceListener traceListener)
 {
     this.traceListener   = traceListener;
     this.taskScheduler   = taskScheduler;
     this.providerRuntime = providerRuntime;
 }