private void Worker(object state) { if (log.IsDebugEnabled) log.Debug("Started working."); while (this.stopCounter == 0) { if (this.client == null) this.client = this.CreateClient(); // false means that the url was not responding or failed while reading this.statusPool = this.urls.ToDictionary(u => u, u => true); this.urlIndex = 0; // this will quit when all nodes go down or we're stopped externally this.ProcessPool(); // sockIOPool fail if (this.stopCounter == 0) { if (log.IsWarnEnabled) log.Warn("All nodes are dead, sleeping for a while."); this.Trigger(null); this.SleepUntil(this.DeadTimeout); // recreate the memcachedClient after failure this.CleanupRequests(); if (this.client != null) { this.client.Dispose(); this.client = null; } } } }
protected void Dispose() { AppDomain.CurrentDomain.DomainUnload -= CurrentDomain_DomainUnload; this.CleanupRequests(); if (this.client != null) { using (this.client) this.client.CancelAsync(); this.client = null; } }
private static Uri ResolveBucketUri(WebClientWithTimeout client, Uri root, string bucketName) { try { var bucket = ConfigHelper.ResolveBucket(client, root, bucketName); if (bucket == null) return null; if (String.IsNullOrEmpty(bucket.streamingUri)) { log.ErrorFormat("Url {0} for bucket {1} returned a config with no streamingUri", root, bucketName); return null; } return new Uri(root, bucket.streamingUri); } catch (Exception e) { log.Error("Error resolving streaming uri: " + root, e); return null; } }