|
45 | 45 | import java.util.List; |
46 | 46 | import java.util.Map; |
47 | 47 | import java.util.Set; |
48 | | -import java.util.concurrent.Callable; |
49 | 48 |
|
50 | 49 | import com.google.common.collect.Lists; |
51 | 50 |
|
|
175 | 174 | import org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration; |
176 | 175 | import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo; |
177 | 176 | import org.apache.hadoop.hdfs.server.protocol.NodeRegistration; |
| 177 | +import org.apache.hadoop.hdfs.server.protocol.RegisterCommand; |
178 | 178 | import org.apache.hadoop.hdfs.server.protocol.RemoteEditLogManifest; |
179 | 179 | import org.apache.hadoop.hdfs.server.protocol.SlowDiskReports; |
180 | 180 | import org.apache.hadoop.hdfs.server.protocol.SlowPeerReports; |
@@ -1591,21 +1591,25 @@ public DatanodeCommand blockReport(final DatanodeRegistration nodeReg, |
1591 | 1591 | } |
1592 | 1592 | final BlockManager bm = namesystem.getBlockManager(); |
1593 | 1593 | boolean noStaleStorages = false; |
1594 | | - for (int r = 0; r < reports.length; r++) { |
1595 | | - final BlockListAsLongs blocks = reports[r].getBlocks(); |
1596 | | - // |
1597 | | - // BlockManager.processReport accumulates information of prior calls |
1598 | | - // for the same node and storage, so the value returned by the last |
1599 | | - // call of this loop is the final updated value for noStaleStorage. |
1600 | | - // |
1601 | | - final int index = r; |
1602 | | - noStaleStorages = bm.runBlockOp(new Callable<Boolean>() { |
1603 | | - @Override |
1604 | | - public Boolean call() throws IOException { |
1605 | | - return bm.processReport(nodeReg, reports[index].getStorage(), |
1606 | | - blocks, context); |
| 1594 | + try { |
| 1595 | + if (bm.checkBlockReportLease(context, nodeReg)) { |
| 1596 | + for (int r = 0; r < reports.length; r++) { |
| 1597 | + final BlockListAsLongs blocks = reports[r].getBlocks(); |
| 1598 | + // |
| 1599 | + // BlockManager.processReport accumulates information of prior calls |
| 1600 | + // for the same node and storage, so the value returned by the last |
| 1601 | + // call of this loop is the final updated value for noStaleStorage. |
| 1602 | + // |
| 1603 | + final int index = r; |
| 1604 | + noStaleStorages = bm.runBlockOp(() -> |
| 1605 | + bm.processReport(nodeReg, reports[index].getStorage(), |
| 1606 | + blocks, context)); |
1607 | 1607 | } |
1608 | | - }); |
| 1608 | + } |
| 1609 | + } catch (UnregisteredNodeException une) { |
| 1610 | + LOG.debug("Datanode {} is attempting to report but not register yet.", |
| 1611 | + nodeReg); |
| 1612 | + return RegisterCommand.REGISTER; |
1609 | 1613 | } |
1610 | 1614 | bm.removeBRLeaseIfNeeded(nodeReg, context); |
1611 | 1615 |
|
|
0 commit comments