Exemplo n.º 1
0
        private void HeartbeatVersion42000(TransactionOperationContext ctx, MaintenanceReport report)
        {
            report.ServerReport = new ServerReport
            {
                OutOfCpuCredits = _server.Server.CpuCreditsBalance.BackgroundTasksAlertRaised.IsRaised()
            };

            using (var writer = new BlittableJsonTextWriter(ctx, _tcp.Stream))
            {
                ctx.Write(writer, report.ToJson());
            }
        }
        public void CollectDatabasesStatusReport()
        {
            var lastNodeReport = new Dictionary <string, DatabaseStatusReport>();
            var report         = new MaintenanceReport();

            while (_token.IsCancellationRequested == false)
            {
                try
                {
                    using (_server.ContextPool.AllocateOperationContext(out TransactionOperationContext ctx))
                    {
                        Dictionary <string, DatabaseStatusReport> nodeReport;
                        using (ctx.OpenReadTransaction())
                        {
                            nodeReport = CollectDatabaseInformation(ctx, lastNodeReport);
                        }

                        if (SupportedFeatures.Heartbeats.IncludeServerInfo == false)
                        {
                            HeartbeatVersion41200(ctx, nodeReport);
                        }
                        else
                        {
                            report.DatabasesReport = nodeReport;
                            HeartbeatVersion42000(ctx, report);
                        }

                        lastNodeReport = nodeReport;
                    }
                }
                catch (Exception e)
                {
                    if (_tcp.TcpClient?.Connected != true)
                    {
                        if (_logger.IsInfoEnabled)
                        {
                            _logger.Info("The tcp connection was closed, so we exit the maintenance work.");
                        }
                        return;
                    }
                    if (_logger.IsInfoEnabled)
                    {
                        _logger.Info($"Exception occurred while collecting info from {_server.NodeTag}", e);
                    }
                }
                finally
                {
                    _token.WaitHandle.WaitOne(WorkerSamplePeriod);
                }
            }
        }
        private void HeartbeatVersion42000(TransactionOperationContext ctx, MaintenanceReport report)
        {
            report.ServerReport = new ServerReport
            {
                OutOfCpuCredits  = _server.Server.CpuCreditsBalance.BackgroundTasksAlertRaised.IsRaised(),
                EarlyOutOfMemory = LowMemoryNotification.Instance.IsEarlyOutOfMemory,
                HighDirtyMemory  = LowMemoryNotification.Instance.DirtyMemoryState.IsHighDirty
            };

            using (var writer = new BlittableJsonTextWriter(ctx, _tcp.Stream))
            {
                ctx.Write(writer, report.ToJson());
            }
        }