From c9024668420814efa6f548491808e677731bed95 Mon Sep 17 00:00:00 2001 From: zeekling Date: Mon, 6 Nov 2023 23:33:31 +0800 Subject: [PATCH] =?UTF-8?q?datanode=E5=90=AF=E5=8A=A8=E6=BA=90=E7=A0=81?= =?UTF-8?q?=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hdfs/dataNode启动过程.md | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/hdfs/dataNode启动过程.md b/hdfs/dataNode启动过程.md index 4632c75..7907308 100644 --- a/hdfs/dataNode启动过程.md +++ b/hdfs/dataNode启动过程.md @@ -126,6 +126,7 @@ private void doRefreshNamenodes( // Step 1. For each of the new nameservices, figure out whether // it's an update of the set of NNs for an existing NS, // or an entirely new nameservice. + // 判断当前DN中的nameservice是否已经存在:如果已经存在则需要刷新;否则需要添加。 for (String nameserviceId : addrMap.keySet()) { if (bpByNameserviceId.containsKey(nameserviceId)) { toRefresh.add(nameserviceId); @@ -136,20 +137,12 @@ private void doRefreshNamenodes( // Step 2. Any nameservices we currently have but are no longer present // need to be removed. + // 计算当前DN需要删除的nameservice toRemove = Sets.newHashSet(Sets.difference( bpByNameserviceId.keySet(), addrMap.keySet())); - assert toRefresh.size() + toAdd.size() == - addrMap.size() : - "toAdd: " + Joiner.on(",").useForNull("").join(toAdd) + - " toRemove: " + Joiner.on(",").useForNull("").join(toRemove) + - " toRefresh: " + Joiner.on(",").useForNull("").join(toRefresh); - - - // Step 3. Start new nameservices + // Step 3. 启动新的nameservice if (!toAdd.isEmpty()) { - LOG.info("Starting BPOfferServices for nameservices: " + - Joiner.on(",").useForNull("").join(toAdd)); for (String nsToAdd : toAdd) { Map nnIdToAddr = addrMap.get(nsToAdd); @@ -176,12 +169,10 @@ private void doRefreshNamenodes( startAll(); } - // Step 4. Shut down old nameservices. This happens outside + // Step 4. 停止掉老的nameservice. This happens outside // of the synchronized(this) lock since they need to call // back to .remove() from another thread if (!toRemove.isEmpty()) { - LOG.info("Stopping BPOfferServices for nameservices: " + - Joiner.on(",").useForNull("").join(toRemove)); for (String nsToRemove : toRemove) { BPOfferService bpos = bpByNameserviceId.get(nsToRemove); @@ -191,10 +182,9 @@ private void doRefreshNamenodes( } } - // Step 5. Update nameservices whose NN list has changed + // Step 5. Update nameservices whose NN list has changed + // 更新nameservices if (!toRefresh.isEmpty()) { - LOG.info("Refreshing list of NNs for nameservices: " + - Joiner.on(",").useForNull("").join(toRefresh)); for (String nsToRefresh : toRefresh) { BPOfferService bpos = bpByNameserviceId.get(nsToRefresh); @@ -218,6 +208,7 @@ private void doRefreshNamenodes( .doAs(new PrivilegedExceptionAction() { @Override public Object run() throws Exception { + // 刷新NNList 核心实现. bpos.refreshNNList(nsToRefresh, nnIds, addrs, lifelineAddrs); return null; }