@@ -45,7 +45,7 @@ public ServerCounters GetCounters()
45
45
{
46
46
counters . Add ( snapshot [ i ] . GetCounters ( ) ) ;
47
47
}
48
- unprocessableCompletionManager . GetCounters ( counters . Other ) ;
48
+ UnprocessableCompletionManager . GetCounters ( counters . Other ) ;
49
49
return counters ;
50
50
}
51
51
@@ -123,7 +123,7 @@ internal void OnConnectionFailed(EndPoint endpoint, ConnectionType connectionTyp
123
123
var handler = ConnectionFailed ;
124
124
if ( handler != null )
125
125
{
126
- unprocessableCompletionManager . CompleteSyncOrAsync (
126
+ UnprocessableCompletionManager . CompleteSyncOrAsync (
127
127
new ConnectionFailedEventArgs ( handler , this , endpoint , connectionType , failureType , exception )
128
128
) ;
129
129
}
@@ -142,7 +142,7 @@ internal void OnInternalError(Exception exception, EndPoint endpoint = null, Con
142
142
var handler = InternalError ;
143
143
if ( handler != null )
144
144
{
145
- unprocessableCompletionManager . CompleteSyncOrAsync (
145
+ UnprocessableCompletionManager . CompleteSyncOrAsync (
146
146
new InternalErrorEventArgs ( handler , this , endpoint , connectionType , exception , origin )
147
147
) ;
148
148
}
@@ -158,7 +158,7 @@ internal void OnConnectionRestored(EndPoint endpoint, ConnectionType connectionT
158
158
var handler = ConnectionRestored ;
159
159
if ( handler != null )
160
160
{
161
- unprocessableCompletionManager . CompleteSyncOrAsync (
161
+ UnprocessableCompletionManager . CompleteSyncOrAsync (
162
162
new ConnectionFailedEventArgs ( handler , this , endpoint , connectionType , ConnectionFailureType . None , null )
163
163
) ;
164
164
}
@@ -170,7 +170,7 @@ private void OnEndpointChanged(EndPoint endpoint, EventHandler<EndPointEventArgs
170
170
if ( isDisposed ) return ;
171
171
if ( handler != null )
172
172
{
173
- unprocessableCompletionManager . CompleteSyncOrAsync (
173
+ UnprocessableCompletionManager . CompleteSyncOrAsync (
174
174
new EndPointEventArgs ( handler , this , endpoint )
175
175
) ;
176
176
}
@@ -189,7 +189,7 @@ internal void OnErrorMessage(EndPoint endpoint, string message)
189
189
var handler = ErrorMessage ;
190
190
if ( handler != null )
191
191
{
192
- unprocessableCompletionManager . CompleteSyncOrAsync (
192
+ UnprocessableCompletionManager . CompleteSyncOrAsync (
193
193
new RedisErrorEventArgs ( handler , this , endpoint , message )
194
194
) ;
195
195
}
@@ -481,7 +481,7 @@ private static void WriteNormalizingLineEndings(string source, StreamWriter writ
481
481
/// <summary>
482
482
/// Gets the timeout associated with the connections
483
483
/// </summary>
484
- public int TimeoutMilliseconds => timeoutMilliseconds ;
484
+ public int TimeoutMilliseconds { get ; }
485
485
486
486
/// <summary>
487
487
/// Gets all endpoints defined on the server
@@ -494,13 +494,11 @@ public EndPoint[] GetEndPoints(bool configuredOnly = false)
494
494
return ConvertHelper . ConvertAll ( serverSnapshot , x => x . EndPoint ) ;
495
495
}
496
496
497
- private readonly int timeoutMilliseconds ;
498
-
499
497
private readonly ConfigurationOptions configuration ;
500
498
501
499
internal bool TryResend ( int hashSlot , Message message , EndPoint endpoint , bool isMoved )
502
500
{
503
- return serverSelectionStrategy . TryResend ( hashSlot , message , endpoint , isMoved ) ;
501
+ return ServerSelectionStrategy . TryResend ( hashSlot , message , endpoint , isMoved ) ;
504
502
}
505
503
506
504
/// <summary>
@@ -510,7 +508,7 @@ internal bool TryResend(int hashSlot, Message message, EndPoint endpoint, bool i
510
508
public void Wait ( Task task )
511
509
{
512
510
if ( task == null ) throw new ArgumentNullException ( nameof ( task ) ) ;
513
- if ( ! task . Wait ( timeoutMilliseconds ) ) throw new TimeoutException ( ) ;
511
+ if ( ! task . Wait ( TimeoutMilliseconds ) ) throw new TimeoutException ( ) ;
514
512
}
515
513
516
514
/// <summary>
@@ -521,7 +519,7 @@ public void Wait(Task task)
521
519
public T Wait < T > ( Task < T > task )
522
520
{
523
521
if ( task == null ) throw new ArgumentNullException ( nameof ( task ) ) ;
524
- if ( ! task . Wait ( timeoutMilliseconds ) ) throw new TimeoutException ( ) ;
522
+ if ( ! task . Wait ( TimeoutMilliseconds ) ) throw new TimeoutException ( ) ;
525
523
return task . Result ;
526
524
}
527
525
@@ -533,10 +531,10 @@ public void WaitAll(params Task[] tasks)
533
531
{
534
532
if ( tasks == null ) throw new ArgumentNullException ( nameof ( tasks ) ) ;
535
533
if ( tasks . Length == 0 ) return ;
536
- if ( ! Task . WaitAll ( tasks , timeoutMilliseconds ) ) throw new TimeoutException ( ) ;
534
+ if ( ! Task . WaitAll ( tasks , TimeoutMilliseconds ) ) throw new TimeoutException ( ) ;
537
535
}
538
536
539
- private bool WaitAllIgnoreErrors ( Task [ ] tasks ) => WaitAllIgnoreErrors ( tasks , timeoutMilliseconds ) ;
537
+ private bool WaitAllIgnoreErrors ( Task [ ] tasks ) => WaitAllIgnoreErrors ( tasks , TimeoutMilliseconds ) ;
540
538
541
539
private static bool WaitAllIgnoreErrors ( Task [ ] tasks , int timeout )
542
540
{
@@ -677,7 +675,7 @@ internal void OnHashSlotMoved(int hashSlot, EndPoint old, EndPoint @new)
677
675
var handler = HashSlotMoved ;
678
676
if ( handler != null )
679
677
{
680
- unprocessableCompletionManager . CompleteSyncOrAsync (
678
+ UnprocessableCompletionManager . CompleteSyncOrAsync (
681
679
new HashSlotMovedEventArgs ( handler , this , hashSlot , old , @new )
682
680
) ;
683
681
}
@@ -687,7 +685,7 @@ internal void OnHashSlotMoved(int hashSlot, EndPoint old, EndPoint @new)
687
685
/// Compute the hash-slot of a specified key
688
686
/// </summary>
689
687
/// <param name="key">The key to get a hash slot ID for.</param>
690
- public int HashSlot ( RedisKey key ) => serverSelectionStrategy . HashSlot ( key ) ;
688
+ public int HashSlot ( RedisKey key ) => ServerSelectionStrategy . HashSlot ( key ) ;
691
689
692
690
internal ServerEndPoint AnyConnected ( ServerType serverType , uint startOffset , RedisCommand command , CommandFlags flags )
693
691
{
@@ -910,11 +908,11 @@ private ConnectionMultiplexer(ConfigurationOptions configuration)
910
908
}
911
909
912
910
PreserveAsyncOrder = configuration . PreserveAsyncOrder ;
913
- timeoutMilliseconds = configuration . SyncTimeout ;
911
+ TimeoutMilliseconds = configuration . SyncTimeout ;
914
912
915
913
OnCreateReaderWriter ( configuration ) ;
916
- unprocessableCompletionManager = new CompletionManager ( this , "multiplexer" ) ;
917
- serverSelectionStrategy = new ServerSelectionStrategy ( this ) ;
914
+ UnprocessableCompletionManager = new CompletionManager ( this , "multiplexer" ) ;
915
+ ServerSelectionStrategy = new ServerSelectionStrategy ( this ) ;
918
916
919
917
var configChannel = configuration . ConfigurationChannel ;
920
918
if ( ! string . IsNullOrWhiteSpace ( configChannel ) )
@@ -975,7 +973,7 @@ internal long LastHeartbeatSecondsAgo
975
973
976
974
internal static long LastGlobalHeartbeatSecondsAgo => unchecked ( Environment . TickCount - VolatileWrapper . Read ( ref lastGlobalHeartbeatTicks ) ) / 1000 ;
977
975
978
- internal CompletionManager UnprocessableCompletionManager => unprocessableCompletionManager ;
976
+ internal CompletionManager UnprocessableCompletionManager { get ; }
979
977
980
978
/// <summary>
981
979
/// Obtain a pub/sub subscriber connection to the specified server
@@ -1086,8 +1084,6 @@ internal static void TraceWithoutContext(bool condition, string message, [Caller
1086
1084
if ( condition ) OnTraceWithoutContext ( message , category ) ;
1087
1085
}
1088
1086
1089
- private readonly CompletionManager unprocessableCompletionManager ;
1090
-
1091
1087
/// <summary>
1092
1088
/// The number of operations that have been performed on all connections
1093
1089
/// </summary>
@@ -1234,7 +1230,7 @@ internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, Text
1234
1230
if ( configuration . ResolveDns && configuration . HasDnsEndPoints ( ) )
1235
1231
{
1236
1232
var dns = configuration . ResolveEndPointsAsync ( this , log ) . ObserveErrors ( ) ;
1237
- if ( ( await Task . WhenAny ( dns , Task . Delay ( timeoutMilliseconds ) ) . ForAwait ( ) ) != dns )
1233
+ if ( ( await Task . WhenAny ( dns , Task . Delay ( TimeoutMilliseconds ) ) . ForAwait ( ) ) != dns )
1238
1234
{
1239
1235
throw new TimeoutException ( "Timeout resolving endpoints" ) ;
1240
1236
}
@@ -1443,15 +1439,15 @@ internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, Text
1443
1439
// set the serverSelectionStrategy
1444
1440
if ( RawConfig . Proxy == Proxy . Twemproxy )
1445
1441
{
1446
- serverSelectionStrategy . ServerType = ServerType . Twemproxy ;
1442
+ ServerSelectionStrategy . ServerType = ServerType . Twemproxy ;
1447
1443
}
1448
1444
else if ( standaloneCount == 0 && sentinelCount > 0 )
1449
1445
{
1450
- serverSelectionStrategy . ServerType = ServerType . Sentinel ;
1446
+ ServerSelectionStrategy . ServerType = ServerType . Sentinel ;
1451
1447
}
1452
1448
else
1453
1449
{
1454
- serverSelectionStrategy . ServerType = ServerType . Standalone ;
1450
+ ServerSelectionStrategy . ServerType = ServerType . Standalone ;
1455
1451
}
1456
1452
var preferred = await NominatePreferredMaster ( log , servers , useTieBreakers , tieBreakers , masters ) . ObserveErrors ( ) . ForAwait ( ) ;
1457
1453
foreach ( var master in masters )
@@ -1468,10 +1464,10 @@ internal async Task<bool> ReconfigureAsync(bool first, bool reconfigureAll, Text
1468
1464
}
1469
1465
else
1470
1466
{
1471
- serverSelectionStrategy . ServerType = ServerType . Cluster ;
1472
- long coveredSlots = serverSelectionStrategy . CountCoveredSlots ( ) ;
1467
+ ServerSelectionStrategy . ServerType = ServerType . Cluster ;
1468
+ long coveredSlots = ServerSelectionStrategy . CountCoveredSlots ( ) ;
1473
1469
LogLocked ( log , "Cluster: {0} of {1} slots covered" ,
1474
- coveredSlots , serverSelectionStrategy . TotalSlots ) ;
1470
+ coveredSlots , ServerSelectionStrategy . TotalSlots ) ;
1475
1471
}
1476
1472
if ( ! first )
1477
1473
{
@@ -1724,15 +1720,13 @@ internal void UpdateClusterRange(ClusterConfiguration configuration)
1724
1720
foreach ( var slot in node . Slots )
1725
1721
{
1726
1722
var server = GetServerEndPoint ( node . EndPoint ) ;
1727
- if ( server != null ) serverSelectionStrategy . UpdateClusterRange ( slot . From , slot . To , server ) ;
1723
+ if ( server != null ) ServerSelectionStrategy . UpdateClusterRange ( slot . From , slot . To , server ) ;
1728
1724
}
1729
1725
}
1730
1726
}
1731
1727
1732
1728
private Timer pulse ;
1733
1729
1734
- private readonly ServerSelectionStrategy serverSelectionStrategy ;
1735
-
1736
1730
internal ServerEndPoint [ ] GetServerSnapshot ( )
1737
1731
{
1738
1732
var tmp = serverSnapshot ;
@@ -1742,12 +1736,12 @@ internal ServerEndPoint[] GetServerSnapshot()
1742
1736
internal ServerEndPoint SelectServer ( Message message )
1743
1737
{
1744
1738
if ( message == null ) return null ;
1745
- return serverSelectionStrategy . Select ( message ) ;
1739
+ return ServerSelectionStrategy . Select ( message ) ;
1746
1740
}
1747
1741
1748
1742
internal ServerEndPoint SelectServer ( int db , RedisCommand command , CommandFlags flags , RedisKey key )
1749
1743
{
1750
- return serverSelectionStrategy . Select ( db , command , key , flags ) ;
1744
+ return ServerSelectionStrategy . Select ( db , command , key , flags ) ;
1751
1745
}
1752
1746
1753
1747
private bool TryPushMessageToBridge < T > ( Message message , ResultProcessor < T > processor , ResultBox < T > resultBox , ref ServerEndPoint server )
@@ -1855,7 +1849,7 @@ public bool IsConnecting
1855
1849
1856
1850
internal ConfigurationOptions RawConfig => configuration ;
1857
1851
1858
- internal ServerSelectionStrategy ServerSelectionStrategy => serverSelectionStrategy ;
1852
+ internal ServerSelectionStrategy ServerSelectionStrategy { get ; }
1859
1853
1860
1854
/// <summary>
1861
1855
/// Close all connections and release all resources associated with this object
@@ -2005,7 +1999,7 @@ internal T ExecuteSyncImpl<T>(Message message, ResultProcessor<T> processor, Ser
2005
1999
throw ExceptionFactory . NoConnectionAvailable ( IncludeDetailInExceptions , IncludePerformanceCountersInExceptions , message . Command , message , server , GetServerSnapshot ( ) ) ;
2006
2000
}
2007
2001
2008
- if ( Monitor . Wait ( source , timeoutMilliseconds ) )
2002
+ if ( Monitor . Wait ( source , TimeoutMilliseconds ) )
2009
2003
{
2010
2004
Trace ( "Timeley response to " + message ) ;
2011
2005
}
0 commit comments