/** * Replaces the specified inode with the specified one. */ void replaceNode(String path, INodeFile oldnode, INodeFile newnode) throws IOException { replaceNode(path, null, oldnode, newnode, true); }
/** * Replaces the specified inode with the specified one. */ void replaceNode(String path, INodeFile oldnode, INodeFile newnode) throws IOException { replaceNode(path, oldnode, newnode, true); }
private void loadFilesUnderConstruction(int version, DataInputStream in, FSNamesystem fs) throws IOException { FSDirectory fsDir = fs.dir; if (version > -13) // pre lease image version return; int size = in.readInt(); LOG.info("Number of files under construction = " + size); for (int i = 0; i < size; i++) { INodeFileUnderConstruction cons = readINodeUnderConstruction(in); // verify that file exists in namespace String path = cons.getLocalName(); INode old = fsDir.getFileINode(path); if (old == null) { throw new IOException("Found lease for non-existent file " + path); } if (old.isDirectory()) { throw new IOException("Found lease for directory " + path); } INodeFile oldnode = (INodeFile) old; fsDir.replaceNode(path, oldnode, cons); fs.leaseManager.addLease(cons.clientName, path); } }
private void finalizeINodeFileUnderConstruction(String src, INodeFileUnderConstruction pendingFile) throws IOException { leaseManager.removeLease(pendingFile.clientName, src); // The file is no longer pending. // Create permanent INode, update blockmap INodeFile newFile = pendingFile.convertToInodeFile(); dir.replaceNode(src, pendingFile, newFile); // close file and persist block allocations for this file dir.closeFile(src, newFile); checkReplicationFactor(newFile); }
private void loadFilesUnderConstruction(DataInputStream in) throws IOException { FSDirectory fsDir = namesystem.dir; int imgVersion = getLayoutVersion(); if (imgVersion > -13) // pre lease image version return; int size = in.readInt(); LOG.info("Number of files under construction = " + size); for (int i = 0; i < size; i++) { INodeFileUnderConstruction cons = FSImageSerialization.readINodeUnderConstruction(in); // verify that file exists in namespace String path = cons.getLocalName(); INode old = fsDir.getFileINode(path); if (old == null) { throw new IOException("Found lease for non-existent file " + path); } if (old.isDirectory()) { throw new IOException("Found lease for directory " + path); } INodeFile oldnode = (INodeFile) old; fsDir.replaceNode(path, oldnode, cons); namesystem.leaseManager.addLease(cons.getClientName(), path, cons.getModificationTime()); } }
} catch (QuotaExceededException e) { replaceNode(path, newnode, oldnode, false); throw e;
private void finalizeINodeFileUnderConstruction(String src, INode[] inodes, INodeFileUnderConstruction pendingFile) throws IOException { // Put last block in needed replication queue if uder replicated replicateLastBlock(src, pendingFile); leaseManager.removeLease(pendingFile.getClientName(), src); DatanodeDescriptor[] descriptors = pendingFile.getTargets(); if (descriptors != null) { for (DatanodeDescriptor node : descriptors) { node.removeINode(pendingFile); } } // The file is no longer pending. // Create permanent INode, update blockmap INodeFile newFile = pendingFile.convertToInodeFile(); dir.replaceNode(src, inodes, pendingFile, newFile, true); // close file and persist block allocations for this file dir.closeFile(src, newFile); }
clientMachine, clientNode); dir.replaceNode(src, inodes, node, cons, true); leaseManager.addLease(cons.clientName, src, cons.getModificationTime());
clientMachine, clientNode); dir.replaceNode(src, node, cons); leaseManager.addLease(cons.clientName, src);
} catch (QuotaExceededException e) { replaceNode(path, inodes, newnode, oldnode, false); throw e;
clientMachine, null); fsDir.replaceNode(path, node, cons); fsNamesys.leaseManager.addLease(cons.clientName, path);
fsNamesys.leaseManager.removeLease(pendingFile.getClientName(), addCloseOp.path); fsDir.replaceNode(addCloseOp.path, node, newNode);