private InternalState InitBasic(ClusterConfig config, ISaslAuthenticationProvider auth) { if (log.IsInfoEnabled) { log.Info("No vbucket. Server count: " + (config.nodes == null ? 0 : config.nodes.Length)); } // no vbucket config, use the node list and the ports var portType = this.configuration.Port; var tmp = config == null ? Enumerable.Empty <IMemcachedNode>() : (from node in config.nodes let ip = new IPEndPoint(IPAddress.Parse(node.hostname), (portType == BucketPortType.Proxy ? node.ports.proxy : node.ports.direct)) where node.status == "healthy" select(IMemcachedNode)(new BinaryNode(ip, this.configuration.SocketPool, auth))); return(new InternalState { CurrentNodes = tmp.ToArray(), Locator = this.configuration.CreateNodeLocator() ?? new KetamaNodeLocator(), OpFactory = new Enyim.Caching.Memcached.Protocol.Binary.BinaryOperationFactory() }); }
public BinaryPool(IMemcachedClientConfiguration configuration, ILogger logger) : base(configuration, new BinaryOperationFactory(logger), logger) { this.authenticationProvider = GetProvider(configuration); this.configuration = configuration; _logger = logger; }
public BinaryPool(IMemcachedClientConfiguration configuration) : base(configuration, new BinaryOperationFactory()) { this._configuration = configuration; this._authenticationProvider = configuration.Authentication != null && !string.IsNullOrWhiteSpace(configuration.Authentication.Type) ? FastActivator.Create(configuration.Authentication.Type) as ISaslAuthenticationProvider : null; this._authenticationProvider?.Initialize(configuration.Authentication.Parameters); }
public AutoBinaryPool(IMemcachedClientConfiguration configuration, ILoggerFactory loggerFactory) : base(configuration, new BinaryOperationFactory(loggerFactory.CreateLogger <BinaryOperationFactory>()), loggerFactory) { _authenticationProvider = GetProvider(configuration); _configuration = configuration; _loggerFactory = loggerFactory; }
public CouchbaseNode(IPEndPoint endpoint, Uri couchApiBase, ICouchbaseClientConfiguration config, ISaslAuthenticationProvider authenticationProvider) : base(endpoint, config.SocketPool, authenticationProvider) { var ub = new UriBuilder(couchApiBase); ub.Path = System.IO.Path.Combine(ub.Path, "_design"); this.Client = config.CreateHttpClient(ub.Uri); this.Client.RetryCount = config.RetryCount; }
protected override IMemcachedNode CreateNode(IPEndPoint endpoint, ISaslAuthenticationProvider auth, Dictionary<string, object> nodeInfo) { string couchApiBase; if (!nodeInfo.TryGetValue("couchApiBase", out couchApiBase) || String.IsNullOrEmpty(couchApiBase)) throw new InvalidOperationException("The node configuration does not contain the required 'couchApiBase' attribute."); return new CouchbaseNode(endpoint, new Uri(couchApiBase), this.configuration, auth); }
public BinaryNode( DnsEndPoint endpoint, ISocketPoolConfiguration config, ISaslAuthenticationProvider authenticationProvider, ILogger logger) : base(endpoint, config, logger) { this.authenticationProvider = authenticationProvider; _logger = logger; }
private InternalState InitVBucket(ClusterConfig config, ISaslAuthenticationProvider auth) { // we have a vbucket config, which has its own server list // it's supposed to be the same as the cluster config's list, // but the order is significicant (because of the bucket indexes), // so we we'll use this for initializing the locator var vbsm = config.vBucketServerMap; if (log.IsInfoEnabled) { log.Info("Has vbucket. Server count: " + (vbsm.serverList == null ? 0 : vbsm.serverList.Length)); } var epa = (from server in vbsm.serverList select ConfigurationHelper.ResolveToEndPoint(server)).ToArray(); var epaLength = epa.Length; for (var i = 0; i < vbsm.vBucketMap.Length; i++) { var vb = vbsm.vBucketMap[i]; if (vb == null || vb.Length == 0) { throw new InvalidOperationException("Server sent an empty vbucket definition at index " + i); } if (vb[0] >= epaLength || vb[0] < 0) { throw new InvalidOperationException(String.Format("VBucket line {0} has a master index {1} out of range of the server list ({2})", i, vb[0], epaLength)); } } var buckets = vbsm.vBucketMap.Select(a => new VBucket(a[0], a.Skip(1).ToArray())).ToArray(); var bucketNodeMap = buckets.ToLookup(vb => { try { return(epa[vb.Master]); } catch (Exception e) { log.Error(e); throw; } } ); var vbnl = new VBucketNodeLocator(vbsm.hashAlgorithm, buckets); return(new InternalState { CurrentNodes = epa.Select(ip => (IMemcachedNode) new BinaryNode(ip, this.configuration.SocketPool, auth)).ToArray(), Locator = vbnl, OpFactory = new VBucketAwareOperationFactory(vbnl) }); }
protected IMemcachedNode CreateNode(IPEndPoint endpoint, ISaslAuthenticationProvider auth, Dictionary <string, object> nodeInfo) { string couchApiBase; if (!nodeInfo.TryGetValue("couchApiBase", out couchApiBase) || String.IsNullOrEmpty(couchApiBase)) { return(new BinaryNode(endpoint, this.configuration.SocketPool, auth)); } return(new CouchbaseNode(endpoint, new Uri(couchApiBase), this.configuration, auth)); }
public CouchbaseNode(IPEndPoint endpoint, Uri couchApiBase, ICouchbaseClientConfiguration config, ISaslAuthenticationProvider provider) { var uriBuilder = new UriBuilder(couchApiBase); uriBuilder.Path = Path.Combine(uriBuilder.Path, "_design"); _config = config; _client = config.CreateHttpClient(uriBuilder.Uri); _client.RetryCount = config.RetryCount; _endpoint = endpoint; _pool = new SocketPool(this, config.SocketPool, provider); }
private InternalState InitVBucket(ClusterConfig config, ISaslAuthenticationProvider auth) { // we have a vbucket config, which has its own server list // it's supposed to be the same as the cluster config's list, // but the order is significicant (because of the bucket indexes), // so we we'll use this for initializing the locator var vbsm = config.vBucketServerMap; if (log.IsInfoEnabled) { log.Info("Has vbucket. Server count: " + (vbsm.serverList == null ? 0 : vbsm.serverList.Length)); } // parse the ip addresses of the servers in the vbucket map // make sure we have a proper vbucket map ValidateVBucketMap(vbsm, vbsm.serverList.Length); // create vbuckets from the int[][] arrays int i = 0; var buckets = vbsm.vBucketMap.Select(a => new VBucket(a[0], a.Skip(1).ToArray(), i++)).ToArray(); var locator = new VBucketNodeLocator(vbsm.hashAlgorithm, buckets); // create a (host=>node) lookup from the node info objects, // so we can pass the extra config data to the factory method // (the vbucket map only contains 'host:port' strings) // this expects that all nodes listed in the vbucket map are listed in the config.nodes member as well var realNodes = config.nodes.ToDictionary(node => node.HostName + ":" + node.Port); var nodes = new List <IMemcachedNode>(); foreach (var hostSpec in vbsm.serverList) { ClusterNode node; if (!realNodes.TryGetValue(hostSpec, out node)) { throw new InvalidOperationException(String.Format("VBucket map contains a node {0} whihc was not found in the cluster info's node list.", hostSpec)); } var ip = GetFirstAddress(node.HostName); var endpoint = new IPEndPoint(ip, node.Port); nodes.Add(this.CreateNode(endpoint, auth, node.ConfigurationData)); } return(new InternalState { CurrentNodes = nodes.ToArray(), Locator = locator, OpFactory = new VBucketAwareOperationFactory(locator), IsVbucket = true }); }
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 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); }
private InternalState InitBasic(ClusterConfig config, ISaslAuthenticationProvider auth) { if (log.IsInfoEnabled) { log.Info("No vbucket. Server count: " + (config.nodes == null ? 0 : config.nodes.Length)); } // the cluster can return host names in the server list, so // we ha ve to make sure they are converted to IP addresses var nodes = config == null ? Enumerable.Empty <IMemcachedNode>() : (from node in config.nodes let ip = new IPEndPoint(GetFirstAddress(node.HostName), node.Port) where node.Status == "healthy" select CreateNode(ip, auth, node.ConfigurationData)); return(new InternalState { CurrentNodes = nodes.ToArray(), Locator = configuration.CreateNodeLocator() ?? new KetamaNodeLocator(), OpFactory = BasicMembaseOperationFactory.Instance }); }
protected virtual IMemcachedNode CreateNode(IPEndPoint endpoint, ISaslAuthenticationProvider auth, Dictionary<string, object> nodeInfo) { return new BinaryNode(endpoint, this.configuration.SocketPool, auth); }
public BinaryNode(IPEndPoint endpoint, ISocketPoolConfiguration config, ISaslAuthenticationProvider authenticationProvider) : base(endpoint, config) { this.authenticationProvider = authenticationProvider; }
protected virtual IMemcachedNode CreateNode(IPEndPoint endpoint, ISaslAuthenticationProvider auth, Dictionary <string, object> nodeInfo) { return(new BinaryNode(endpoint, this.configuration.SocketPool, auth)); }
private InternalState InitBasic(ClusterConfig config, ISaslAuthenticationProvider auth) { if (log.IsInfoEnabled) log.Info("No vbucket. Server count: " + (config.nodes == null ? 0 : config.nodes.Length)); // the cluster can return host names in the server list, so // we ha ve to make sure they are converted to IP addresses var nodes = config == null ? Enumerable.Empty<IMemcachedNode>() : (from node in config.nodes let ip = new IPEndPoint(GetFirstAddress(node.HostName), node.Port) where node.Status == "healthy" select CreateNode(ip, auth, node.ConfigurationData)); return new InternalState { CurrentNodes = nodes.ToArray(), Locator = configuration.CreateNodeLocator() ?? new KetamaNodeLocator(), OpFactory = BasicCouchbaseOperationFactory.Instance }; }
protected SaslStep(ISaslAuthenticationProvider provider) { this.Provider = provider; }
public SaslStart(ISaslAuthenticationProvider provider) : base(provider) { }
public SaslStart(ISaslAuthenticationProvider provider) : base(provider) { }
public BinaryNode(EndPoint endpoint, ISocketPoolConfiguration config, ISaslAuthenticationProvider authenticationProvider) : base(endpoint, config) { this._authenticationProvider = authenticationProvider; this._logger = Logger.CreateLogger <BinaryNode>(); }
private InternalState InitVBucket(ClusterConfig config, ISaslAuthenticationProvider auth) { // we have a vbucket config, which has its own server list // it's supposed to be the same as the cluster config's list, // but the order is significicant (because of the bucket indexes), // so we we'll use this for initializing the locator var vbsm = config.vBucketServerMap; if (log.IsInfoEnabled) log.Info("Has vbucket. Server count: " + (vbsm.serverList == null ? 0 : vbsm.serverList.Length)); var epa = (from server in vbsm.serverList select ConfigurationHelper.ResolveToEndPoint(server)).ToArray(); var epaLength = epa.Length; for (var i = 0; i < vbsm.vBucketMap.Length; i++) { var vb = vbsm.vBucketMap[i]; if (vb == null || vb.Length == 0) throw new InvalidOperationException("Server sent an empty vbucket definition at index " + i); if (vb[0] >= epaLength || vb[0] < 0) throw new InvalidOperationException(String.Format("VBucket line {0} has a master index {1} out of range of the server list ({2})", i, vb[0], epaLength)); } var buckets = vbsm.vBucketMap.Select(a => new VBucket(a[0], a.Skip(1).ToArray())).ToArray(); var bucketNodeMap = buckets.ToLookup(vb => { try { return epa[vb.Master]; } catch (Exception e) { log.Error(e); throw; } } ); var vbnl = new VBucketNodeLocator(vbsm.hashAlgorithm, buckets); return new InternalState { CurrentNodes = epa.Select(ip => (IMemcachedNode)new BinaryNode(ip, this.configuration.SocketPool, auth)).ToArray(), Locator = vbnl, OpFactory = new VBucketAwareOperationFactory(vbnl) }; }
public CouchbaseNode(IPEndPoint endpoint, Uri couchApiBase, ICouchbaseClientConfiguration config, ISaslAuthenticationProvider provider) { var uriBuilder = new UriBuilder(couchApiBase); uriBuilder.Path = Path.Combine(uriBuilder.Path, "_design"); _config = config; _client = config.CreateHttpClient(uriBuilder.Uri); _client.RetryCount = config.RetryCount; _endpoint = endpoint; _pool = new SocketPool(this, config.SocketPool, provider); }
private InternalState InitVBucket(ClusterConfig config, ISaslAuthenticationProvider auth) { // we have a vbucket config, which has its own server list // it's supposed to be the same as the cluster config's list, // but the order is significicant (because of the bucket indexes), // so we we'll use this for initializing the locator var vbsm = config.vBucketServerMap; if (log.IsInfoEnabled) log.Info("Has vbucket. Server count: " + (vbsm.serverList == null ? 0 : vbsm.serverList.Length)); // parse the ip addresses of the servers in the vbucket map // make sure we have a propert vbucket map ValidateVBucketMap(vbsm, vbsm.serverList.Length); // create vbuckets from the int[][] arrays var buckets = vbsm.vBucketMap.Select(a => new VBucket(a[0], a.Skip(1).ToArray())).ToArray(); var locator = new VBucketNodeLocator(vbsm.hashAlgorithm, buckets); // create a (host=>node) lookup from the node info objects, // so we can pass the extra config data to the factory method // (the vbucket map only contains 'host:port' strings) // this expects that all nodes listed in the vbucket map are listed in the config.nodes member as well var realNodes = config.nodes.ToDictionary(node => node.HostName + ":" + node.Port); var nodes = new List<IMemcachedNode>(); foreach (var hostSpec in vbsm.serverList) { ClusterNode node; if (!realNodes.TryGetValue(hostSpec, out node)) throw new InvalidOperationException(String.Format("VBucket map contains a node {0} whihc was not found in the cluster info's node list.", hostSpec)); var ip = GetFirstAddress(node.HostName); var endpoint = new IPEndPoint(ip, node.Port); nodes.Add(this.CreateNode(endpoint, auth, node.ConfigurationData)); } return new InternalState { CurrentNodes = nodes.ToArray(), Locator = locator, OpFactory = new VBucketAwareOperationFactory(locator), IsVbucket = true }; }
public CouchbaseNode(IPEndPoint endpoint, ISocketPoolConfiguration config, ISaslAuthenticationProvider provider) { _endpoint = endpoint; _pool = new SocketPool(this, config, provider); }
public BinaryPool(IMemcachedClientConfiguration configuration) : base(configuration, new BinaryOperationFactory()) { this.authenticationProvider = GetProvider(configuration); this.configuration = configuration; }
public CustomBinaryPool(IMemcachedClientConfiguration configuration) : base(configuration, new BinaryOperationFactory()) { this.authenticationProvider = GetProvider(configuration); this.configuration = configuration; }
protected IMemcachedNode CreateNode(IPEndPoint endpoint, ISaslAuthenticationProvider auth, Dictionary<string, object> nodeInfo) { log.WarnFormat("Creating node {0}", this); string couchApiBase; if (!nodeInfo.TryGetValue("couchApiBase", out couchApiBase) || String.IsNullOrEmpty(couchApiBase)) { return new CouchbaseNode(endpoint, configuration.SocketPool, auth); } return new CouchbaseNode(endpoint, new Uri(couchApiBase), this.configuration, auth); }
protected SaslStep(ISaslAuthenticationProvider provider) { this.Provider = provider; }
public CouchbaseNode(IPEndPoint endpoint, ISocketPoolConfiguration config, ISaslAuthenticationProvider provider) { _endpoint = endpoint; _pool = new SocketPool(this, config, provider); }
public SaslContinue(ISaslAuthenticationProvider provider, byte[] continuation) : base(provider) { this.continuation = continuation; }
public CouchbaseNode(IPEndPoint endpoint, Uri couchApiBase, ICouchbaseClientConfiguration config, ISaslAuthenticationProvider authenticationProvider) : base(endpoint, config.SocketPool, authenticationProvider) { var ub = new UriBuilder(couchApiBase); ub.Path = System.IO.Path.Combine(ub.Path, "_design"); this.Client = config.CreateHttpClient(ub.Uri); this.Client.RetryCount = config.RetryCount; }
private InternalState InitBasic(ClusterConfig config, ISaslAuthenticationProvider auth) { if (log.IsInfoEnabled) log.Info("No vbucket. Server count: " + (config.nodes == null ? 0 : config.nodes.Length)); // no vbucket config, use the node list and the ports var portType = this.configuration.Port; var tmp = config == null ? Enumerable.Empty<IMemcachedNode>() : (from node in config.nodes let ip = new IPEndPoint(IPAddress.Parse(node.hostname), (portType == BucketPortType.Proxy ? node.ports.proxy : node.ports.direct)) where node.status == "healthy" select (IMemcachedNode)(new BinaryNode(ip, this.configuration.SocketPool, auth))); return new InternalState { CurrentNodes = tmp.ToArray(), Locator = this.configuration.CreateNodeLocator() ?? new KetamaNodeLocator(), OpFactory = new Enyim.Caching.Memcached.Protocol.Binary.BinaryOperationFactory() }; }
public CustomBinaryNode(IPEndPoint endpoint, ISocketPoolConfiguration config, ISaslAuthenticationProvider authenticationProvider) : base(endpoint, config, authenticationProvider) { }
public BinaryNode(IPEndPoint endpoint, ISocketPoolConfiguration config, ISaslAuthenticationProvider authenticationProvider) : base(endpoint, config) { this.authenticationProvider = authenticationProvider; }
public SaslContinue(ISaslAuthenticationProvider provider, byte[] continuation) : base(provider) { this.continuation = continuation; }