long first = ((blocks.length == 1)? blocks[0].getNumBytes(): 0);
blockSize = Math.max(fsNamesys.getDefaultBlockSize(), first);
}
}
PermissionStatus permissions = fsNamesys.getUpgradePermission();
if (addCloseOp.permissions != null) {
permissions = addCloseOp.permissions;
}
// The open lease transaction re-creates a file if necessary.
// Delete the file if it already exists.
if (FSNamesystem.LOG.isDebugEnabled()) {
FSNamesystem.LOG.debug(op.opCode + ": " + addCloseOp.path +
" numblocks : " + blocks.length +
" clientHolder " + addCloseOp.clientName +
" clientMachine " + addCloseOp.clientMachine);
}
INodeFile node = fsDir.updateINodefile(addCloseOp.path, permissions,
blocks, replication, addCloseOp.mtime, addCloseOp.atime, blockSize,
addCloseOp.clientName, addCloseOp.clientMachine);
if (addCloseOp.opCode == FSEditLogOpCodes.OP_ADD) {
if (!node.isUnderConstruction()) {
throw new IOException("INodeFile : " + node
+ " is not under construction");
}
INodeFileUnderConstruction cons = (INodeFileUnderConstruction) node;
if (!cons.getClientName().equals(addCloseOp.clientName)) {
fsNamesys.leaseManager.removeLease(cons.getClientName(),
addCloseOp.path);
FSNamesystem.LOG.info("Updating client name for : " + addCloseOp.path
+ " from : " + cons.getClientName() + " to : "
+ addCloseOp.clientName);
}
cons.setClientName(addCloseOp.clientName);
cons.setClientMachine(addCloseOp.clientMachine);
fsNamesys.leaseManager.addLease(cons.getClientName(),
addCloseOp.path,
cons.getModificationTime());
} else {
INodeFile newNode = node;
if (node.isUnderConstruction()) {
INodeFileUnderConstruction pendingFile = (INodeFileUnderConstruction) node;
newNode = pendingFile.convertToInodeFile();
newNode.setAccessTime(addCloseOp.atime);
fsNamesys.leaseManager.removeLease(pendingFile.getClientName(),
addCloseOp.path);
fsDir.replaceNode(addCloseOp.path, node, newNode);
}
}
break;
}
case OP_SET_REPLICATION: {
SetReplicationOp setReplicationOp = (SetReplicationOp)op;
short replication = fsNamesys.adjustReplication(
setReplicationOp.replication);
fsDir.unprotectedSetReplication(setReplicationOp.path,
replication, null);
break;
}
case OP_CONCAT_DELETE: {
ConcatDeleteOp concatDeleteOp = (ConcatDeleteOp)op;
fsDir.unprotectedConcat(concatDeleteOp.trg, concatDeleteOp.srcs,
concatDeleteOp.timestamp);
break;
}
case OP_RENAME: {
RenameOp renameOp = (RenameOp)op;
HdfsFileStatus dinfo = fsDir.getHdfsFileInfo(renameOp.dst);
fsDir.unprotectedRenameTo(renameOp.src, renameOp.dst,
renameOp.timestamp);
fsNamesys.changeLease(renameOp.src, renameOp.dst, dinfo);
break;
}
case OP_DELETE: {
DeleteOp deleteOp = (DeleteOp)op;
fsDir.unprotectedDelete(deleteOp.path, deleteOp.timestamp);
break;
}
case OP_MKDIR: {
MkdirOp mkdirOp = (MkdirOp)op;
PermissionStatus permissions = fsNamesys.getUpgradePermission();
if (mkdirOp.permissions != null) {
permissions = mkdirOp.permissions;
}
fsDir.unprotectedMkdir(mkdirOp.path, permissions,