private void LogSuccess(IDictionary <string, object> meta) { if (_logger != null && _logger.IsDebugEnabled()) { _logger?.Debug(MessagePattern, new SuccessMessage(meta)); } }
public async Task <IBoltProtocol> ConnectAsync() { _connMetricsListener?.ConnectionConnecting(_connEvent); await _tcpSocketClient.ConnectAsync(_uri).ConfigureAwait(false); SetOpened(); _logger?.Debug($"~~ [CONNECT] {_uri}"); _connMetricsListener?.ConnectionConnected(_connEvent); var version = await DoHandshakeAsync().ConfigureAwait(false); return(SelectBoltProtocol(version)); }
public void Debug(string message, params object[] args) { if (IsDebugEnabled()) { _delegate?.Debug(Reformat(message), args); } }
private void LogDebug(string message) { if (_logger.IsDebugEnabled()) { _logger.Debug(message); } }
private SslStream CreateSecureStream(Uri uri) { return(new SslStream(_stream, true, (sender, certificate, chain, errors) => { if (errors.HasFlag(SslPolicyErrors.RemoteCertificateNotAvailable)) { _logger?.Error(null, $"{GetType().Name}: Certificate not available."); return false; } var trust = _encryptionManager.TrustManager.ValidateServerCertificate(uri, new X509Certificate2(certificate.Export(X509ContentType.Cert)), chain, errors); if (trust) { _logger?.Debug("Trust is established, resuming connection."); } else { _logger?.Error(null, "Trust not established, aborting communication."); } return trust; })); }
public IBoltProtocol Connect() { _connMetricsListener?.ConnectionConnecting(_connEvent); _tcpSocketClient.Connect(_uri); SetOpened(); _logger?.Debug($"~~ [CONNECT] {_uri}"); _connMetricsListener?.ConnectionConnected(_connEvent); var version = DoHandshake(); return(SelectBoltProtocol(version)); }
internal async Task <IRoutingTable> UpdateRoutingTableWithInitialUriFallbackAsync( Func <ISet <Uri>, Task <IRoutingTable> > updateRoutingTableFunc = null) { _logger?.Debug("Updating routing table."); var hasPrependedInitialRouters = false; if (IsReadingInAbsenceOfWriter) { var uris = _initialServerAddressProvider.Get(); await PrependRoutersAsync(uris).ConfigureAwait(false); hasPrependedInitialRouters = true; } var triedUris = new HashSet <Uri>(); var routingTable = await UpdateRoutingTableAsync(triedUris).ConfigureAwait(false); if (routingTable != null) { return(routingTable); } if (!hasPrependedInitialRouters) { var uris = _initialServerAddressProvider.Get(); uris.ExceptWith(triedUris); if (uris.Count != 0) { await PrependRoutersAsync(uris).ConfigureAwait(false); routingTable = await UpdateRoutingTableAsync(null).ConfigureAwait(false); if (routingTable != null) { return(routingTable); } } } // We retied and tried our best however there is just no cluster. // This is the ultimate place we will inform the user that you need to re-create a driver throw new ServiceUnavailableException( "Failed to connect to any routing server. " + "Please make sure that the cluster is up and can be accessed by the driver and retry."); }