[ https://issues.apache.org/jira/browse/HDFS-13994?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16656002#comment-16656002 ]
Íñigo Goiri commented on HDFS-13994: ------------------------------------ Actually, I take it back, how is this not a "deadlock" (of 3 seconds)? We enter the {{waitForMinLength}} and then we take the lock() and wait for three seconds. Meanwhile, we get a packet and {{setLastChecksumAndDataLen()}} has to wait until {{waitForMinLength()}} is done. Am I missing something? Is it the same thread that does the wait and the set? I don't think so. > DataNode BlockSender waitForMinLength > ------------------------------------- > > Key: HDFS-13994 > URL: https://issues.apache.org/jira/browse/HDFS-13994 > Project: Hadoop HDFS > Issue Type: Improvement > Components: datanode > Affects Versions: 3.2.0 > Reporter: BELUGA BEHR > Assignee: BELUGA BEHR > Priority: Minor > Attachments: HDFS-13994.1.patch, HDFS-13994.2.patch, > HDFS-13994.3.patch, HDFS-13994.4.patch, HDFS-13994.5.patch > > > {code:java|title=BlockSender.java} > private static void waitForMinLength(ReplicaInPipeline rbw, long len) > throws IOException { > // Wait for 3 seconds for rbw replica to reach the minimum length > for (int i = 0; i < 30 && rbw.getBytesOnDisk() < len; i++) { > try { > Thread.sleep(100); > } catch (InterruptedException ie) { > throw new IOException(ie); > } > } > long bytesOnDisk = rbw.getBytesOnDisk(); > if (bytesOnDisk < len) { > throw new IOException( > String.format("Need %d bytes, but only %d bytes available", len, > bytesOnDisk)); > } > } > {code} > It is not very efficient to poll for status in this way. Instead, use > {{notifyAll}} within the {{ReplicaInPipeline}} to notify the caller when the > replica has reached a certain size. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org