HDFS-7979. Initialize block report IDs with a random number.
(cherry picked from commit b1e059089d
)
This commit is contained in:
parent
eafee9a04e
commit
351fac25a9
|
@ -89,6 +89,8 @@ Release 2.8.0 - UNRELEASED
|
||||||
|
|
||||||
HDFS-8089. Move o.a.h.hdfs.web.resources.* to the client jars. (wheat9)
|
HDFS-8089. Move o.a.h.hdfs.web.resources.* to the client jars. (wheat9)
|
||||||
|
|
||||||
|
HDFS-7979. Initialize block report IDs with a random number. (wang)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
|
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
|
||||||
|
|
|
@ -118,6 +118,7 @@ class BPServiceActor implements Runnable {
|
||||||
private volatile boolean shouldServiceRun = true;
|
private volatile boolean shouldServiceRun = true;
|
||||||
private final DataNode dn;
|
private final DataNode dn;
|
||||||
private final DNConf dnConf;
|
private final DNConf dnConf;
|
||||||
|
private long prevBlockReportId;
|
||||||
|
|
||||||
private DatanodeRegistration bpRegistration;
|
private DatanodeRegistration bpRegistration;
|
||||||
final LinkedList<BPServiceActorAction> bpThreadQueue
|
final LinkedList<BPServiceActorAction> bpThreadQueue
|
||||||
|
@ -128,6 +129,7 @@ class BPServiceActor implements Runnable {
|
||||||
this.dn = bpos.getDataNode();
|
this.dn = bpos.getDataNode();
|
||||||
this.nnAddr = nnAddr;
|
this.nnAddr = nnAddr;
|
||||||
this.dnConf = dn.getDnConf();
|
this.dnConf = dn.getDnConf();
|
||||||
|
prevBlockReportId = DFSUtil.getRandom().nextLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isAlive() {
|
boolean isAlive() {
|
||||||
|
@ -434,15 +436,15 @@ class BPServiceActor implements Runnable {
|
||||||
return sendImmediateIBR;
|
return sendImmediateIBR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long prevBlockReportId = 0;
|
|
||||||
|
|
||||||
private long generateUniqueBlockReportId() {
|
private long generateUniqueBlockReportId() {
|
||||||
long id = System.nanoTime();
|
// Initialize the block report ID the first time through.
|
||||||
if (id <= prevBlockReportId) {
|
// Note that 0 is used on the NN to indicate "uninitialized", so we should
|
||||||
id = prevBlockReportId + 1;
|
// not send a 0 value ourselves.
|
||||||
|
prevBlockReportId++;
|
||||||
|
while (prevBlockReportId == 0) {
|
||||||
|
prevBlockReportId = DFSUtil.getRandom().nextLong();
|
||||||
}
|
}
|
||||||
prevBlockReportId = id;
|
return prevBlockReportId;
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hdfs.server.protocol;
|
package org.apache.hadoop.hdfs.server.protocol;
|
||||||
|
|
||||||
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The context of the block report.
|
* The context of the block report.
|
||||||
*
|
*
|
||||||
|
@ -27,6 +29,7 @@ package org.apache.hadoop.hdfs.server.protocol;
|
||||||
* of RPCs which this block report is split into, and the index into that
|
* of RPCs which this block report is split into, and the index into that
|
||||||
* total for the current RPC.
|
* total for the current RPC.
|
||||||
*/
|
*/
|
||||||
|
@InterfaceAudience.Private
|
||||||
public class BlockReportContext {
|
public class BlockReportContext {
|
||||||
private final int totalRpcs;
|
private final int totalRpcs;
|
||||||
private final int curRpc;
|
private final int curRpc;
|
||||||
|
|
Loading…
Reference in New Issue