public async Task Get() { using (var webSocket = await HttpContext.WebSockets.AcceptWebSocketAsync()) { using (var writer = new NotificationCenterWebSocketWriter(webSocket, ServerStore.ServerDashboardNotifications, ServerStore.ContextPool, ServerStore.ServerShutdown)) { var isValidFor = GetDatabaseAccessValidationFunc(); try { using (var lowMemoryMonitor = new LowMemoryMonitor()) { var machineResources = MachineResourcesNotificationSender.GetMachineResources(Server.MetricCacher, lowMemoryMonitor, Server.CpuUsageCalculator); await writer.WriteToWebSocket(machineResources.ToJson()); } using (var cts = CancellationTokenSource.CreateLinkedTokenSource(ServerStore.ServerShutdown)) { var databasesInfo = new List <AbstractDashboardNotification>(); foreach (var item in DatabasesInfoRetriever.FetchDatabasesInfo(ServerStore, isValidFor, cts.Token)) { databasesInfo.Add(item); } foreach (var info in databasesInfo) { await writer.WriteToWebSocket(info.ToJson()); } } } catch (Exception e) { if (Logger.IsInfoEnabled) { Logger.Info("Failed to send the initial server dashboard data", e); } } await writer.WriteNotifications(isValidFor); } } }
public TrafficNotificationSender(int widgetId, ClusterDashboardPayloadType payloadType, DatabasesInfoRetriever databasesInfoRetriever, ConnectedWatcher watcher, CancellationToken shutdown) : base(widgetId, watcher, shutdown) { _payloadType = payloadType; _databasesInfoRetriever = databasesInfoRetriever; }
public OngoingTasksNotificationSender(int widgetId, DatabasesInfoRetriever databasesInfoRetriever, ConnectedWatcher watcher, CancellationToken shutdown) : base(widgetId, watcher, shutdown) { _databasesInfoRetriever = databasesInfoRetriever; }
public ClusterDashboardNotifications(RavenServer server, CanAccessDatabase canAccessDatabase, CancellationToken shutdown) { _server = server; _shutdown = shutdown; _databasesInfoRetriever = new DatabasesInfoRetriever(server.ServerStore, canAccessDatabase); }