Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
Catch exception when populating ReplicaStats (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
kabochya authored Sep 24, 2019
1 parent 4d85678 commit e71fbc7
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ public ReplicaStat call() throws Exception {

LOG.info("logSizeMetric = {}", logSizeMetric);

ObjectName objectName = new ObjectName(logSizeMetric);
Long longValue = (Long) mbs.getAttribute(objectName, "Value");
replicaStat.setLogSizeInBytes(longValue);
Long longValue = 0L;
try {
longValue = (Long) mbs.getAttribute(new ObjectName(logSizeMetric), "Value");
replicaStat.setLogSizeInBytes(longValue);
} catch (InstanceNotFoundException e) {
LOG.info("Could not find metric {}", logSizeMetric, e);
}

String numSegmentsMetric = String.format(
"kafka.log:type=Log,name=NumLogSegments,topic=%s,partition=%d",
Expand All @@ -65,7 +69,7 @@ public ReplicaStat call() throws Exception {
intValue = (Integer) mbs.getAttribute(new ObjectName(numSegmentsMetric), "Value");
replicaStat.setNumLogSegments(intValue);
} catch (InstanceNotFoundException e) {
LOG.info("Did to find metric {}", numSegmentsMetric, e);
LOG.info("Could not find metric {}", numSegmentsMetric, e);
}

String startOffsetMetric = String.format(
Expand All @@ -75,7 +79,7 @@ public ReplicaStat call() throws Exception {
longValue = (Long) mbs.getAttribute(new ObjectName(startOffsetMetric), "Value");
replicaStat.setStartOffset(longValue);
} catch (InstanceNotFoundException e) {
LOG.info("Did to find metric {}", startOffsetMetric, e);
LOG.info("Could not find metric {}", startOffsetMetric, e);
}

String endOffsetMetric = String.format(
Expand All @@ -85,7 +89,7 @@ public ReplicaStat call() throws Exception {
longValue = (Long) mbs.getAttribute(new ObjectName(endOffsetMetric), "Value");
replicaStat.setEndOffset(longValue);
} catch (InstanceNotFoundException e) {
LOG.info("Did to find metric {}", endOffsetMetric, e);
LOG.info("Could not find metric {}", endOffsetMetric, e);
}

String underReplicatedMetric = String.format(
Expand All @@ -95,7 +99,7 @@ public ReplicaStat call() throws Exception {
intValue = (Integer) mbs.getAttribute(new ObjectName(underReplicatedMetric), "Value");
replicaStat.setUnderReplicated(intValue != 0);
} catch (InstanceNotFoundException e) {
LOG.info("Did to find metric {}", underReplicatedMetric, e);
LOG.info("Could not find metric {}", underReplicatedMetric, e);
}
replicaStat.setIsLeader(isLeader);
replicaStat.setInReassignment(inReassignment);
Expand Down

0 comments on commit e71fbc7

Please sign in to comment.