本文整理汇总了C#中IOperation.ReadResponse方法的典型用法代码示例。如果您正苦于以下问题:C# IOperation.ReadResponse方法的具体用法?C# IOperation.ReadResponse怎么用?C# IOperation.ReadResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOperation
的用法示例。
在下文中一共展示了IOperation.ReadResponse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteOperation
protected override Enyim.Caching.Memcached.Results.IPooledSocketResult ExecuteOperation(IOperation op)
{
var result = this.Acquire();
if (result.Success && result.HasValue)
{
try
{
var socket = result.Value;
var b = op.GetBuffer();
socket.Write(b);
var readResult = op.ReadResponse(socket);
if (readResult.Success)
{
result.Pass();
}
else
{
readResult.Combine(result);
}
return result;
}
//----------------------------------------Begin Modify by ZhaiXueDong---------------------------------------------------------------------------
//catch (IOException e)
//{
// log.Error(e);
// result.Fail("Exception reading response", e);
// return result;
//}
//----------------------------------------------------------------------------------------------------------------------------------------------
// my
catch (System.Net.Sockets.SocketException)
{
throw;
}
//----------------------------------------End Modify by ZhaiXueDong-----------------------------------------------------------------------------
finally
{
((IDisposable)result.Value).Dispose();
}
}
else
{
// result.Fail("Failed to obtain socket from pool");
//return result;
if (result.Exception != null)
{
throw result.Exception;
}
throw new System.ServiceModel.EndpointNotFoundException(String.Format("未能够从连接池中获取到连接对象,详细错误信息为:{0}", result.Message));
}
}
示例2: Execute
public IOperationResult Execute(IOperation op)
{
IOperationResult result = new BinaryOperationResult();
IPooledSocket socket = null;
try
{
socket = _pool.Acquire();
if (Log.IsDebugEnabled)
{
Log.DebugFormat("Start execute {0} with {1}", op.Key, socket.InstanceId);
}
var buffers = op.GetBuffer();
socket.Write(buffers);
result = op.ReadResponse(socket);
if (result.Success)
{
result.Pass();
}
}
catch (NodeShutdownException e)
{
string msg = String.Format("Node Shutdown - {0}.", EndPoint);
Log.DebugFormat("m:{0} i:{1}\n{2}", msg, op.Key, e);
result.Fail(msg, e);
result.StatusCode = StatusCode.NodeShutdown.ToInt();
}
catch (QueueTimeoutException e)
{
string msg = String.Format("Queue Timeout - {0}.", EndPoint);
Log.ErrorFormat("m:{0} i:{1}\n{2}", msg, op.Key, e);
result.Fail(msg, e);
result.StatusCode = StatusCode.SocketPoolTimeout.ToInt();
}
catch (IOException e)
{
string msg = String.Format("Exception reading response - {0}", EndPoint);
Log.ErrorFormat("m:{0} s:{1} i:{2}\n{3}", msg, op.Key,
socket == null ? Guid.Empty : socket.InstanceId, e);
result.Fail(msg, e);
if (result.StatusCode == null ||
result.StatusCode == StatusCode.Success.ToInt())
{
result.StatusCode = StatusCode.InternalError.ToInt();
}
}
catch (Exception e)
{
string msg = String.Format("Operation failed - {0}", EndPoint);
Log.ErrorFormat("m:{0} s:{1} i:{2}\n{3}", msg, op.Key,
socket == null ? Guid.Empty : socket.InstanceId, e);
result.Fail(msg, e);
if (result.StatusCode == null ||
result.StatusCode == StatusCode.Success.ToInt())
{
result.StatusCode = StatusCode.InternalError.ToInt();
}
}
finally
{
if (socket != null)
{
if (Log.IsDebugEnabled)
{
Log.DebugFormat("End execute {0} with {1}", op.Key, socket.InstanceId);
}
_pool.Release(socket);
}
}
if (Log.IsDebugEnabled)
{
const string msg = "Operation {0} :i {1} n: {2} t: {3} m: {4} sc: {5} r: {6}";
Log.DebugFormat(msg, result.Success ?
op.RetryAttempts > 0 ? "succeeded*" : "succeeded" :
op.RetryAttempts > 0 ? "failed*" : "failed",
op.Key,
_endpoint, Thread.CurrentThread.Name,
result.Message,
Enum.GetName(typeof (StatusCode), result.StatusCode ?? 0),
op.RetryAttempts);
}
return result;
}