HDFS-10693. metaSave should print blocks, not LightWeightHashSet. Contributed by Yuanbo Liu.
(cherry picked from commit 4d3af47f27
)
This commit is contained in:
parent
7bbd3cf650
commit
bfc261f2a0
|
@ -32,6 +32,7 @@ import org.apache.hadoop.hdfs.protocol.Block;
|
|||
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
|
||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||
import org.apache.hadoop.hdfs.util.LightWeightHashSet;
|
||||
import org.apache.hadoop.util.StringUtils;
|
||||
import org.apache.hadoop.util.Time;
|
||||
import org.apache.hadoop.hdfs.DFSUtil;
|
||||
|
||||
|
@ -140,7 +141,7 @@ class InvalidateBlocks {
|
|||
/** Print the contents to out. */
|
||||
synchronized void dump(final PrintWriter out) {
|
||||
final int size = node2blocks.values().size();
|
||||
out.println("Metasave: Blocks " + numBlocks
|
||||
out.println("Metasave: Blocks " + numBlocks
|
||||
+ " waiting deletion from " + size + " datanodes.");
|
||||
if (size == 0) {
|
||||
return;
|
||||
|
@ -150,7 +151,7 @@ class InvalidateBlocks {
|
|||
final LightWeightHashSet<Block> blocks = entry.getValue();
|
||||
if (blocks.size() > 0) {
|
||||
out.println(entry.getKey());
|
||||
out.println(blocks);
|
||||
out.println(StringUtils.join(",", blocks));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +197,7 @@ class InvalidateBlocks {
|
|||
numBlocks -= toInvalidate.size();
|
||||
return toInvalidate;
|
||||
}
|
||||
|
||||
|
||||
synchronized void clear() {
|
||||
node2blocks.clear();
|
||||
numBlocks = 0;
|
||||
|
|
|
@ -163,7 +163,9 @@ public class TestMetaSave {
|
|||
assertTrue(line.equals("Metasave: Blocks 2 waiting deletion from 1 datanodes."));
|
||||
//skip 2 lines to reach HDFS-9033 scenario.
|
||||
line = reader.readLine();
|
||||
// skip 1 line for Corrupt Blocks section.
|
||||
line = reader.readLine();
|
||||
assertTrue(line.contains("blk"));
|
||||
line = reader.readLine();
|
||||
assertTrue(line.equals("Metasave: Number of datanodes: 2"));
|
||||
line = reader.readLine();
|
||||
|
@ -221,7 +223,7 @@ public class TestMetaSave {
|
|||
|
||||
/**
|
||||
* Returns a File for the given name inside the log directory.
|
||||
*
|
||||
*
|
||||
* @param name String file name
|
||||
* @return File for given name inside log directory
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue