Skip to content

Commit

Permalink
Problem
Browse files Browse the repository at this point in the history
In Redis 3.2 and newer, the property `pending-commands` was renamed to
`link-pending-commands`. The current implementation only checks for
the former in the `props` and so throws an invalid property exception.

Solution

Check for both properties in `props` to preserve compatibility.

Signed-off-by: Ruben Oanta <[email protected]>

comments and CHANGES

more changes fixes

RB_ID=913516
  • Loading branch information
Tomas Edwardsson authored and jenkins committed Apr 3, 2017
1 parent 7028146 commit e89eacb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ Breaking API Changes
to `ThriftMethod.SuccessType` instead of `ThriftMethod.Args` to `ThriftMethod.Result`.
``RB_ID=908846``

* finagle-redis: Remove pendingCommands from `c.t.f.finagle.redis.SentinelClient.Node` and
add linkPendingCommands for compatibility with redis 3.2 and newer.
``RB_ID=913516``

Runtime Behavior Changes
~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -279,6 +283,9 @@ Bug Fixes
* finagle-thrift: Properly locate sub-classed MethodIface services to instantiate for serving
BaseServiceIface implemented thrift services. ``RB_ID=907608``

* finagle-redis: The SentinelClient will no longer throw an NoSuchElementException when
initializing connections to a redis 3.2 or greater sentinel server. ``RB_ID=913516``

Dependencies
~~~~~~~~~~~~

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,29 @@ object SentinelClient {
*/
def apply(raw: ServiceFactory[Command, Reply]): SentinelClient =
new SentinelClient(raw)

sealed trait Node {
val props: Map[String, String]
val name: String = props("name")
val ip: String = props("ip")
val port: Int = props("port").toInt
val runid: String = props("runid")
val flags: Seq[String] = props("flags").split(",")
val pendingCommands: Int = props("pending-commands").toInt
// In Redis 3.2 and newer, the property was renamed to link-pending-commands
// preserve compatibility with older releases.
val linkPendingCommands: Int = props.get("link-pending-commands")
.getOrElse(props("pending-commands")).toInt
val lastPingSent: Int = props("last-ping-sent").toInt
val lastPingReply: Int = props("last-ping-reply").toInt
val downAfterMilliseconds: Int = props("down-after-milliseconds").toInt
}

sealed trait DataNode extends Node {
val infoRefresh: Long = props("info-refresh").toLong
val roleReported: String = props("role-reported")
val roleReportedTime: Long = props("role-reported-time").toLong
val roleReportedTime: Long = props("role-reported-time").toLong
}

class MasterNode private[redis] (val props: Map[String, String]) extends DataNode {
val quorum: Int = props("quorum").toInt
val configEpoch: Option[Long] = props.get("configEpoch").map(_.toLong)
Expand All @@ -46,7 +49,7 @@ object SentinelClient {
val failoverTimeout: Int = props("failover-timeout").toInt
val parallelSyncs: Int = props("parallel-syncs").toInt
}

class SlaveNode private[redis] (val props: Map[String, String]) extends DataNode {
val masterLinkDownTime: Int = props("master-link-down-time").toInt
val masterLinkStatus: String = props("master-link-status")
Expand All @@ -55,7 +58,7 @@ object SentinelClient {
val slavePriority: Int = props("slave-priority").toInt
val slaveReplOffset: Long = props("slave-repl-offset").toLong
}

class SentinelNode private[redis] (val props: Map[String, String]) extends Node {
val lastHelloMessage: Int = props("last-hello-message").toInt
val votedLeader: String = props("voted-leader")
Expand Down

0 comments on commit e89eacb

Please sign in to comment.