public async Task <IPingReport> PingAsync(PingOptions?options = null) { ThrowIfBootStrapFailed(); options ??= new PingOptions(); return(await DiagnosticsReportProvider.CreatePingReportAsync(Context, BucketConfig, options) .ConfigureAwait(false)); }
public Task <IPingReport> PingAsync(PingOptions?options = null) { ThrowIfBootStrapFailed(); options ??= new PingOptions(); return(Task.Run(() => DiagnosticsReportProvider.CreatePingReport(Context, BucketConfig, options))); }
public async Task <IPingReport> PingAsync(PingOptions?options = null) { options ??= new PingOptions(); return(await DiagnosticsReportProvider. CreatePingReportAsync(_context, _context.GlobalConfig, options). ConfigureAwait(false)); }
/// <summary> /// Creates a diagnostics report from the perspective of the client connected to each of the requeted services. /// </summary> /// <param name="reportId">The report identifer.</param> /// <returns>An <see cref="IDiagnosticsReport"/> with details of connected services.</returns> public IDiagnosticsReport Diagnostics(string reportId) { if (string.IsNullOrWhiteSpace(reportId)) { throw new ArgumentException(nameof(reportId)); } var configs = _clusterController.Buckets.Cast <IConfigObserver>().Select(x => x.ConfigInfo); return(DiagnosticsReportProvider.CreateDiagnosticsReport(reportId, configs)); }
public void Can_Create_DiagnosticsReport() { var reportId = Guid.NewGuid().ToString(); var kvLastActivity = DateTime.UtcNow; var viewLastActivity = kvLastActivity.AddSeconds(-5); var queryLastActivity = kvLastActivity.AddSeconds(-10); var searchLastActivity = kvLastActivity.AddSeconds(-15); var analyticsLastActivity = kvLastActivity.AddSeconds(-20); var connection = Mock.Of <IConnection>(c => c.LastActivity == kvLastActivity && c.IsConnected == true && c.IsAuthenticated == true ); var connectionPool = Mock.Of <IConnectionPool>(p => p.Connections == new List <IConnection> { connection } ); var server = Mock.Of <IServer>(s => s.IsDataNode == true && s.ConnectionPool == connectionPool && s.IsViewNode == true && s.ViewClient.LastActivity == viewLastActivity && s.IsQueryNode == true && s.QueryClient.LastActivity == queryLastActivity && s.IsSearchNode == true && s.SearchClient.LastActivity == searchLastActivity && s.IsAnalyticsNode == true && s.AnalyticsClient.LastActivity == analyticsLastActivity ); var configInfo = Mock.Of <IConfigInfo>(c => c.Servers == new List <IServer> { server } ); var report = DiagnosticsReportProvider.CreateDiagnosticsReport(reportId, new[] { configInfo }); Assert.IsNotNull(report); Assert.AreEqual(reportId, report.Id); Assert.AreEqual(1, report.Version); Assert.AreEqual(ClientIdentifier.GetClientDescription(), report.Sdk); Assert.IsTrue(report.Services["kv"].First(x => x.Type == ServiceType.KeyValue).LastActivity > 0); Assert.IsTrue(report.Services["view"].First(x => x.Type == ServiceType.Views).LastActivity > 0); Assert.IsTrue(report.Services["n1ql"].First(x => x.Type == ServiceType.Query).LastActivity > 0); Assert.IsTrue(report.Services["fts"].First(x => x.Type == ServiceType.Search).LastActivity > 0); Assert.IsTrue(report.Services["cbas"].First(x => x.Type == ServiceType.Analytics).LastActivity > 0); }
public async Task WaitUntilReadyAsync(TimeSpan timeout, WaitUntilReadyOptions?options = null) { if (!_context.IsGlobal) { throw new NotSupportedException( "Cluster level WaitUntilReady is only supported by Couchbase Server 6.5 or greater. " + "If you think this exception is caused by another error, please check your SDK logs for detail."); } options ??= new WaitUntilReadyOptions(); if (options.DesiredStateValue == ClusterState.Offline) { throw new ArgumentException(nameof(options.DesiredStateValue)); } var token = options.CancellationTokenValue; CancellationTokenSource?tokenSource = null; if (token == CancellationToken.None) { tokenSource = CancellationTokenSource.CreateLinkedTokenSource(token); tokenSource.CancelAfter(timeout); token = tokenSource.Token; } try { token.ThrowIfCancellationRequested(); while (!token.IsCancellationRequested) { var pingReport = await DiagnosticsReportProvider.CreatePingReportAsync(_context, _context.GlobalConfig, new PingOptions { ServiceTypesValue = options.ServiceTypesValue }).ConfigureAwait(false); var status = new Dictionary <string, bool>(); foreach (var service in pingReport.Services) { var failures = service.Value.Any(x => x.State != ServiceState.Ok); if (failures) { //mark a service as failed status.Add(service.Key, failures); } } //everything is up if (status.Count == 0) { _clusterState = ClusterState.Online; return; } //determine if completely offline or degraded _clusterState = status.Count == pingReport.Services.Count ? ClusterState.Offline : ClusterState.Degraded; if (_clusterState == options.DesiredStateValue) { return; } await Task.Delay(100, token).ConfigureAwait(false); } } catch (OperationCanceledException e) { throw new UnambiguousTimeoutException($"Timed out after {timeout}.", e); } catch (Exception e) { throw new CouchbaseException("An error has occurred, see the inner exception for details.", e); } finally { tokenSource?.Dispose(); } }
public async Task <IDiagnosticsReport> DiagnosticsAsync(DiagnosticsOptions?options = null) { options ??= new DiagnosticsOptions(); return(await DiagnosticsReportProvider.CreateDiagnosticsReportAsync(_context, options.ReportIdValue ?? Guid.NewGuid().ToString()) .ConfigureAwait(false)); }
public Task <IPingReport> PingAsync(PingOptions options = null) { options = options ?? new PingOptions(); return(Task.Run(() => DiagnosticsReportProvider.CreatePingReport(Context, BucketConfig, options))); }
public Task <IDiagnosticsReport> DiagnosticsAsync(DiagnosticsOptions?options = null) { options ??= new DiagnosticsOptions(); return(Task.FromResult(DiagnosticsReportProvider.CreateDiagnosticsReport(_context, options.ReportIdValue ?? Guid.NewGuid().ToString()))); }