Skip to content

Commit d496303

Browse files
author
lgh
committed
make only one fbr task is executing
1 parent d1b1d02 commit d496303

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,8 @@ public class DFSConfigKeys extends CommonConfigurationKeys {
972972
public static final boolean DFS_DATANODE_TRANSFERTO_ALLOWED_DEFAULT = true;
973973
public static final String DFS_HEARTBEAT_INTERVAL_KEY = "dfs.heartbeat.interval";
974974
public static final long DFS_HEARTBEAT_INTERVAL_DEFAULT = 3;
975-
public static final String DFS_HEARTBEAT_REREGISTER_INTERVAL_KEY = "dfs.heartbeat.reregister,interval";
976-
public static final long DFS_HEARTBEAT_REREGISTER_INTERVAL__DEFAULT = 9;
975+
public static final String DFS_HEARTBEAT_REREGISTER_INTERVAL_KEY = "dfs.heartbeat.reregister.interval";
976+
public static final long DFS_HEARTBEAT_REREGISTER_INTERVAL_DEFAULT = 6;
977977
public static final String DFS_DATANODE_LIFELINE_INTERVAL_SECONDS_KEY =
978978
"dfs.datanode.lifeline.interval.seconds";
979979
public static final String DFS_NAMENODE_PATH_BASED_CACHE_RETRY_INTERVAL_MS = "dfs.namenode.path.based.cache.retry.interval.ms";

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ enum RunningState {
123123
private final DNConf dnConf;
124124
private long prevBlockReportId;
125125
private volatile long fullBlockReportLeaseId;
126+
private volatile boolean shouldSendFBR = true;
126127
private final SortedSet<Integer> blockReportSizes =
127128
Collections.synchronizedSortedSet(new TreeSet<>());
128129
private final int maxDataLength;
@@ -149,6 +150,7 @@ enum RunningState {
149150
dn.getMetrics());
150151
prevBlockReportId = ThreadLocalRandom.current().nextLong();
151152
fullBlockReportLeaseId = 0;
153+
shouldSendFBR = true;
152154
scheduler = new Scheduler(dnConf.heartBeatInterval,
153155
dnConf.getLifelineIntervalMs(), dnConf.blockReportInterval,
154156
dnConf.outliersReportIntervalMs, dnConf.heartBeatReRegisterInterval);
@@ -771,7 +773,8 @@ private void offerService() throws Exception {
771773
if (forceFullBr) {
772774
LOG.info("Forcing a full block report to " + nnAddr);
773775
}
774-
if ((fullBlockReportLeaseId != 0) || forceFullBr) {
776+
if ((fullBlockReportLeaseId != 0 && shouldSendFBR) || forceFullBr) {
777+
shouldSendFBR = false;
775778
fbrExecutorService.submit(new FBRTaskHandler());
776779
}
777780

@@ -799,6 +802,7 @@ private void offerService() throws Exception {
799802
}
800803
if (InvalidBlockReportLeaseException.class.getName().equals(reClass)) {
801804
fullBlockReportLeaseId = 0;
805+
shouldSendFBR = true;
802806
}
803807
LOG.warn("RemoteException in offerService", re);
804808
sleepAfterException();
@@ -873,6 +877,7 @@ void register(NamespaceInfo nsInfo) throws IOException {
873877
// reset lease id whenever registered to NN.
874878
// ask for a new lease id at the next heartbeat.
875879
fullBlockReportLeaseId = 0;
880+
shouldSendFBR = true;
876881

877882
// random short delay - helps scatter the BR from all DNs
878883
scheduler.scheduleBlockReport(dnConf.initialBlockReportDelayMs, true);
@@ -1212,8 +1217,10 @@ public void run() {
12121217
}
12131218
fullBlockReportLeaseId = 0;
12141219
commandProcessingThread.enqueue(cmds);
1220+
shouldSendFBR = true;
12151221
} catch (Throwable t) {
12161222
fullBlockReportLeaseId = 0;
1223+
shouldSendFBR = true;
12171224
LOG.warn("InterruptedException in FBR Task Handler.", t);
12181225
sleepAndLogInterrupts(5000, "offering FBR service");
12191226
synchronized(ibrManager) {

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DNConf.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_ENCRYPT_DATA_OVERWRITE_DOWNSTREAM_DERIVED_QOP_DEFAULT;
4141
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_ENCRYPT_DATA_OVERWRITE_DOWNSTREAM_DERIVED_QOP_KEY;
4242
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HEARTBEAT_REREGISTER_INTERVAL_KEY;
43-
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HEARTBEAT_REREGISTER_INTERVAL__DEFAULT;
43+
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HEARTBEAT_REREGISTER_INTERVAL_DEFAULT;
4444
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_SOCKET_TIMEOUT_KEY;
4545
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_MAX_LOCKED_MEMORY_DEFAULT;
4646
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_MAX_LOCKED_MEMORY_KEY;
@@ -223,7 +223,7 @@ public DNConf(final Configurable dn) {
223223
DFS_HEARTBEAT_INTERVAL_DEFAULT, TimeUnit.SECONDS,
224224
TimeUnit.MILLISECONDS);
225225
heartBeatReRegisterInterval = getConf().getTimeDuration(DFS_HEARTBEAT_REREGISTER_INTERVAL_KEY,
226-
DFS_HEARTBEAT_REREGISTER_INTERVAL__DEFAULT, TimeUnit.SECONDS,
226+
DFS_HEARTBEAT_REREGISTER_INTERVAL_DEFAULT, TimeUnit.SECONDS,
227227
TimeUnit.MILLISECONDS);
228228
long confLifelineIntervalMs =
229229
getConf().getLong(DFS_DATANODE_LIFELINE_INTERVAL_SECONDS_KEY,

0 commit comments

Comments
 (0)