HDFS-1522. Combine two BLOCK_FILE_PREFIX constants into one. Contributed by Dongming Liang.
This commit is contained in:
parent
53947f37c7
commit
430b537188
|
@ -706,6 +706,9 @@ Release 2.7.0 - UNRELEASED
|
||||||
|
|
||||||
HDFS-7535. Utilize Snapshot diff report for distcp. (jing9)
|
HDFS-7535. Utilize Snapshot diff report for distcp. (jing9)
|
||||||
|
|
||||||
|
HDFS-1522. Combine two BLOCK_FILE_PREFIX constants into one.
|
||||||
|
(Dongming Liang via shv)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-7454. Reduce memory footprint for AclEntries in NameNode.
|
HDFS-7454. Reduce memory footprint for AclEntries in NameNode.
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.hadoop.fs.FSInputChecker;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.ReadOption;
|
import org.apache.hadoop.fs.ReadOption;
|
||||||
import org.apache.hadoop.hdfs.net.Peer;
|
import org.apache.hadoop.hdfs.net.Peer;
|
||||||
|
import org.apache.hadoop.hdfs.protocol.Block;
|
||||||
import org.apache.hadoop.hdfs.protocol.DatanodeID;
|
import org.apache.hadoop.hdfs.protocol.DatanodeID;
|
||||||
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
|
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
|
||||||
import org.apache.hadoop.hdfs.protocol.datatransfer.DataTransferProtoUtil;
|
import org.apache.hadoop.hdfs.protocol.datatransfer.DataTransferProtoUtil;
|
||||||
|
@ -351,7 +352,8 @@ public class RemoteBlockReader extends FSInputChecker implements BlockReader {
|
||||||
long startOffset, long firstChunkOffset, long bytesToRead, Peer peer,
|
long startOffset, long firstChunkOffset, long bytesToRead, Peer peer,
|
||||||
DatanodeID datanodeID, PeerCache peerCache) {
|
DatanodeID datanodeID, PeerCache peerCache) {
|
||||||
// Path is used only for printing block and file information in debug
|
// Path is used only for printing block and file information in debug
|
||||||
super(new Path("/blk_" + blockId + ":" + bpid + ":of:"+ file)/*too non path-like?*/,
|
super(new Path("/" + Block.BLOCK_FILE_PREFIX + blockId +
|
||||||
|
":" + bpid + ":of:"+ file)/*too non path-like?*/,
|
||||||
1, verifyChecksum,
|
1, verifyChecksum,
|
||||||
checksum.getChecksumSize() > 0? checksum : null,
|
checksum.getChecksumSize() > 0? checksum : null,
|
||||||
checksum.getBytesPerChecksum(),
|
checksum.getBytesPerChecksum(),
|
||||||
|
|
|
@ -83,7 +83,6 @@ import java.util.concurrent.Future;
|
||||||
public class DataStorage extends Storage {
|
public class DataStorage extends Storage {
|
||||||
|
|
||||||
public final static String BLOCK_SUBDIR_PREFIX = "subdir";
|
public final static String BLOCK_SUBDIR_PREFIX = "subdir";
|
||||||
final static String BLOCK_FILE_PREFIX = "blk_";
|
|
||||||
final static String COPY_FILE_PREFIX = "dncp_";
|
final static String COPY_FILE_PREFIX = "dncp_";
|
||||||
final static String STORAGE_DIR_DETACHED = "detach";
|
final static String STORAGE_DIR_DETACHED = "detach";
|
||||||
public final static String STORAGE_DIR_RBW = "rbw";
|
public final static String STORAGE_DIR_RBW = "rbw";
|
||||||
|
@ -1250,7 +1249,7 @@ public class DataStorage extends Storage {
|
||||||
String[] blockNames = from.list(new java.io.FilenameFilter() {
|
String[] blockNames = from.list(new java.io.FilenameFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
return name.startsWith(BLOCK_FILE_PREFIX);
|
return name.startsWith(Block.BLOCK_FILE_PREFIX);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -633,7 +633,7 @@ public class DirectoryScanner implements Runnable {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!Block.isBlockFilename(files[i])) {
|
if (!Block.isBlockFilename(files[i])) {
|
||||||
if (isBlockMetaFile("blk_", files[i].getName())) {
|
if (isBlockMetaFile(Block.BLOCK_FILE_PREFIX, files[i].getName())) {
|
||||||
long blockId = Block.getBlockId(files[i].getName());
|
long blockId = Block.getBlockId(files[i].getName());
|
||||||
verifyFileLocation(files[i].getParentFile(), bpFinalizedDir,
|
verifyFileLocation(files[i].getParentFile(), bpFinalizedDir,
|
||||||
blockId);
|
blockId);
|
||||||
|
|
|
@ -430,7 +430,8 @@ public class FsVolumeImpl implements FsVolumeSpi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
return !name.endsWith(".meta") && name.startsWith("blk_");
|
return !name.endsWith(".meta") &&
|
||||||
|
name.startsWith(Block.BLOCK_FILE_PREFIX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,7 +301,7 @@ public class NamenodeFsck implements DataEncryptionKeyFactory {
|
||||||
out.println(sb.toString());
|
out.println(sb.toString());
|
||||||
sb.append(" for blockIds: \n");
|
sb.append(" for blockIds: \n");
|
||||||
for (String blk: blocks) {
|
for (String blk: blocks) {
|
||||||
if(blk == null || !blk.contains("blk_")) {
|
if(blk == null || !blk.contains(Block.BLOCK_FILE_PREFIX)) {
|
||||||
out.println("Incorrect blockId format: " + blk);
|
out.println("Incorrect blockId format: " + blk);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2544,8 +2544,8 @@ public class MiniDFSCluster {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (File f : files) {
|
for (File f : files) {
|
||||||
if (f.getName().startsWith("blk_") && f.getName().endsWith(
|
if (f.getName().startsWith(Block.BLOCK_FILE_PREFIX) &&
|
||||||
Block.METADATA_EXTENSION)) {
|
f.getName().endsWith(Block.METADATA_EXTENSION)) {
|
||||||
results.add(f);
|
results.add(f);
|
||||||
} else if (f.isDirectory()) {
|
} else if (f.isDirectory()) {
|
||||||
List<File> subdirResults = getAllBlockMetadataFiles(f);
|
List<File> subdirResults = getAllBlockMetadataFiles(f);
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.apache.hadoop.fs.FSDataInputStream;
|
||||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.hdfs.DFSClientFaultInjector;
|
import org.apache.hadoop.hdfs.DFSClientFaultInjector;
|
||||||
|
import org.apache.hadoop.hdfs.protocol.Block;
|
||||||
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
|
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
|
||||||
import org.apache.hadoop.io.IOUtils;
|
import org.apache.hadoop.io.IOUtils;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -176,7 +177,7 @@ public class TestCrcCorruption {
|
||||||
assertTrue("Blocks do not exist in data-dir", (blocks != null) && (blocks.length > 0));
|
assertTrue("Blocks do not exist in data-dir", (blocks != null) && (blocks.length > 0));
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for (int idx = 0; idx < blocks.length; idx++) {
|
for (int idx = 0; idx < blocks.length; idx++) {
|
||||||
if (blocks[idx].getName().startsWith("blk_") &&
|
if (blocks[idx].getName().startsWith(Block.BLOCK_FILE_PREFIX) &&
|
||||||
blocks[idx].getName().endsWith(".meta")) {
|
blocks[idx].getName().endsWith(".meta")) {
|
||||||
num++;
|
num++;
|
||||||
if (num % 3 == 0) {
|
if (num % 3 == 0) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class TestFileCorruption {
|
||||||
File[] blocks = data_dir.listFiles();
|
File[] blocks = data_dir.listFiles();
|
||||||
assertTrue("Blocks do not exist in data-dir", (blocks != null) && (blocks.length > 0));
|
assertTrue("Blocks do not exist in data-dir", (blocks != null) && (blocks.length > 0));
|
||||||
for (int idx = 0; idx < blocks.length; idx++) {
|
for (int idx = 0; idx < blocks.length; idx++) {
|
||||||
if (!blocks[idx].getName().startsWith("blk_")) {
|
if (!blocks[idx].getName().startsWith(Block.BLOCK_FILE_PREFIX)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
System.out.println("Deliberately removing file "+blocks[idx].getName());
|
System.out.println("Deliberately removing file "+blocks[idx].getName());
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
|
||||||
import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
|
||||||
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
||||||
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
||||||
|
import org.apache.hadoop.hdfs.protocol.Block;
|
||||||
import org.apache.hadoop.hdfs.server.datanode.SimulatedFSDataset;
|
import org.apache.hadoop.hdfs.server.datanode.SimulatedFSDataset;
|
||||||
import org.apache.hadoop.util.Time;
|
import org.apache.hadoop.util.Time;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -511,7 +512,7 @@ public class TestReplication {
|
||||||
String blockFile = null;
|
String blockFile = null;
|
||||||
File[] listFiles = participatedNodeDirs.listFiles();
|
File[] listFiles = participatedNodeDirs.listFiles();
|
||||||
for (File file : listFiles) {
|
for (File file : listFiles) {
|
||||||
if (file.getName().startsWith("blk_")
|
if (file.getName().startsWith(Block.BLOCK_FILE_PREFIX)
|
||||||
&& !file.getName().endsWith("meta")) {
|
&& !file.getName().endsWith("meta")) {
|
||||||
blockFile = file.getName();
|
blockFile = file.getName();
|
||||||
for (File file1 : nonParticipatedNodeDirs) {
|
for (File file1 : nonParticipatedNodeDirs) {
|
||||||
|
|
|
@ -319,7 +319,7 @@ public class TestDataNodeVolumeFailure {
|
||||||
private boolean deteteBlocks(File dir) {
|
private boolean deteteBlocks(File dir) {
|
||||||
File [] fileList = dir.listFiles();
|
File [] fileList = dir.listFiles();
|
||||||
for(File f : fileList) {
|
for(File f : fileList) {
|
||||||
if(f.getName().startsWith("blk_")) {
|
if(f.getName().startsWith(Block.BLOCK_FILE_PREFIX)) {
|
||||||
if(!f.delete())
|
if(!f.delete())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue