public MemcachedNode( EndPoint endpoint, ISocketPoolConfiguration socketPoolConfig, ILogger logger) { this.endPoint = endpoint; this.config = socketPoolConfig; if (socketPoolConfig.ConnectionTimeout.TotalMilliseconds >= Int32.MaxValue) { throw new InvalidOperationException("ConnectionTimeout must be < Int32.MaxValue"); } if (socketPoolConfig.InitPoolTimeout.TotalSeconds < 1) { _initPoolTimeout = new TimeSpan(0, 1, 0); } else { _initPoolTimeout = socketPoolConfig.InitPoolTimeout; } _logger = logger; this.internalPoolImpl = new InternalPoolImpl(this, socketPoolConfig, _logger); }
internal InternalPoolImpl(MemcachedNode ownerNode, ISocketPoolConfiguration config) { if (config.MinPoolSize < 0) { throw new InvalidOperationException("Min pool size must be larger >= 0", null); } if (config.MaxPoolSize < config.MinPoolSize) { throw new InvalidOperationException("Max pool size must be larger than min pool size", null); } if (config.QueueTimeout < TimeSpan.Zero) { throw new InvalidOperationException("queueTimeout must be >= TimeSpan.Zero", null); } this._ownerNode = ownerNode; this._endpoint = ownerNode.EndPoint; this._queueTimeout = config.QueueTimeout; this._minItems = config.MinPoolSize; this._maxItems = config.MaxPoolSize; this._semaphore = new Semaphore(this._maxItems, this._maxItems); this._freeItems = new InterlockedStack <PooledSocket>(); this._logger = Logger.CreateLogger <InternalPoolImpl>(); }
public ServerPool(IMemcachedClientConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException("configuration", "Invalid or missing pool configuration. Check if the enyim.com/memcached section or your custom section presents in the app/web.config."); } this.configuration = configuration; this.isAliveTimer = new Timer(callback_isAliveTimer, null, (int)this.configuration.SocketPool.DeadTimeout.TotalMilliseconds, (int)this.configuration.SocketPool.DeadTimeout.TotalMilliseconds); // create the key transformer instance Type t = this.configuration.KeyTransformer; this.keyTransformer = (t == null) ? new DefaultKeyTransformer() : (IMemcachedKeyTransformer)Activator.CreateInstance(t); // create the item transcoder instance t = this.configuration.Transcoder; this.transcoder = (t == null) ? new DefaultTranscoder() : (ITranscoder)Activator.CreateInstance(t); // initialize the server list ISocketPoolConfiguration ispc = configuration.SocketPool; foreach (IPEndPoint ip in configuration.Servers) { this.workingServers.Add(new MemcachedNode(ip, ispc)); } // (re)creates the locator this.RebuildIndexes(); }
private MemcachedClientApiConfiguration( IEnumerable <IPEndPoint> servers, ISocketPoolConfiguration socketPoolConfiguration, IMemcachedKeyTransformer keyTransformer, IMemcachedNodeLocator nodeLocator, Func <IMemcachedNodeLocator> nodeLocatorFactory, ITranscoder transcoder, IAuthenticationConfiguration authentication, MemcachedProtocol protocol, IPerformanceMonitor performanceMonitor) { Condition.Requires(socketPoolConfiguration, "socket pool configuration").IsNotNull(); Condition.Requires(keyTransformer, "key transformer").IsNotNull(); Condition.Requires(transcoder, "transcoder").IsNotNull(); Condition.Requires(authentication, "authentication").IsNotNull(); Condition.Requires(nodeLocator, "node locator") .Evaluate(!(nodeLocator == null && nodeLocatorFactory == null), "Both node locator and node locator factory are not set. Requires only one to be set."); Condition.Requires(nodeLocator, "node locator") .Evaluate(!(nodeLocator == null && nodeLocatorFactory == null), "Both node locator and node locator are set. Requires only one to be set."); Condition.Requires(servers, "servers").IsNotNull(); _socketPoolConfiguration = socketPoolConfiguration; _keyTransformer = keyTransformer; _nodeLocator = nodeLocator; _nodeLocatorFactory = nodeLocatorFactory; _transcoder = transcoder; _authentication = authentication; PerformanceMonitor = performanceMonitor; Protocol = protocol; _servers = servers.ToList(); }
internal InternalPoolImpl(IPEndPoint endpoint, ISocketPoolConfiguration config) { isAlive = true; endPoint = endpoint; this.config = config; minItems = config.MinPoolSize; maxItems = config.MaxPoolSize; if (minItems < 0) { throw new InvalidOperationException("minItems must be larger than 0", null); } if (maxItems < minItems) { throw new InvalidOperationException("maxItems must be larger than minItems", null); } if (this.config.ConnectionTimeout < TimeSpan.Zero) { throw new InvalidOperationException("connectionTimeout must be >= TimeSpan.Zero", null); } freeItems = new InterlockedQueue <PooledSocket>(); itemReleasedEvent = new AutoResetEvent(false); InitPool(); }
internal InternalPoolImpl(MemcachedNode ownerNode, ISocketPoolConfiguration config) { if (config.MinPoolSize < 0) { throw new InvalidOperationException("minItems must be larger >= 0", null); } if (config.MaxPoolSize < config.MinPoolSize) { throw new InvalidOperationException("maxItems must be larger than minItems", null); } if (config.QueueTimeout < TimeSpan.Zero) { throw new InvalidOperationException("queueTimeout must be >= TimeSpan.Zero", null); } this.ownerNode = ownerNode; this.isAlive = true; this.endPoint = ownerNode.EndPoint; this.queueTimeout = config.QueueTimeout; this.minItems = config.MinPoolSize; this.maxItems = config.MaxPoolSize; this.semaphore = new Semaphore(maxItems, maxItems); this.freeItems = new InterlockedStack <PooledSocket>(); }
private MemcachedClientApiConfiguration( IEnumerable<IPEndPoint> servers, ISocketPoolConfiguration socketPoolConfiguration, IMemcachedKeyTransformer keyTransformer, IMemcachedNodeLocator nodeLocator, Func<IMemcachedNodeLocator> nodeLocatorFactory, ITranscoder transcoder, IAuthenticationConfiguration authentication, MemcachedProtocol protocol, IPerformanceMonitor performanceMonitor) { Condition.Requires(socketPoolConfiguration, "socket pool configuration").IsNotNull(); Condition.Requires(keyTransformer, "key transformer").IsNotNull(); Condition.Requires(transcoder, "transcoder").IsNotNull(); Condition.Requires(authentication, "authentication").IsNotNull(); Condition.Requires(nodeLocator, "node locator") .Evaluate(!(nodeLocator == null && nodeLocatorFactory == null), "Both node locator and node locator factory are not set. Requires only one to be set."); Condition.Requires(nodeLocator, "node locator") .Evaluate(!(nodeLocator == null && nodeLocatorFactory == null), "Both node locator and node locator are set. Requires only one to be set."); Condition.Requires(servers, "servers").IsNotNull(); _socketPoolConfiguration = socketPoolConfiguration; _keyTransformer = keyTransformer; _nodeLocator = nodeLocator; _nodeLocatorFactory = nodeLocatorFactory; _transcoder = transcoder; _authentication = authentication; PerformanceMonitor = performanceMonitor; Protocol = protocol; _servers = servers.ToList(); }
/// <summary> /// Initializes a new instance of the <see cref="T:MemcachedClientConfiguration"/> class. /// </summary> public MemcachedClientConfiguration() { this.servers = new List<IPEndPoint>(); this.socketPool = new _SocketPoolConfig(); this.EnablePerformanceCounters = false; }
internal InternalPoolImpl( MemcachedNode ownerNode, ISocketPoolConfiguration config, ILogger logger) { if (config.MinPoolSize < 0) { throw new InvalidOperationException("minItems must be larger >= 0", null); } if (config.MaxPoolSize < config.MinPoolSize) { throw new InvalidOperationException("maxItems must be larger than minItems", null); } if (config.QueueTimeout < TimeSpan.Zero) { throw new InvalidOperationException("queueTimeout must be >= TimeSpan.Zero", null); } this.ownerNode = ownerNode; this.isAlive = true; _endPoint = ownerNode.EndPoint; this.queueTimeout = config.QueueTimeout; this.minItems = config.MinPoolSize; this.maxItems = config.MaxPoolSize; _semaphore = new SemaphoreSlim(maxItems, maxItems); _freeItems = new InterlockedStack <PooledSocket>(); _logger = logger; _isDebugEnabled = _logger.IsEnabled(LogLevel.Debug); }
public IMemcachedNode CreateNode(IPEndPoint endpoint, ISocketPoolConfiguration config) { #if CORE_CLR return(new MemcachedNode(endpoint, config, logger)); #else return(new MemcachedNode(endpoint, config)); #endif }
public SPC(ISocketPoolConfiguration original) { this.connectionTimeout = original.ConnectionTimeout; this.deadTimeout = original.DeadTimeout; this.maxPoolSize = original.MaxPoolSize; this.minPoolSize = original.MinPoolSize; this.queueTimeout = original.QueueTimeout; this.receiveTimeout = original.ReceiveTimeout; this.fpf = original.FailurePolicyFactory; }
public BinaryNode( DnsEndPoint endpoint, ISocketPoolConfiguration config, ISaslAuthenticationProvider authenticationProvider, ILogger logger) : base(endpoint, config, logger) { this.authenticationProvider = authenticationProvider; _logger = logger; }
private static ISocketPoolConfiguration CopySocketPool(ISocketPoolConfiguration source) { var socketPool = (ISocketPoolConfiguration) new SocketPoolConfiguration(); socketPool.ConnectionTimeout = source.ConnectionTimeout; socketPool.DeadTimeout = source.DeadTimeout; socketPool.MaxPoolSize = source.MaxPoolSize; socketPool.MinPoolSize = source.MinPoolSize; socketPool.QueueTimeout = source.QueueTimeout; socketPool.ReceiveTimeout = source.ReceiveTimeout; return(socketPool); }
public MemcachedNode(IPEndPoint endpoint, ISocketPoolConfiguration socketPoolConfig) { this.endPoint = endpoint; this.config = socketPoolConfig; if (socketPoolConfig.ConnectionTimeout.TotalMilliseconds >= Int32.MaxValue) { throw new InvalidOperationException("ConnectionTimeout must be < Int32.MaxValue"); } this.internalPoolImpl = new InternalPoolImpl(this, socketPoolConfig); }
public MemcachedNode(EndPoint endpoint, ISocketPoolConfiguration config) { if (config.ConnectionTimeout.TotalMilliseconds >= Int32.MaxValue) { throw new InvalidOperationException($"ConnectionTimeout must be < {Int32.MaxValue}"); } this._logger = Logger.CreateLogger <IMemcachedNode>(); this._endpoint = endpoint; this._config = config; this._internalPoolImpl = new InternalPoolImpl(this, this._config); }
internal MemcachedNode(IPEndPoint endpoint, ISocketPoolConfiguration config) { endPoint = endpoint; this.config = config; internalPoolImpl = new InternalPoolImpl(endpoint, config); deadTimeout = (int)config.DeadTimeout.TotalSeconds; if (deadTimeout < 0) { throw new InvalidOperationException("deadTimeout must be >= TimeSpan.Zero"); } }
public ReadOnlyConfig(IMembaseClientConfiguration original) { this.bucket = original.Bucket; this.bucketPassword = original.BucketPassword; this.urls = original.Urls.ToArray(); this.retryCount = original.RetryCount; this.retryTimeout = original.RetryTimeout; this.spc = new SPC(original.SocketPool); this.original = original; }
public SocketPool(IMemcachedNode node, ISocketPoolConfiguration config, ISaslAuthenticationProvider provider) { if (config.MinPoolSize < 0) throw new InvalidOperationException("MinPoolSize must be larger >= 0", null); if (config.MaxPoolSize < config.MinPoolSize) throw new InvalidOperationException("MaxPoolSize must be larger than MinPoolSize", null); if (config.QueueTimeout < TimeSpan.Zero) throw new InvalidOperationException("queueTimeout must be >= TimeSpan.Zero", null); _provider = provider; _node = node; _config = config; _queue = new Queue<IPooledSocket>(config.MaxPoolSize); _isAlive = true; PreAllocate(config.MinPoolSize); }
public ReadOnlyConfig(ICouchbaseClientConfiguration original) { this.bucket = original.Bucket; this.bucketPassword = original.BucketPassword; this.username = original.Username; this.password = original.Password; this.urls = original.Urls.ToArray(); this.retryCount = original.RetryCount; this.retryTimeout = original.RetryTimeout; this.observeTimeout = original.ObserveTimeout; this.spc = new SPC(original.SocketPool); this.hbm = new HBM(original.HeartbeatMonitor); this.original = original; }
public SocketPool(IMemcachedNode node, ISocketPoolConfiguration config, ISaslAuthenticationProvider provider) { if (config.MinPoolSize < 0) { throw new InvalidOperationException("MinPoolSize must be larger >= 0", null); } if (config.MaxPoolSize < config.MinPoolSize) { throw new InvalidOperationException("MaxPoolSize must be larger than MinPoolSize", null); } if (config.QueueTimeout < TimeSpan.Zero) { throw new InvalidOperationException("queueTimeout must be >= TimeSpan.Zero", null); } _provider = provider; _node = node; _config = config; _queue = new Queue <IPooledSocket>(config.MaxPoolSize); _isAlive = true; PreAllocate(config.MinPoolSize); }
public CouchbaseNode(IPEndPoint endpoint, ISocketPoolConfiguration config) { _endpoint = endpoint; _pool = new SocketPool(this, config); }
public CouchbaseNode(IPEndPoint endpoint, ISocketPoolConfiguration config, ISaslAuthenticationProvider provider) { _endpoint = endpoint; _pool = new SocketPool(this, config, provider); }
public BinaryNode(IPEndPoint endpoint, ISocketPoolConfiguration config, ISaslAuthenticationProvider authenticationProvider) : base(endpoint, config) { this.authenticationProvider = authenticationProvider; }
public IMemcachedNode CreateNode(EndPoint endpoint, ISocketPoolConfiguration config) { return(new MemcachedNode(endpoint, config, _logger)); }
public ReadOnlyConfig(ICouchbaseClientConfiguration original) { this.bucket = original.Bucket; this.bucketPassword = original.BucketPassword; this.username = original.Username; this.password = original.Password; this.urls = original.Urls.ToArray(); this.retryCount = original.RetryCount; this.retryTimeout = original.RetryTimeout; this.observeTimeout = original.ObserveTimeout; this.httpRequestTimeout = original.HttpRequestTimeout; this.spc = new SPC(original.SocketPool); this.hbm = new HBM(original.HeartbeatMonitor); this.hcc = new HCC(original.HttpClient); this.original = original; _vBucketRetryCount = original.VBucketRetryCount; }
/// <summary> /// Initializes a new instance of the <see cref="T:Guanima.Redis.Configuration.RedisClientConfiguration"/> class. /// </summary> public RedisClientConfiguration() { _socketPool = new SocketPoolConfiguration(); _authentication = new AuthenticationConfiguration(); _servers = new List<IEndPointConfiguration>(); }
public SocketPool(IMemcachedNode node, ISocketPoolConfiguration config) : this(node, config, null) { }
public IMemcachedNode CreateNode(EndPoint endpoint, ISocketPoolConfiguration config, ILoggerFactory loggerFactory) { node.EndPoint = endpoint; return(node); }
public ReadOnlyConfig(ICouchbaseClientConfiguration original) { this.bucket = original.Bucket; this.bucketPassword = original.BucketPassword; this.urls = original.Urls.ToArray(); this.retryCount = original.RetryCount; this.retryTimeout = original.RetryTimeout; this.spc = new SPC(original.SocketPool); this.hbm = new HBM(original.HeartbeatMonitor); this.original = original; }
private static ISocketPoolConfiguration CopySocketPool(ISocketPoolConfiguration source) { var socketPool = (ISocketPoolConfiguration) new SocketPoolConfiguration(); socketPool.ConnectionTimeout = source.ConnectionTimeout; socketPool.DeadTimeout = source.DeadTimeout; socketPool.MaxPoolSize = source.MaxPoolSize; socketPool.MinPoolSize = source.MinPoolSize; socketPool.QueueTimeout = source.QueueTimeout; socketPool.ReceiveTimeout = source.ReceiveTimeout; return socketPool; }
public CustomBinaryNode(IPEndPoint endpoint, ISocketPoolConfiguration config, ISaslAuthenticationProvider authenticationProvider) : base(endpoint, config, authenticationProvider) { }
public IMemcachedNode CreateNode(DnsEndPoint endpoint, ISocketPoolConfiguration config, ILoggerFactory loggerFactory) { return(new MemcachedNode(endpoint, config, loggerFactory.CreateLogger <MemcachedNode>())); }
public SPC(ISocketPoolConfiguration original) { this.connectionTimeout = original.ConnectionTimeout; this.deadTimeout = original.DeadTimeout; this.maxPoolSize = original.MaxPoolSize; this.minPoolSize = original.MinPoolSize; this.queueTimeout = original.QueueTimeout; this.receiveTimeout = original.ReceiveTimeout; this.fpf = original.FailurePolicyFactory; _lingerTime = original.LingerTime; _lingerEnabled = original.LingerEnabled; }
public BinaryNode(EndPoint endpoint, ISocketPoolConfiguration config, ISaslAuthenticationProvider authenticationProvider) : base(endpoint, config) { this._authenticationProvider = authenticationProvider; this._logger = Logger.CreateLogger <BinaryNode>(); }
/// <summary> /// Initializes a new instance of the <see cref="T:MemcachedClientConfiguration"/> class. /// </summary> public MemcachedClientConfiguration() { this.servers = new List <IPEndPoint>(); this.socketPool = new _SocketPoolConfig(); }
/// <summary> /// Initializes a new instance of the <see cref="T:MemcachedClientConfiguration"/> class. /// </summary> public MemcachedClientConfiguration() { this.servers = new List<IPEndPoint>(); this.socketPool = new _SocketPoolConfig(); }