Skip to content

Commit

Permalink
HDFS-17273. Change the way of computing some local variables duration…
Browse files Browse the repository at this point in the history
… for better debugging (apache#6321). Contributed by farmmamba.

Reviewed-by: Haiyang Hu <[email protected]>
Reviewed-by: Tao Li <[email protected]>
Signed-off-by: He Xiaoqiao <[email protected]>
  • Loading branch information
hfutatzhanghb authored Dec 24, 2023
1 parent 77edca8 commit 415e9bd
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ public void run() {
scope = null;
dataQueue.removeFirst();
ackQueue.addLast(one);
packetSendTime.put(one.getSeqno(), Time.monotonicNow());
packetSendTime.put(one.getSeqno(), Time.monotonicNowNanos());
dataQueue.notifyAll();
}
}
Expand Down Expand Up @@ -953,7 +953,7 @@ void waitForAckedSeqno(long seqno) throws IOException {
dnodes = nodes != null ? nodes.length : 3;
}
int writeTimeout = dfsClient.getDatanodeWriteTimeout(dnodes);
long begin = Time.monotonicNow();
long begin = Time.monotonicNowNanos();
try {
synchronized (dataQueue) {
while (!streamerClosed) {
Expand All @@ -963,14 +963,14 @@ void waitForAckedSeqno(long seqno) throws IOException {
}
try {
dataQueue.wait(1000); // when we receive an ack, we notify on
long duration = Time.monotonicNow() - begin;
if (duration > writeTimeout) {
long duration = Time.monotonicNowNanos() - begin;
if (TimeUnit.NANOSECONDS.toMillis(duration) > writeTimeout) {
LOG.error("No ack received, took {}ms (threshold={}ms). "
+ "File being written: {}, block: {}, "
+ "Write pipeline datanodes: {}.",
duration, writeTimeout, src, block, nodes);
TimeUnit.NANOSECONDS.toMillis(duration), writeTimeout, src, block, nodes);
throw new InterruptedIOException("No ack received after " +
duration / 1000 + "s and a timeout of " +
TimeUnit.NANOSECONDS.toSeconds(duration) + "s and a timeout of " +
writeTimeout / 1000 + "s");
}
// dataQueue
Expand All @@ -984,11 +984,12 @@ void waitForAckedSeqno(long seqno) throws IOException {
} catch (ClosedChannelException cce) {
LOG.debug("Closed channel exception", cce);
}
long duration = Time.monotonicNow() - begin;
if (duration > dfsclientSlowLogThresholdMs) {
long duration = Time.monotonicNowNanos() - begin;
if (TimeUnit.NANOSECONDS.toMillis(duration) > dfsclientSlowLogThresholdMs) {
LOG.warn("Slow waitForAckedSeqno took {}ms (threshold={}ms). File being"
+ " written: {}, block: {}, Write pipeline datanodes: {}.",
duration, dfsclientSlowLogThresholdMs, src, block, nodes);
TimeUnit.NANOSECONDS.toMillis(duration), dfsclientSlowLogThresholdMs,
src, block, nodes);
}
}
}
Expand Down Expand Up @@ -1179,10 +1180,10 @@ public void run() {
if (ack.getSeqno() != DFSPacket.HEART_BEAT_SEQNO) {
Long begin = packetSendTime.get(ack.getSeqno());
if (begin != null) {
long duration = Time.monotonicNow() - begin;
if (duration > dfsclientSlowLogThresholdMs) {
long duration = Time.monotonicNowNanos() - begin;
if (TimeUnit.NANOSECONDS.toMillis(duration) > dfsclientSlowLogThresholdMs) {
LOG.info("Slow ReadProcessor read fields for block " + block
+ " took " + duration + "ms (threshold="
+ " took " + TimeUnit.NANOSECONDS.toMillis(duration) + "ms (threshold="
+ dfsclientSlowLogThresholdMs + "ms); ack: " + ack
+ ", targets: " + Arrays.asList(targets));
}
Expand Down

0 comments on commit 415e9bd

Please sign in to comment.