Skip to content
Browse files

Fixes #10 where the webclient stopped reading from the socket after a…

… while (5 mins or so).

- Changed the client's ReadWriteTimeout property to infinite.
- Change dthe NorthScale defaults to us ethe proxy port instead of the direct one.
  • Loading branch information...
1 parent f05c23a commit f265b92d00087df795bf5f42f099288232289750 @enyim committed Jun 17, 2010
View
2 Enyim.Caching/Configuration/EndPointElementCollection.cs
@@ -36,7 +36,7 @@ protected override object GetElementKey(ConfigurationElement element)
/// Helper method; converts the collection into an <see cref="T:IPEndPoint"/> collection for the interface implementation.
/// </summary>
/// <returns></returns>
- internal IList<IPEndPoint> ToIPEndPointCollection()
+ public IList<IPEndPoint> ToIPEndPointCollection()
{
List<IPEndPoint> retval = new List<IPEndPoint>(this.Count);
foreach (EndPointElement e in this)
View
334 Enyim.Caching/Enyim.Caching.csproj
@@ -1,166 +1,170 @@
-<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{D438C0B3-A168-40B8-BDDD-61F0939DFF35}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Enyim.Caching</RootNamespace>
- <AssemblyName>Enyim.Caching</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <TargetFrameworkSubset>
- </TargetFrameworkSubset>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <RunCodeAnalysis>false</RunCodeAnalysis>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CodeAnalysisRules>-Microsoft.Globalization#CA1301;-Microsoft.Globalization#CA1302;-Microsoft.Globalization#CA1306;-Microsoft.Globalization#CA1304;-Microsoft.Globalization#CA1305;-Microsoft.Globalization#CA2101;-Microsoft.Globalization#CA1300</CodeAnalysisRules>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE;SIGN</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <DocumentationFile>bin\Release\Enyim.Caching.XML</DocumentationFile>
- <RunCodeAnalysis>false</RunCodeAnalysis>
- <CodeAnalysisRules>-Microsoft.Design#CA1020;-Microsoft.Naming#CA1709;-Microsoft.Naming#CA1704</CodeAnalysisRules>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\binaries\log4net.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.configuration" />
- <Reference Include="System.Configuration.Install" />
- <Reference Include="System.Core">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data" />
- <Reference Include="System.Web" />
- <Reference Include="System.Web.Extensions">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Configuration\AuthenticationConfiguration.cs" />
- <Compile Include="Configuration\ConfigurationHelper.cs" />
- <Compile Include="Configuration\AuthenticationElement.cs" />
- <Compile Include="Configuration\IAuthenticationConfiguration.cs" />
- <Compile Include="Configuration\SocketPoolConfiguration.cs" />
- <Compile Include="Memcached\Authentication\PlainTextAuthenticator.cs" />
- <Compile Include="Memcached\IAuthenticator.cs" />
- <Compile Include="Memcached\IMemcachedNode.cs" />
- <Compile Include="Memcached\IServerPool.cs" />
- <Compile Include="Memcached\IProtocolImplementation.cs" />
- <Compile Include="Memcached\ISaslAuthenticationProvider.cs" />
- <Compile Include="Memcached\Enums.cs" />
- <Compile Include="Memcached\KetamaNodeLocator.cs" />
- <Compile Include="Memcached\Operations\Binary\ConcatenationOperation.cs" />
- <Compile Include="Memcached\Operations\Binary\MultiGetOperation.cs" />
- <Compile Include="Memcached\Operations\Binary\SaslAuthenticator.cs" />
- <Compile Include="Memcached\Operations\Binary\FlushOperation.cs" />
- <Compile Include="Memcached\Operations\Binary\StatsOperation.cs" />
- <Compile Include="Memcached\Operations\Text\TextProtocol.cs" />
- <Compile Include="Memcached\Operations\Binary\BinaryProtocol.cs" />
- <Compile Include="HashCodeCombiner.cs" />
- <Compile Include="InterlockedQueue.cs" />
- <Compile Include="Memcached\CommandNotSupportedException.cs" />
- <Compile Include="Memcached\IMemcachedKeyTransformer.cs" />
- <Compile Include="Memcached\KeyTransformers\Base64KeyTransformer.cs" />
- <Compile Include="Memcached\KeyTransformers\DefaultKeyTransformer.cs">
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="Memcached\KeyTransformers\KeyTransformerBase.cs" />
- <Compile Include="Memcached\KeyTransformers\SHA1KeyTransformer.cs" />
- <Compile Include="Memcached\KeyTransformers\TigerHashKeyTransformer.cs" />
- <Compile Include="Memcached\MemcachedNode.cs" />
- <Compile Include="Memcached\Operations\Binary\BinaryRequest.cs" />
- <Compile Include="Memcached\Operations\Binary\BinaryResponse.cs" />
- <Compile Include="Memcached\Operations\Binary\BinaryConverter.cs" />
- <Compile Include="Memcached\Operations\Binary\MutatorOperation.cs" />
- <Compile Include="Memcached\Operations\Binary\DeleteOperation.cs" />
- <Compile Include="Memcached\Operations\Binary\GetOperation.cs" />
- <Compile Include="Memcached\Operations\Binary\OpCode.cs" />
- <Compile Include="Memcached\Operations\Binary\StoreOperation.cs" />
- <Compile Include="Memcached\Operations\ItemOperation.cs" />
- <Compile Include="Memcached\Operations\Operation.cs" />
- <Compile Include="Memcached\Operations\Text\DecrementOperation.cs" />
- <Compile Include="Memcached\Operations\Text\DeleteOperation.cs" />
- <Compile Include="Memcached\Operations\Text\FlushOperation.cs" />
- <Compile Include="Memcached\Operations\Text\GetHelper.cs" />
- <Compile Include="Memcached\Operations\Text\GetOperation.cs" />
- <Compile Include="Memcached\Operations\Text\IncrementOperation.cs" />
- <Compile Include="Memcached\Operations\Text\MultiGetOperation.cs" />
- <Compile Include="Memcached\Operations\Text\TextSocketHelper.cs" />
- <Compile Include="Memcached\Operations\Text\StatsOperation.cs" />
- <Compile Include="Memcached\Operations\Text\StoreOperation.cs" />
- <Compile Include="Memcached\SingleNodeLocator.cs" />
- <Compile Include="Memcached\StatItem.cs" />
- <Compile Include="Memcached\Transcoders\DefaultTranscoder.cs" />
- <Compile Include="Configuration\IMemcachedClientConfiguration.cs" />
- <Compile Include="Configuration\EndPointElement.cs" />
- <Compile Include="Configuration\InterfaceValidator.cs" />
- <Compile Include="Configuration\ISocketPoolConfiguration.cs" />
- <Compile Include="Configuration\MemcachedClientConfiguration.cs" />
- <Compile Include="Configuration\SocketPoolElement.cs" />
- <Compile Include="Configuration\EndPointElementCollection.cs" />
- <Compile Include="FastActivator.cs" />
- <Compile Include="IFastObjectFacory.cs" />
- <Compile Include="Memcached\DefaultNodeLocator.cs" />
- <Compile Include="Memcached\IMemcachedNodeLocator.cs" />
- <Compile Include="FnvHash.cs" />
- <Compile Include="MemcachedClient.cs" />
- <Compile Include="Memcached\MemcachedClientException.cs" />
- <Compile Include="Configuration\MemcachedClientSection.cs" />
- <Compile Include="Memcached\MemcachedException.cs" />
- <Compile Include="Memcached\PooledSocket.cs" />
- <Compile Include="Memcached\ServerStats.cs" />
- <Compile Include="Memcached\ThrowHelper.cs" />
- <Compile Include="Memcached\Transcoders\CacheItem.cs" />
- <Compile Include="Memcached\Transcoders\ITranscoder.cs" />
- <Compile Include="NorthScale.Store\BucketConfigListener.cs" />
- <Compile Include="NorthScale.Store\Configuration\BucketPortType.cs" />
- <Compile Include="NorthScale.Store\ConfigManager.cs" />
- <Compile Include="NorthScale.Store\Configuration\INorthScaleClientConfiguration.cs" />
- <Compile Include="NorthScale.Store\Configuration\NorthScaleClientConfiguration.cs" />
- <Compile Include="NorthScale.Store\Configuration\NorthScaleClientSection.cs" />
- <Compile Include="NorthScale.Store\Configuration\ServersElement.cs" />
- <Compile Include="NorthScale.Store\Configuration\UriElement.cs" />
- <Compile Include="NorthScale.Store\Configuration\UriElementCollection.cs" />
- <Compile Include="NorthScale.Store\Configuration\UriValidator.cs" />
- <Compile Include="NorthScale.Store\Deserialization.cs" />
- <Compile Include="NorthScale.Store\MessageStreamListener.cs" />
- <Compile Include="NorthScale.Store\NorthScaleClient.cs" />
- <Compile Include="NorthScale.Store\NorthScalePool.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Memcached\ServerPool.cs" />
- <Compile Include="Memcached\StoreMode.cs" />
- <Compile Include="TigerHash.cs" />
- <Compile Include="UIntEqualityComparer.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="App.config" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{D438C0B3-A168-40B8-BDDD-61F0939DFF35}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Enyim.Caching</RootNamespace>
+ <AssemblyName>Enyim.Caching</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <TargetFrameworkSubset>
+ </TargetFrameworkSubset>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <RunCodeAnalysis>false</RunCodeAnalysis>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <CodeAnalysisRules>-Microsoft.Globalization#CA1301;-Microsoft.Globalization#CA1302;-Microsoft.Globalization#CA1306;-Microsoft.Globalization#CA1304;-Microsoft.Globalization#CA1305;-Microsoft.Globalization#CA2101;-Microsoft.Globalization#CA1300</CodeAnalysisRules>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE;SIGN</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <DocumentationFile>bin\Release\Enyim.Caching.XML</DocumentationFile>
+ <RunCodeAnalysis>false</RunCodeAnalysis>
+ <CodeAnalysisRules>-Microsoft.Design#CA1020;-Microsoft.Naming#CA1709;-Microsoft.Naming#CA1704</CodeAnalysisRules>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\binaries\log4net.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.configuration" />
+ <Reference Include="System.Configuration.Install" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Web.Extensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Configuration\AuthenticationConfiguration.cs" />
+ <Compile Include="Configuration\ConfigurationHelper.cs" />
+ <Compile Include="Configuration\AuthenticationElement.cs" />
+ <Compile Include="Configuration\IAuthenticationConfiguration.cs" />
+ <Compile Include="Configuration\SocketPoolConfiguration.cs" />
+ <Compile Include="Memcached\Authentication\PlainTextAuthenticator.cs" />
+ <Compile Include="Memcached\IAuthenticator.cs" />
+ <Compile Include="Memcached\IMemcachedNode.cs" />
+ <Compile Include="Memcached\IServerPool.cs" />
+ <Compile Include="Memcached\IProtocolImplementation.cs" />
+ <Compile Include="Memcached\ISaslAuthenticationProvider.cs" />
+ <Compile Include="Memcached\Enums.cs" />
+ <Compile Include="Memcached\KetamaNodeLocator.cs" />
+ <Compile Include="Memcached\Operations\Binary\ConcatenationOperation.cs" />
+ <Compile Include="Memcached\Operations\Binary\MultiGetOperation.cs" />
+ <Compile Include="Memcached\Operations\Binary\SaslAuthenticator.cs" />
+ <Compile Include="Memcached\Operations\Binary\FlushOperation.cs" />
+ <Compile Include="Memcached\Operations\Binary\StatsOperation.cs" />
+ <Compile Include="Memcached\Operations\Text\TextProtocol.cs" />
+ <Compile Include="Memcached\Operations\Binary\BinaryProtocol.cs" />
+ <Compile Include="HashCodeCombiner.cs" />
+ <Compile Include="InterlockedQueue.cs" />
+ <Compile Include="Memcached\CommandNotSupportedException.cs" />
+ <Compile Include="Memcached\IMemcachedKeyTransformer.cs" />
+ <Compile Include="Memcached\KeyTransformers\Base64KeyTransformer.cs" />
+ <Compile Include="Memcached\KeyTransformers\DefaultKeyTransformer.cs">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="Memcached\KeyTransformers\KeyTransformerBase.cs" />
+ <Compile Include="Memcached\KeyTransformers\SHA1KeyTransformer.cs" />
+ <Compile Include="Memcached\KeyTransformers\TigerHashKeyTransformer.cs" />
+ <Compile Include="Memcached\MemcachedNode.cs" />
+ <Compile Include="Memcached\Operations\Binary\BinaryRequest.cs" />
+ <Compile Include="Memcached\Operations\Binary\BinaryResponse.cs" />
+ <Compile Include="Memcached\Operations\Binary\BinaryConverter.cs" />
+ <Compile Include="Memcached\Operations\Binary\MutatorOperation.cs" />
+ <Compile Include="Memcached\Operations\Binary\DeleteOperation.cs" />
+ <Compile Include="Memcached\Operations\Binary\GetOperation.cs" />
+ <Compile Include="Memcached\Operations\Binary\OpCode.cs" />
+ <Compile Include="Memcached\Operations\Binary\StoreOperation.cs" />
+ <Compile Include="Memcached\Operations\ItemOperation.cs" />
+ <Compile Include="Memcached\Operations\Operation.cs" />
+ <Compile Include="Memcached\Operations\Text\DecrementOperation.cs" />
+ <Compile Include="Memcached\Operations\Text\DeleteOperation.cs" />
+ <Compile Include="Memcached\Operations\Text\FlushOperation.cs" />
+ <Compile Include="Memcached\Operations\Text\GetHelper.cs" />
+ <Compile Include="Memcached\Operations\Text\GetOperation.cs" />
+ <Compile Include="Memcached\Operations\Text\IncrementOperation.cs" />
+ <Compile Include="Memcached\Operations\Text\MultiGetOperation.cs" />
+ <Compile Include="Memcached\Operations\Text\TextSocketHelper.cs" />
+ <Compile Include="Memcached\Operations\Text\StatsOperation.cs" />
+ <Compile Include="Memcached\Operations\Text\StoreOperation.cs" />
+ <Compile Include="Memcached\SingleNodeLocator.cs" />
+ <Compile Include="Memcached\StatItem.cs" />
+ <Compile Include="Memcached\Transcoders\DefaultTranscoder.cs" />
+ <Compile Include="Configuration\IMemcachedClientConfiguration.cs" />
+ <Compile Include="Configuration\EndPointElement.cs" />
+ <Compile Include="Configuration\InterfaceValidator.cs" />
+ <Compile Include="Configuration\ISocketPoolConfiguration.cs" />
+ <Compile Include="Configuration\MemcachedClientConfiguration.cs" />
+ <Compile Include="Configuration\SocketPoolElement.cs" />
+ <Compile Include="Configuration\EndPointElementCollection.cs" />
+ <Compile Include="FastActivator.cs" />
+ <Compile Include="IFastObjectFacory.cs" />
+ <Compile Include="Memcached\DefaultNodeLocator.cs" />
+ <Compile Include="Memcached\IMemcachedNodeLocator.cs" />
+ <Compile Include="FnvHash.cs" />
+ <Compile Include="MemcachedClient.cs" />
+ <Compile Include="Memcached\MemcachedClientException.cs" />
+ <Compile Include="Configuration\MemcachedClientSection.cs" />
+ <Compile Include="Memcached\MemcachedException.cs" />
+ <Compile Include="Memcached\PooledSocket.cs" />
+ <Compile Include="Memcached\ServerStats.cs" />
+ <Compile Include="Memcached\ThrowHelper.cs" />
+ <Compile Include="Memcached\Transcoders\CacheItem.cs" />
+ <Compile Include="Memcached\Transcoders\ITranscoder.cs" />
+ <Compile Include="NorthScale.Store\BucketConfigListener.cs" />
+ <Compile Include="NorthScale.Store\Configuration\BucketPortType.cs" />
+ <Compile Include="NorthScale.Store\ConfigManager.cs">
+ </Compile>
+ <Compile Include="NorthScale.Store\Configuration\INorthScaleClientConfiguration.cs" />
+ <Compile Include="NorthScale.Store\Configuration\NorthScaleClientConfiguration.cs" />
+ <Compile Include="NorthScale.Store\Configuration\NorthScaleClientSection.cs" />
+ <Compile Include="NorthScale.Store\Configuration\ServersElement.cs" />
+ <Compile Include="NorthScale.Store\Configuration\UriElement.cs" />
+ <Compile Include="NorthScale.Store\Configuration\UriElementCollection.cs" />
+ <Compile Include="NorthScale.Store\Configuration\UriValidator.cs" />
+ <Compile Include="NorthScale.Store\WebClientWithTimeout.cs">
+ <SubType>Component</SubType>
+ </Compile>
+ <Compile Include="NorthScale.Store\Deserialization.cs" />
+ <Compile Include="NorthScale.Store\MessageStreamListener.cs" />
+ <Compile Include="NorthScale.Store\NorthScaleClient.cs" />
+ <Compile Include="NorthScale.Store\NorthScalePool.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Memcached\ServerPool.cs" />
+ <Compile Include="Memcached\StoreMode.cs" />
+ <Compile Include="TigerHash.cs" />
+ <Compile Include="UIntEqualityComparer.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
</Project>
View
5 Enyim.Caching/Memcached/MemcachedNode.cs
@@ -421,11 +421,6 @@ public void Dispose()
}
}
- private void CheckDisposed()
- {
- if (this.isDisposed) throw new ObjectDisposedException("pool");
- }
-
void IDisposable.Dispose()
{
this.Dispose();
View
48 Enyim.Caching/NorthScale.Store/ConfigManager.cs
@@ -11,46 +11,22 @@ internal class ConfigHelper
{
private static log4net.ILog log = log4net.LogManager.GetLogger(typeof(ConfigHelper));
- private WebClient client;
+ private WebClientWithTimeout wcwt;
- public ConfigHelper() { }
-
- public ICredentials Credentials { get; set; }
-
- /// <summary>
- /// Creates a WebClient for communicating with the REST API.
- /// </summary>
- /// <param name="credentials"></param>
- /// <returns></returns>
- public static WebClient CreateClient(ICredentials credentials)
+ public ConfigHelper()
{
- var retval = new WebClient();
-
- retval.Credentials = credentials;
-
- retval.Headers[HttpRequestHeader.CacheControl] = "no-cache";
- retval.Headers[HttpRequestHeader.Accept] = "application/com.northscale.store+json";
- // TODO mayvbe we should version this
- retval.Headers[HttpRequestHeader.UserAgent] = "enyim.com memcached client";
-
- retval.Encoding = Encoding.UTF8;
-
- return retval;
+ this.wcwt = new WebClientWithTimeout();
}
- private WebClient GetWebClient()
+ public ICredentials Credentials
{
- if (this.client == null)
- {
- this.client = CreateClient(this.Credentials);
- }
-
- return this.client;
+ get { return this.wcwt.Credentials; }
+ set { this.wcwt.Credentials = value; }
}
private T DeserializeUri<T>(Uri uri)
{
- var info = this.GetWebClient().DownloadString(uri);
+ var info = this.wcwt.DownloadString(uri);
var jss = new JavaScriptSerializer();
return jss.Deserialize<T>(info);
@@ -134,6 +110,16 @@ public BucketNode[] GetWorkingNodes(Uri[] pools, string name)
return null;
}
+
+ public int Timeout
+ {
+ get { return this.wcwt.Timeout; }
+ set
+ {
+ this.wcwt.Timeout = value;
+ this.wcwt.ReadWriteTimeout = value;
+ }
+ }
}
}
View
2 Enyim.Caching/NorthScale.Store/Configuration/NorthScaleClientConfiguration.cs
@@ -18,7 +18,7 @@ public class NorthScaleClientConfiguration : INorthScaleClientConfiguration
private Type transcoder;
private ICredentials credentials;
private string bucket;
- private BucketPortType port = BucketPortType.Direct;
+ private BucketPortType port = BucketPortType.Proxy;
/// <summary>
/// Initializes a new instance of the <see cref="T:MemcachedClientConfiguration"/> class.
View
2 Enyim.Caching/NorthScale.Store/Configuration/ServersElement.cs
@@ -49,7 +49,7 @@ public UriElementCollection Urls
/// <summary>
/// Determines which port the client should use to connect to the nodes
/// </summary>
- [ConfigurationProperty("port", IsRequired = false, DefaultValue=BucketPortType.Direct)]
+ [ConfigurationProperty("port", IsRequired = false, DefaultValue=BucketPortType.Proxy)]
public BucketPortType Port
{
get { return (BucketPortType)base["port"]; }
View
26 Enyim.Caching/NorthScale.Store/MessageStreamListener.cs
@@ -32,16 +32,14 @@ public MessageStreamListener(Uri[] urls)
protected virtual WebClient CreateClient()
{
- var client = new WebClient();
-
- client.Credentials = this.Credentials;
- client.Headers[HttpRequestHeader.CacheControl] = "no-cache";
- client.Headers[HttpRequestHeader.Accept] = "application/com.northscale.store+json";
- client.Headers[HttpRequestHeader.UserAgent] = "enyim.com memcached client";
-
- client.Encoding = Encoding.UTF8;
-
- return client;
+ return new WebClientWithTimeout()
+ {
+ Credentials = this.Credentials,
+ // make it infinite so it will not stop abort the socket thinking that the server have died
+ ReadWriteTimeout = System.Threading.Timeout.Infinite,
+ // this is just the connect timeout
+ Timeout = this.Timeout
+ };
}
/// <summary>
@@ -76,7 +74,8 @@ private void Work(object state)
if (log.IsDebugEnabled) log.Debug("Started working.");
Uri[] urls = this.urls;
- using (var client = ConfigHelper.CreateClient(this.Credentials))
+
+ using (var client = this.CreateClient())
{
var worker = this.currentWorker = new MessageReader(client, this.OnMessageReceived);
@@ -140,6 +139,8 @@ private void Work(object state)
}
catch (Exception e)
{
+ log.Error("POOLFAIL", e);
+
if (e is IOException || e is System.Net.WebException)
{
// current worker failed, most probably the pool it was connected to went down
@@ -186,6 +187,9 @@ protected virtual void OnConnectionAborted()
//if (log.IsDebugEnabled) log.Debug("Aborted");
}
+
+ public int Timeout { get; set; }
+
#region [ MessageReader ]
private class MessageReader
{
View
2 Enyim.Caching/NorthScale.Store/NorthScalePool.cs
@@ -91,6 +91,7 @@ void IServerPool.Start()
var cm = new ConfigHelper();
cm.Credentials = this.configuration.Credentials;
+ cm.Timeout = (int)this.configuration.SocketPool.ConnectionTimeout.TotalMilliseconds;
// get the nodes of the specified buctek using the pool urls
var nodes = cm.GetWorkingNodes(this.poolUrls, this.bucketName ?? "default");
@@ -108,6 +109,7 @@ void IServerPool.Start()
// create a config listener
this.configListener = new BucketConfigListener(streamingUris, nodes);
this.configListener.Credentials = this.configuration.Credentials;
+ this.configListener.Timeout = cm.Timeout;
// recreate the node lcoator when the config changes
this.configListener.NodeListChanged += InitNodes;
View
57 Enyim.Caching/NorthScale.Store/WebClientWithTimeout.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Web.Script.Serialization;
+
+namespace NorthScale.Store
+{
+ internal class WebClientWithTimeout : WebClient
+ {
+ public WebClientWithTimeout()
+ {
+ this.Encoding = Encoding.UTF8;
+
+ this.Headers[HttpRequestHeader.CacheControl] = "no-cache";
+ this.Headers[HttpRequestHeader.Accept] = "application/com.northscale.store+json";
+ // TODO mayvbe we should version this
+ this.Headers[HttpRequestHeader.UserAgent] = "enyim.com memcached client";
+ }
+
+ protected override WebRequest GetWebRequest(Uri address)
+ {
+ var retval = base.GetWebRequest(address);
+ retval.Timeout = this.Timeout;
+
+ var hrw = retval as HttpWebRequest;
+ if (hrw != null)
+ hrw.ReadWriteTimeout = this.ReadWriteTimeout;
+
+ return retval;
+ }
+
+ public int ReadWriteTimeout { get; set; }
+ public int Timeout { get; set; }
+ }
+}
+
+#region [ License information ]
+/* ************************************************************
+ *
+ * Copyright (c) 2010 Attila Kiskó, enyim.com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ************************************************************/
+#endregion
View
15 MemcachedTest/App.config
@@ -14,10 +14,11 @@
<enyim.com>
<memcached>
<servers>
- <add address="127.0.0.1" port="20002" />
+ <add address="192.168.2.80" port="11211" />
+ <!--<add address="127.0.0.1" port="20002" />
<add address="127.0.0.1" port="20004" />
<add address="127.0.0.1" port="20006" />
- <add address="127.0.0.1" port="20008" />
+ <add address="127.0.0.1" port="20008" />-->
</servers>
<socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:00:10" />
</memcached>
@@ -27,20 +28,22 @@
<binaryConfig protocol="Binary">
<servers>
- <add address="127.0.0.1" port="20002" />
+ <add address="192.168.2.80" port="11211" />
+ <!--<add address="127.0.0.1" port="20002" />
<add address="127.0.0.1" port="20004" />
<add address="127.0.0.1" port="20006" />
- <add address="127.0.0.1" port="20008" />
+ <add address="127.0.0.1" port="20008" />-->
</servers>
<socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:00:10" />
</binaryConfig>
<textConfig protocol="Text">
<servers>
- <add address="127.0.0.1" port="20002" />
+ <add address="192.168.2.80" port="11211" />
+ <!--<add address="127.0.0.1" port="20002" />
<add address="127.0.0.1" port="20004" />
<add address="127.0.0.1" port="20006" />
- <add address="127.0.0.1" port="20008" />
+ <add address="127.0.0.1" port="20008" />-->
</servers>
<socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:00:10" />
</textConfig>

0 comments on commit f265b92

Please sign in to comment.
Something went wrong with that request. Please try again.