在计算模拟器中缺少Windows Azure缓存2.1的缓存角色行为 [英] Missing cache role behavior of Windows Azure Caching 2.1 in compute emulator

查看:123
本文介绍了在计算模拟器中缺少Windows Azure缓存2.1的缓存角色行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个托管服务上工作,该服务在Web角色实例上部署了Windows Azure缓存.缓存已在生产环境中启用,但是在计算模拟器中我们将其禁用,因为我们经常会遇到缓存模拟器的运行速度减慢和异常情况.特别是,在计算仿真器中,我们没有在csdef中加载缓存模块,并且在运行时我们通过创建DataCacheFactory并捕获当客户端库配置中指示的角色为时抛出的特定异常来检测是否启用了缓存.在csdef中找不到.

I work on a hosted service which has Windows Azure Cache deployed on instances of the web role. The cache is enabled on production but in the compute emulator we disable it since we often experience slowdowns and exceptions with the cache emulator. In particular, in the compute emulator we do not load the caching module in the csdef and at runtime we detect if cache is enabled by creating the DataCacheFactory and catching the specific exception thrown when the role indicated in the client library configuration is not found in the csdef.

这在Windows Azure Caching 2.0之前一直有效-当我们升级到Windows Azure Caching 2.1(和Azure SDK 2.1)时,行为已更改:

This worked correctly until Windows Azure Caching 2.0 -- when we upgraded to Windows Azure Caching 2.1 (and Azure SDK 2.1) the behavior changed:

  • 我们在DataCacheFactory构造函数上没有例外;
  • 当我们尝试从DataCacheFactory实例化DataCache时,该角色似乎已挂起,并且3分钟后它返回,但出现以下异常(可以在

  • we don't have the exception on DataCacheFactory constructor;
  • when we try to instantiate the DataCache from the DataCacheFactory the role seems to hang and after 3 minutes it returns with the following exception (the complete text can be found here):

Microsoft.ApplicationServer.Caching.DataCacheException was unhandled by
user code
Message=ErrorCode<ERRCA0017>:SubStatus<ES0006>:There is a temporary failure.
Please retry later. (<snip>). Additional Information :
The client was trying to communicate with the server:
net.tcp://WebRole:24233.
InnerException: System.Net.Sockets.SocketException
Message=No such host is known

请注意,这不是以下SO问题的重复:

Please not that this is not a duplicate of the following SO questions:

  • Cant get Azure Cache to work. "There is a temporary failure. Please retry later."
  • Exception while using Windows Azure Caching : No such host is known
  • Azure Caching - Failure after upgrading to SDK 2.1 and caching 2.1

因为

  • 我确定我使用的是Azure SDK 2.1(已在调试中检查了库的版本是否正确);
  • 仅当我故意禁用缓存角色时,我的问题才会出现.

推荐答案

使用以下 SO答案中描述的过程在ILSpy的帮助下,我已经能够理解为什么会发生此异常:在Windows Azure缓存2.1中,当未在客户端配置中指定的角色被找到时,该地址被视为地址并继续执行,而在较旧的版本中,它将引发异常(我发现该缓存未启用).

Using the procedure described in the following SO answer and with the help of ILSpy I've been able to understand why this exception occurs: in Windows Azure Caching 2.1 when the role specified in the client configuration is not found it is considered an address and execution continues, while in older versions it throws an exception (which I caught to understand cache was not enabled).

相关的日志消息是:

WaWorkerHost.exe Information: 0 : INFORMATION:
<DistributedCache.CacheFactory.1> TryAutoDiscoverServersWithinDeployment
for Instance 'WebRole' failed to connect as RoleName type with exception
System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. --->
Microsoft.ApplicationServer.Caching.DataCacheException:
ErrorCode<UnspecifiedErrorCode>:SubStatus<ES0001>:The role WebService
was not found in the current deployment.
at Microsoft.ApplicationServer.Caching.AzureClientHelper.RoleUtility.
  GetCacheRoleIPList(String roleName, String portIdentifier)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments,
  Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
  Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, 
  BindingFlags invokeAttr, Binder binder, Object[] parameters,
  CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Microsoft.ApplicationServer.Caching.DataCacheFactory.
   AutoDiscoverServersWithinDeployment()
at Microsoft.ApplicationServer.Caching.DataCacheFactory.
   TryAutoDiscoverServersWithinDeployment()
Assuming it as EndPoint.

WaWorkerHost.exe Warning: 0 : WARNING: <DistributedCache.SocketClientChannel.1>
Request 1 to host net.tcp://webrolw:24233/ failed 
Status=ChannelOpenFailed[System.Net.Sockets.SocketException (0x80004005):
No such host is known

要解决此问题,您可以:

To resolve this issue you can:

  • 分析刚刚创建的DataCacheFactory,并查看Servers属性中是否存在地址与缓存角色名称相同的任何项目-表明所指示角色未配置缓存;
  • 在托管服务的调试配置中,DataCacheFactory的rel ="nofollow noreferrer"> CacheReadyRetryPolicy 属性(导致异常发生前3分钟的延迟),如果引发异常,则假定高速缓存不可用.
  • analize the DataCacheFactory just created and see if in the Servers property there is any item in which the address is the same as the name of the cache role -- a sign that the indicated role has no cache configured;
  • in debug configurations of the hosted service lower the number of retries in the CacheReadyRetryPolicy property of the DataCacheFactory (which was causing the 3 minute delay before the exception) and if exceptions are thrown assume that the cache is unavailable.

这篇关于在计算模拟器中缺少Windows Azure缓存2.1的缓存角色行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆