HDFS-6150. Add inode id information in the logs to make debugging easier. Contributed by Suresh Srinivas.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1581914 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b5935fab44
commit
c00703dd08
@ -449,6 +449,9 @@ Release 2.4.0 - UNRELEASED
|
|||||||
HDFS-5910. Enhance DataTransferProtocol to allow per-connection choice
|
HDFS-5910. Enhance DataTransferProtocol to allow per-connection choice
|
||||||
of encryption/plain-text. (Benoy Antony via Arpit Agarwal)
|
of encryption/plain-text. (Benoy Antony via Arpit Agarwal)
|
||||||
|
|
||||||
|
HDFS-6150. Add inode id information in the logs to make debugging easier.
|
||||||
|
(suresh)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-5790. LeaseManager.findPath is very slow when many leases need recovery
|
HDFS-5790. LeaseManager.findPath is very slow when many leases need recovery
|
||||||
|
@ -2274,8 +2274,8 @@ private void startFileInternal(FSPermissionChecker pc, String src,
|
|||||||
final INodesInPath iip = dir.getINodesInPath4Write(src);
|
final INodesInPath iip = dir.getINodesInPath4Write(src);
|
||||||
final INode inode = iip.getLastINode();
|
final INode inode = iip.getLastINode();
|
||||||
if (inode != null && inode.isDirectory()) {
|
if (inode != null && inode.isDirectory()) {
|
||||||
throw new FileAlreadyExistsException("Cannot create file " + src
|
throw new FileAlreadyExistsException(src +
|
||||||
+ "; already exists as a directory.");
|
" already exists as a directory");
|
||||||
}
|
}
|
||||||
final INodeFile myFile = INodeFile.valueOf(inode, src, true);
|
final INodeFile myFile = INodeFile.valueOf(inode, src, true);
|
||||||
if (isPermissionEnabled) {
|
if (isPermissionEnabled) {
|
||||||
@ -2293,8 +2293,8 @@ private void startFileInternal(FSPermissionChecker pc, String src,
|
|||||||
try {
|
try {
|
||||||
if (myFile == null) {
|
if (myFile == null) {
|
||||||
if (!create) {
|
if (!create) {
|
||||||
throw new FileNotFoundException("failed to overwrite non-existent file "
|
throw new FileNotFoundException("Can't overwrite non-existent " +
|
||||||
+ src + " on client " + clientMachine);
|
src + " for client " + clientMachine);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
@ -2307,8 +2307,8 @@ private void startFileInternal(FSPermissionChecker pc, String src,
|
|||||||
} else {
|
} else {
|
||||||
// If lease soft limit time is expired, recover the lease
|
// If lease soft limit time is expired, recover the lease
|
||||||
recoverLeaseInternal(myFile, src, holder, clientMachine, false);
|
recoverLeaseInternal(myFile, src, holder, clientMachine, false);
|
||||||
throw new FileAlreadyExistsException("failed to create file " + src
|
throw new FileAlreadyExistsException(src + " for client " +
|
||||||
+ " on client " + clientMachine + " because the file exists");
|
clientMachine + " already exists");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2319,8 +2319,7 @@ private void startFileInternal(FSPermissionChecker pc, String src,
|
|||||||
INodeFile newNode = dir.addFile(src, permissions, replication, blockSize,
|
INodeFile newNode = dir.addFile(src, permissions, replication, blockSize,
|
||||||
holder, clientMachine, clientNode);
|
holder, clientMachine, clientNode);
|
||||||
if (newNode == null) {
|
if (newNode == null) {
|
||||||
throw new IOException("DIR* NameSystem.startFile: " +
|
throw new IOException("Unable to add " + src + " to namespace");
|
||||||
"Unable to add file to namespace.");
|
|
||||||
}
|
}
|
||||||
leaseManager.addLease(newNode.getFileUnderConstructionFeature()
|
leaseManager.addLease(newNode.getFileUnderConstructionFeature()
|
||||||
.getClientName(), src);
|
.getClientName(), src);
|
||||||
@ -2328,12 +2327,12 @@ private void startFileInternal(FSPermissionChecker pc, String src,
|
|||||||
// record file record in log, record new generation stamp
|
// record file record in log, record new generation stamp
|
||||||
getEditLog().logOpenFile(src, newNode, logRetryEntry);
|
getEditLog().logOpenFile(src, newNode, logRetryEntry);
|
||||||
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
||||||
NameNode.stateChangeLog.debug("DIR* NameSystem.startFile: "
|
NameNode.stateChangeLog.debug("DIR* NameSystem.startFile: added " +
|
||||||
+"add "+src+" to namespace for "+holder);
|
src + " inode " + newNode.getId() + " " + holder);
|
||||||
}
|
}
|
||||||
} catch (IOException ie) {
|
} catch (IOException ie) {
|
||||||
NameNode.stateChangeLog.warn("DIR* NameSystem.startFile: "
|
NameNode.stateChangeLog.warn("DIR* NameSystem.startFile: " + src + " " +
|
||||||
+ie.getMessage());
|
ie.getMessage());
|
||||||
throw ie;
|
throw ie;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2373,7 +2372,7 @@ private LocatedBlock appendFileInternal(FSPermissionChecker pc, String src,
|
|||||||
try {
|
try {
|
||||||
if (inode == null) {
|
if (inode == null) {
|
||||||
throw new FileNotFoundException("failed to append to non-existent file "
|
throw new FileNotFoundException("failed to append to non-existent file "
|
||||||
+ src + " on client " + clientMachine);
|
+ src + " for client " + clientMachine);
|
||||||
}
|
}
|
||||||
INodeFile myFile = INodeFile.valueOf(inode, src, true);
|
INodeFile myFile = INodeFile.valueOf(inode, src, true);
|
||||||
// Opening an existing file for write - may need to recover lease.
|
// Opening an existing file for write - may need to recover lease.
|
||||||
@ -2497,7 +2496,7 @@ private void recoverLeaseInternal(INodeFile fileInode,
|
|||||||
lease.getHolder().equals(holder)) {
|
lease.getHolder().equals(holder)) {
|
||||||
throw new AlreadyBeingCreatedException(
|
throw new AlreadyBeingCreatedException(
|
||||||
"failed to create file " + src + " for " + holder +
|
"failed to create file " + src + " for " + holder +
|
||||||
" on client " + clientMachine +
|
" for client " + clientMachine +
|
||||||
" because current leaseholder is trying to recreate file.");
|
" because current leaseholder is trying to recreate file.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2510,7 +2509,7 @@ private void recoverLeaseInternal(INodeFile fileInode,
|
|||||||
if (lease == null) {
|
if (lease == null) {
|
||||||
throw new AlreadyBeingCreatedException(
|
throw new AlreadyBeingCreatedException(
|
||||||
"failed to create file " + src + " for " + holder +
|
"failed to create file " + src + " for " + holder +
|
||||||
" on client " + clientMachine +
|
" for client " + clientMachine +
|
||||||
" because pendingCreates is non-null but no leases found.");
|
" because pendingCreates is non-null but no leases found.");
|
||||||
}
|
}
|
||||||
if (force) {
|
if (force) {
|
||||||
@ -2543,7 +2542,7 @@ private void recoverLeaseInternal(INodeFile fileInode,
|
|||||||
+ src + "], " + "lease owner [" + lease.getHolder() + "]");
|
+ src + "], " + "lease owner [" + lease.getHolder() + "]");
|
||||||
} else {
|
} else {
|
||||||
throw new AlreadyBeingCreatedException("Failed to create file ["
|
throw new AlreadyBeingCreatedException("Failed to create file ["
|
||||||
+ src + "] for [" + holder + "] on client [" + clientMachine
|
+ src + "] for [" + holder + "] for client [" + clientMachine
|
||||||
+ "], because this file is already being created by ["
|
+ "], because this file is already being created by ["
|
||||||
+ clientName + "] on ["
|
+ clientName + "] on ["
|
||||||
+ uc.getClientMachine() + "]");
|
+ uc.getClientMachine() + "]");
|
||||||
@ -2661,9 +2660,8 @@ LocatedBlock getAdditionalBlock(String src, long fileId, String clientName,
|
|||||||
DatanodeDescriptor clientNode = null;
|
DatanodeDescriptor clientNode = null;
|
||||||
|
|
||||||
if(NameNode.stateChangeLog.isDebugEnabled()) {
|
if(NameNode.stateChangeLog.isDebugEnabled()) {
|
||||||
NameNode.stateChangeLog.debug(
|
NameNode.stateChangeLog.debug("BLOCK* NameSystem.getAdditionalBlock: "
|
||||||
"BLOCK* NameSystem.getAdditionalBlock: file "
|
+ src + " inodeId " + fileId + " for " + clientName);
|
||||||
+src+" for "+clientName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Part I. Analyze the state of the file with respect to the input data.
|
// Part I. Analyze the state of the file with respect to the input data.
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
import org.apache.hadoop.fs.CreateFlag;
|
import org.apache.hadoop.fs.CreateFlag;
|
||||||
import org.apache.hadoop.fs.FSDataInputStream;
|
import org.apache.hadoop.fs.FSDataInputStream;
|
||||||
import org.apache.hadoop.fs.FSDataOutputStream;
|
import org.apache.hadoop.fs.FSDataOutputStream;
|
||||||
|
import org.apache.hadoop.fs.FileAlreadyExistsException;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.apache.hadoop.fs.FsServerDefaults;
|
import org.apache.hadoop.fs.FsServerDefaults;
|
||||||
import org.apache.hadoop.fs.InvalidPathException;
|
import org.apache.hadoop.fs.InvalidPathException;
|
||||||
@ -246,11 +247,11 @@ public void checkFileCreation(String netIf, boolean useDnHostname)
|
|||||||
fs.create(dir1, true); // Create path, overwrite=true
|
fs.create(dir1, true); // Create path, overwrite=true
|
||||||
fs.close();
|
fs.close();
|
||||||
assertTrue("Did not prevent directory from being overwritten.", false);
|
assertTrue("Did not prevent directory from being overwritten.", false);
|
||||||
} catch (IOException ie) {
|
} catch (FileAlreadyExistsException e) {
|
||||||
if (!ie.getMessage().contains("already exists as a directory."))
|
// expected
|
||||||
throw ie;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// create a new file in home directory. Do not close it.
|
// create a new file in home directory. Do not close it.
|
||||||
//
|
//
|
||||||
Path file1 = new Path("filestatus.dat");
|
Path file1 = new Path("filestatus.dat");
|
||||||
|
@ -198,33 +198,22 @@ private FileSystem getFSAsAnotherUser(final Configuration c)
|
|||||||
private void recoverLeaseUsingCreate(Path filepath)
|
private void recoverLeaseUsingCreate(Path filepath)
|
||||||
throws IOException, InterruptedException {
|
throws IOException, InterruptedException {
|
||||||
FileSystem dfs2 = getFSAsAnotherUser(conf);
|
FileSystem dfs2 = getFSAsAnotherUser(conf);
|
||||||
|
for(int i = 0; i < 10; i++) {
|
||||||
boolean done = false;
|
|
||||||
for(int i = 0; i < 10 && !done; i++) {
|
|
||||||
AppendTestUtil.LOG.info("i=" + i);
|
AppendTestUtil.LOG.info("i=" + i);
|
||||||
try {
|
try {
|
||||||
dfs2.create(filepath, false, BUF_SIZE, (short)1, BLOCK_SIZE);
|
dfs2.create(filepath, false, BUF_SIZE, (short)1, BLOCK_SIZE);
|
||||||
fail("Creation of an existing file should never succeed.");
|
fail("Creation of an existing file should never succeed.");
|
||||||
} catch (IOException ioe) {
|
} catch(FileAlreadyExistsException e) {
|
||||||
final String message = ioe.getMessage();
|
return; // expected
|
||||||
if (message.contains("file exists")) {
|
} catch(AlreadyBeingCreatedException e) {
|
||||||
AppendTestUtil.LOG.info("done", ioe);
|
return; // expected
|
||||||
done = true;
|
} catch(IOException ioe) {
|
||||||
}
|
AppendTestUtil.LOG.warn("UNEXPECTED ", ioe);
|
||||||
else if (message.contains(AlreadyBeingCreatedException.class.getSimpleName())) {
|
|
||||||
AppendTestUtil.LOG.info("GOOD! got " + message);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
AppendTestUtil.LOG.warn("UNEXPECTED IOException", ioe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!done) {
|
|
||||||
AppendTestUtil.LOG.info("sleep " + 5000 + "ms");
|
AppendTestUtil.LOG.info("sleep " + 5000 + "ms");
|
||||||
try {Thread.sleep(5000);} catch (InterruptedException e) {}
|
try {Thread.sleep(5000);} catch (InterruptedException e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertTrue(done);
|
fail("recoverLeaseUsingCreate failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyFile(FileSystem dfs, Path filepath, byte[] actual,
|
private void verifyFile(FileSystem dfs, Path filepath, byte[] actual,
|
||||||
|
Loading…
Reference in New Issue
Block a user