Skip to content

Commit

Permalink
[LI-HOTFIX] Add OneAboveMinIsrCounter sensor. (#71)
Browse files Browse the repository at this point in the history
TICKET =
LI_DESCRIPTION = Add the OneAboveMinIsrCounter metrics to help determining the good timing of broker rolling bounce.
EXIT_CRITERIA = MANUAL [""]
  • Loading branch information
kun du authored Jan 31, 2020
1 parent 4a0ec76 commit 5069ba4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/src/main/scala/kafka/cluster/Partition.scala
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ class Partition(val topicPartition: TopicPartition,
}
}

def isOneAboveMinIsr: Boolean = {
leaderReplicaIfLocal match {
case Some(leaderReplica) =>
inSyncReplicas.size == leaderReplica.log.get.config.minInSyncReplicas + 1
case None =>
false
}
}

/**
* Create the future replica if 1) the current replica is not in the given log directory and 2) the future replica
* does not exist. This method assumes that the current replica has already been created.
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/scala/kafka/server/ReplicaManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ class ReplicaManager(val config: KafkaConfig,
def value = leaderPartitionsIterator.count(_.isAtMinIsr)
}
)
val oneAboveMinIsrPartitionCount = newGauge(
"OneAboveMinIsrPartitionCount",
new Gauge[Int] {
def value = leaderPartitionsIterator.count(_.isOneAboveMinIsr)
}
)

val recompressionCount = newGauge(
"recompressionCount",
Expand Down

0 comments on commit 5069ba4

Please sign in to comment.