@@ -20,7 +20,9 @@ public RedisSentinelWorker(RedisSentinel sentinel, RedisEndpoint sentinelEndpoin
2020 this . sentinel = sentinel ;
2121 this . sentinelClient = new RedisClient ( sentinelEndpoint ) {
2222 Db = 0 , //Sentinel Servers doesn't support DB, reset to 0
23- ConnectTimeout = sentinel . SentinelWorkerTimeoutMs ,
23+ ConnectTimeout = sentinel . SentinelWorkerConnectTimeoutMs ,
24+ ReceiveTimeout = sentinel . SentinelWorkerReceiveTimeoutMs ,
25+ SendTimeout = sentinel . SentinelWorkerSendTimeoutMs ,
2426 } ;
2527
2628 if ( Log . IsDebugEnabled )
@@ -72,18 +74,21 @@ internal SentinelInfo GetSentinelInfo()
7274 internal string GetMasterHost ( string masterName )
7375 {
7476 var masterInfo = sentinelClient . SentinelGetMasterAddrByName ( masterName ) ;
75- if ( masterInfo . Count > 0 )
76- {
77- var ip = masterInfo [ 0 ] ;
78- var port = masterInfo [ 1 ] ;
77+ return masterInfo . Count > 0
78+ ? SanitizeMasterConfig ( masterInfo )
79+ : null ;
80+ }
7981
80- string aliasIp ;
81- if ( sentinel . IpAddressMap . TryGetValue ( ip , out aliasIp ) )
82- ip = aliasIp ;
82+ private string SanitizeMasterConfig ( List < string > masterInfo )
83+ {
84+ var ip = masterInfo [ 0 ] ;
85+ var port = masterInfo [ 1 ] ;
8386
84- return "{0}:{1}" . Fmt ( ip , port ) ;
85- }
86- return null ;
87+ string aliasIp ;
88+ if ( sentinel . IpAddressMap . TryGetValue ( ip , out aliasIp ) )
89+ ip = aliasIp ;
90+
91+ return "{0}:{1}" . Fmt ( ip , port ) ;
8792 }
8893
8994 internal List < string > GetSentinelHosts ( string masterName )
@@ -152,6 +157,14 @@ public void BeginListeningForConfigurationChanges()
152157 }
153158 }
154159
160+ public string ForceMasterFailover ( string masterName )
161+ {
162+ var masterInfo = this . sentinelClient . SentinelFailover ( masterName ) ;
163+ return masterInfo . Count > 0
164+ ? SanitizeMasterConfig ( masterInfo )
165+ : null ;
166+ }
167+
155168 public void Dispose ( )
156169 {
157170 new IDisposable [ ] { this . sentinelClient , sentinePubSub } . Dispose ( Log ) ;
0 commit comments