Ejemplo n.º 1
0
        public ClusterMaintenanceWorker(TcpConnectionOptions tcp, CancellationToken externalToken, ServerStore serverStore, string leader, long term)
        {
            _tcp    = tcp;
            _cts    = CancellationTokenSource.CreateLinkedTokenSource(externalToken);
            _token  = _cts.Token;
            _server = serverStore;
            _logger = LoggingSource.Instance.GetLogger <ClusterMaintenanceWorker>(serverStore.NodeTag);
            _name   = $"Heartbeats worker connection to leader {leader} in term {term}";

            WorkerSamplePeriod = _server.Configuration.Cluster.WorkerSamplePeriod.AsTimeSpan;
            CurrentTerm        = term;
            SupportedFeatures  = TcpConnectionHeaderMessage.GetSupportedFeaturesFor(TcpConnectionHeaderMessage.OperationTypes.Heartbeats, _tcp.ProtocolVersion);
        }
Ejemplo n.º 2
0
            private ClusterNodeStatusReport BuildReport(BlittableJsonReaderObject rawReport, TcpConnectionHeaderMessage.SupportedFeatures supportedFeatures)
            {
                using (rawReport)
                {
                    if (supportedFeatures.Heartbeats.IncludeServerInfo)
                    {
                        var maintenanceReport = JsonDeserializationServer.MaintenanceReport(rawReport);

                        var status = maintenanceReport.ServerReport.OutOfCpuCredits == true
                            ? ClusterNodeStatusReport.ReportStatus.OutOfCredits
                            : ClusterNodeStatusReport.ReportStatus.Ok;

                        return(new ClusterNodeStatusReport(
                                   maintenanceReport.ServerReport,
                                   maintenanceReport.DatabasesReport,
                                   status,
                                   null,
                                   DateTime.UtcNow,
                                   _lastSuccessfulReceivedReport));
                    }

                    var report = new Dictionary <string, DatabaseStatusReport>();
                    foreach (var property in rawReport.GetPropertyNames())
                    {
                        var value = (BlittableJsonReaderObject)rawReport[property];
                        report.Add(property, JsonDeserializationServer.DatabaseStatusReport(value));
                    }

                    return(new ClusterNodeStatusReport(
                               new ServerReport(),
                               report,
                               ClusterNodeStatusReport.ReportStatus.Ok,
                               null,
                               DateTime.UtcNow,
                               _lastSuccessfulReceivedReport));
                }
            }