@@ -28,7 +28,7 @@ public class MemcachedNode : IMemcachedNode
28
28
29
29
private bool isDisposed ;
30
30
31
- private readonly EndPoint endPoint ;
31
+ private readonly EndPoint _endPoint ;
32
32
private readonly ISocketPoolConfiguration config ;
33
33
private InternalPoolImpl internalPoolImpl ;
34
34
private bool isInitialized = false ;
@@ -40,7 +40,8 @@ public MemcachedNode(
40
40
ISocketPoolConfiguration socketPoolConfig ,
41
41
ILogger logger )
42
42
{
43
- this . endPoint = endpoint ;
43
+ _endPoint = endpoint ;
44
+ EndPointString = endpoint ? . ToString ( ) . Replace ( "Unspecified/" , string . Empty ) ;
44
45
this . config = socketPoolConfig ;
45
46
46
47
if ( socketPoolConfig . ConnectionTimeout . TotalMilliseconds >= Int32 . MaxValue )
@@ -72,9 +73,11 @@ protected INodeFailurePolicy FailurePolicy
72
73
/// </summary>
73
74
public EndPoint EndPoint
74
75
{
75
- get { return this . endPoint ; }
76
+ get { return _endPoint ; }
76
77
}
77
78
79
+ public string EndPointString { get ; private set ; }
80
+
78
81
/// <summary>
79
82
/// <para>Gets a value indicating whether the server is working or not. Returns a <b>cached</b> state.</para>
80
83
/// <para>To get real-time information and update the cached state, use the <see cref="M:Ping"/> method.</para>
@@ -771,7 +774,7 @@ protected internal virtual PooledSocket CreateSocket()
771
774
{
772
775
try
773
776
{
774
- var ps = new PooledSocket ( this . endPoint , this . config . ConnectionTimeout , this . config . ReceiveTimeout , _logger ) ;
777
+ var ps = new PooledSocket ( _endPoint , this . config . ConnectionTimeout , this . config . ReceiveTimeout , _logger ) ;
775
778
ps . Connect ( ) ;
776
779
return ps ;
777
780
}
@@ -787,13 +790,13 @@ protected internal virtual async Task<PooledSocket> CreateSocketAsync()
787
790
{
788
791
try
789
792
{
790
- var ps = new PooledSocket ( this . endPoint , this . config . ConnectionTimeout , this . config . ReceiveTimeout , _logger ) ;
793
+ var ps = new PooledSocket ( _endPoint , this . config . ConnectionTimeout , this . config . ReceiveTimeout , _logger ) ;
791
794
await ps . ConnectAsync ( ) ;
792
795
return ps ;
793
796
}
794
797
catch ( Exception ex )
795
798
{
796
- var endPointStr = endPoint . ToString ( ) . Replace ( "Unspecified/" , string . Empty ) ;
799
+ var endPointStr = _endPoint . ToString ( ) . Replace ( "Unspecified/" , string . Empty ) ;
797
800
_logger . LogError ( ex , $ "Failed to { nameof ( CreateSocketAsync ) } to { endPointStr } ") ;
798
801
throw ;
799
802
}
@@ -835,7 +838,7 @@ protected virtual IPooledSocketResult ExecuteOperation(IOperation op)
835
838
}
836
839
catch ( IOException e )
837
840
{
838
- _logger . LogError ( nameof ( MemcachedNode ) , e ) ;
841
+ _logger . LogError ( e , $ "Failed to ExecuteOperation on { EndPointString } " ) ;
839
842
840
843
result . Fail ( "Exception reading response" , e ) ;
841
844
return result ;
@@ -887,14 +890,14 @@ protected virtual async Task<IPooledSocketResult> ExecuteOperationAsync(IOperati
887
890
}
888
891
catch ( IOException e )
889
892
{
890
- _logger . LogError ( nameof ( MemcachedNode ) , e ) ;
893
+ _logger . LogError ( e , $ "IOException occurs when ExecuteOperationAsync( { op } ) on { EndPointString } " ) ;
891
894
892
895
result . Fail ( "IOException reading response" , e ) ;
893
896
return result ;
894
897
}
895
898
catch ( SocketException e )
896
899
{
897
- _logger . LogError ( nameof ( MemcachedNode ) , e ) ;
900
+ _logger . LogError ( e , $ "SocketException occurs when ExecuteOperationAsync( { op } ) on { EndPointString } " ) ;
898
901
899
902
result . Fail ( "SocketException reading response" , e ) ;
900
903
return result ;
@@ -936,7 +939,7 @@ protected virtual async Task<bool> ExecuteOperationAsync(IOperation op, Action<b
936
939
}
937
940
catch ( IOException e )
938
941
{
939
- _logger . LogError ( nameof ( MemcachedNode ) , e ) ;
942
+ _logger . LogError ( e , $ "Failed to ExecuteOperationAsync( { op } ) with next action on { EndPointString } " ) ;
940
943
( ( IDisposable ) socket ) . Dispose ( ) ;
941
944
942
945
return false ;
@@ -956,7 +959,7 @@ private void LogExecutionTime(string title, DateTime startTime, int thresholdMs)
956
959
957
960
EndPoint IMemcachedNode . EndPoint
958
961
{
959
- get { return this . EndPoint ; }
962
+ get { return _endPoint ; }
960
963
}
961
964
962
965
bool IMemcachedNode . IsAlive
0 commit comments