void Dispose(bool disposing) { if (!_disposed) { if (disposing) { GC.SuppressFinalize(this); } if (_ioStrategy != null) { _ioStrategy.Dispose(); } _disposed = true; } }
private void Dispose(bool disposing) { lock (_syncObj) { if (!_disposed) { _disposed = true; IsDown = true; if (disposing) { GC.SuppressFinalize(this); } if (_heartBeatTimer != null) { _heartBeatTimer.Dispose(); } if (_ioStrategy != null) { _ioStrategy.Dispose(); } } } }
public void TestFixtureTearDown() { _ioStrategy.Dispose(); }
public override IConfigInfo GetConfig(string bucketName, string password) { Log.Debug(m => m("Getting config for bucket {0}", bucketName)); var bucketConfiguration = GetOrCreateConfiguration(bucketName); //if the client is using a password make sure the client configuration references it password = string.IsNullOrEmpty(password) ? bucketConfiguration.Password : password; if (string.IsNullOrEmpty(bucketConfiguration.Password)) { bucketConfiguration.Password = password; } var exceptions = new List <Exception>(); CouchbaseConfigContext configInfo = null; foreach (var endPoint in bucketConfiguration.GetEndPoints()) { Log.Debug(m => m("Bootstrapping with {0}", endPoint)); IOStrategy ioStrategy = null; try { var connectionPool = ConnectionPoolFactory(bucketConfiguration.PoolConfiguration, endPoint); ioStrategy = IOStrategyFactory(connectionPool); var saslMechanism = SaslFactory(bucketName, password, ioStrategy, Transcoder); ioStrategy.SaslMechanism = saslMechanism; var operationResult = ioStrategy.Execute( new Config(Transcoder, ClientConfig.DefaultOperationLifespan, endPoint)); if (operationResult.Success) { var bucketConfig = operationResult.Value; bucketConfig.SurrogateHost = connectionPool.EndPoint.Address.ToString(); bucketConfig.Password = password; configInfo = new CouchbaseConfigContext(bucketConfig, ClientConfig, IOStrategyFactory, ConnectionPoolFactory, SaslFactory, Transcoder); Log.Info(m => m("{0}", JsonConvert.SerializeObject(bucketConfig))); configInfo.LoadConfig(ioStrategy); Configs[bucketName] = configInfo; break; } var exception = operationResult.Exception; if (exception != null) { exceptions.Add(exception); } //CCCP only supported for Couchbase Buckets if (operationResult.Status == ResponseStatus.UnknownCommand) { throw new ConfigException("{0} is this a Memcached bucket?", operationResult.Value); } Log.Warn(m => m("Could not retrieve configuration for {0}. Reason: {1}", bucketName, operationResult.Message)); } catch (ConfigException) { ioStrategy.Dispose(); Log.Debug(m => m("Bootstrapping with {0} failed.", endPoint)); throw; } catch (AuthenticationException e) { const string msg = "A failure to authenticate may mean that the server has not joined the cluster" + " yet or that the Bucket does not exist. Please check that {0} has joined that" + " cluster and that the Bucket '{1}' exists."; Log.Warn(m => m(msg, endPoint, bucketName)); Log.Warn(e); exceptions.Add(e); } catch (Exception e) { Log.Debug(m => m("Bootstrapping with {0} failed.", endPoint)); Log.Warn(e); exceptions.Add(e); } finally { if (ioStrategy != null && configInfo == null) { ioStrategy.Dispose(); } } } //Client cannot bootstrap with this provider if (configInfo == null) { throw new AggregateException(exceptions); } return(configInfo); }