public IDistributedHashTableStorage Create(NodeEndpoint endpoint) { PooledDistributedHashTableStorageClientConnection storage = null; lock (locker) { LinkedList <PooledDistributedHashTableStorageClientConnection> value; if (pooledConnections.TryGetValue(endpoint, out value) && value.Count > 0) { storage = value.First.Value; value.RemoveFirst(); } } if (storage != null) { if (storage.Connected == false) { log.DebugFormat("Found unconnected connection in the pool for {0}", endpoint.Sync); try { storage.Dispose(); } catch (Exception e) { log.Debug("Error when disposing unconnected connection in the pool", e); } } else { return(storage); } } log.DebugFormat("Creating new connection in the pool to {0}", endpoint.Sync); return(new PooledDistributedHashTableStorageClientConnection(this, endpoint)); }
private void PutMeBack(PooledDistributedHashTableStorageClientConnection connection) { lock (locker) { LinkedList <PooledDistributedHashTableStorageClientConnection> value; if (pooledConnections.TryGetValue(connection.Endpoint, out value) == false) { pooledConnections[connection.Endpoint] = value = new LinkedList <PooledDistributedHashTableStorageClientConnection>(); } value.AddLast(connection); } log.DebugFormat("Put connection for {0} back in the pool", connection.Endpoint.Sync); }
private void PutMeBack(PooledDistributedHashTableStorageClientConnection connection) { lock (locker) { LinkedList<PooledDistributedHashTableStorageClientConnection> value; if (pooledConnections.TryGetValue(connection.Endpoint, out value) == false) { pooledConnections[connection.Endpoint] = value = new LinkedList<PooledDistributedHashTableStorageClientConnection>(); } value.AddLast(connection); } log.DebugFormat("Put connection for {0} back in the pool", connection.Endpoint.Sync); }