/// <summary> /// The node used to discover endpoints in an ElastiCache cluster /// </summary> /// <param name="config">The config of the client to access the SocketPool</param> /// <param name="hostname">The host name of the cluster with .cfg. in name</param> /// <param name="port">The port of the cluster</param> /// <param name="tries">The number of tries for requesting config info</param> /// <param name="delay">The time, in miliseconds, to wait between tries</param> internal DiscoveryNode(ElastiCacheClusterConfig config, string hostname, int port, int tries, int delay) { #region Param Checks if (config == null) { throw new ArgumentNullException("config"); } if (string.IsNullOrEmpty(hostname)) { throw new ArgumentNullException("hostname"); } if (port <= 0) { throw new ArgumentException("Port cannot be 0 or less"); } if (tries < 1) { throw new ArgumentException("Must atleast try once"); } if (delay < 0) { throw new ArgumentException("The delay can't be negative"); } if (hostname.IndexOf(".cfg", StringComparison.OrdinalIgnoreCase) < 0) { throw new ArgumentException("The hostname is not able to use Auto Discovery"); } #endregion #region Setting Members this.hostname = hostname; this.port = port; this.config = config; this.ClusterVersion = 0; this.tries = tries; this.delay = delay; this.clusterLock = new Object(); this.endpointLock = new Object(); this.nodesLock = new Object(); #endregion this.ResolveEndPoint(); }
/// <summary> /// The node used to discover endpoints in an ElastiCache cluster /// </summary> /// <param name="config">The config of the client to access the SocketPool</param> /// <param name="hostname">The host name of the cluster with .cfg. in name</param> /// <param name="port">The port of the cluster</param> /// <param name="tries">The number of tries for requesting config info</param> /// <param name="delay">The time, in miliseconds, to wait between tries</param> internal DiscoveryNode(ElastiCacheClusterConfig config, string hostname, int port, int tries = DefaultTryCount, int delay = DefaultTryDelay) { #region Param Checks if (string.IsNullOrEmpty(hostname)) { throw new ArgumentNullException(nameof(hostname)); } if (port <= 0) { throw new ArgumentException("Port cannot be 0 or less"); } if (tries < 1) { throw new ArgumentException("Must atleast try once"); } if (delay < 0) { throw new ArgumentException("The delay can't be negative"); } if (hostname.IndexOf(".cfg", StringComparison.OrdinalIgnoreCase) < 0) { throw new ArgumentException("The hostname is not able to use Auto Discovery"); } #endregion #region Setting Members _hostname = hostname; _port = port; _config = config ?? throw new ArgumentNullException(nameof(config)); ClusterVersion = 0; _tries = tries; _delay = delay; _log = config.LoggerFactory.CreateLogger <DiscoveryNode>(); _clusterLock = new object(); _endpointLock = new object(); _nodesLock = new object(); #endregion ResolveEndPoint(); }
/// <summary> /// Creates a MemcachedClient using the Client config provided /// </summary> /// <param name="config">The config to instantiate the client with</param> /// <returns>A new MemcachedClient configured for auto discovery</returns> public static MemcachedClient CreateClient(ElastiCacheClusterConfig config) { return(new MemcachedClient(config)); }
/// <summary> /// The node used to discover endpoints in an ElastiCache cluster /// </summary> /// <param name="config">The config of the client to access the SocketPool</param> /// <param name="hostname">The host name of the cluster with .cfg. in name</param> /// <param name="port">The port of the cluster</param> internal DiscoveryNode(ElastiCacheClusterConfig config, string hostname, int port) : this(config, hostname, port, DEFAULT_TRY_COUNT, DEFAULT_TRY_DELAY) { }
/// <summary> /// Creates a poller for Auto Discovery with the defined itnerval, delay, tries, and try delay for polling /// </summary> /// <param name="client">The memcached client to update servers for</param> /// <param name="intervalDelay">The amount of time between polling operations in miliseconds</param> public ConfigurationPoller(ElastiCacheClusterConfig config, int intervalDelay) { this.intervalDelay = intervalDelay < 0 ? DEFAULT_INTERVAL_DELAY : intervalDelay; this.config = config; }
/// <summary> /// Creates a poller for Auto Discovery with the default intervals /// </summary> /// <param name="client">The memcached client to update servers for</param> public ConfigurationPoller(ElastiCacheClusterConfig config) : this(config, DEFAULT_INTERVAL_DELAY) { }
/// <summary> /// Creates a poller for Auto Discovery with the default intervals /// </summary> /// <param name="config">The cluster config to update servers for</param> public ConfigurationPoller(ElastiCacheClusterConfig config) : this(config, DefaultIntervalDelay) { }
/// <summary> /// Creates a MemcachedClient using the Client config provided /// </summary> /// <param name="config">The config to instantiate the client with</param> /// <returns>A new MemcachedClient configured for auto discovery</returns> #if CORE_CLR public static MemcachedClient CreateClient(ElastiCacheClusterConfig config, ILogger <MemcachedClient> logger = null) { return(new MemcachedClient(logger ?? NullLogger <MemcachedClient> .Instance, config)); }
/// <summary> /// Creates a MemcachedClient using the Client config provided /// </summary> /// <param name="loggerFactory">The factory to create the each class'es logger</param> /// <param name="config">The config to instantiate the client with</param> /// <returns>A new MemcachedClient configured for auto discovery</returns> public static MemcachedClient CreateClient(ILoggerFactory loggerFactory, ElastiCacheClusterConfig config) { return(new MemcachedClient(loggerFactory, config)); }