static void writeINodeUnderConstruction(DataOutputStream out, INodeFile cons, String path) throws IOException { writeString(path, out); out.writeLong(cons.getId()); out.writeShort(cons.getFileReplication()); out.writeLong(cons.getModificationTime()); out.writeLong(cons.getPreferredBlockSize()); writeBlocks(cons.getBlocks(), out); cons.getPermissionStatus().write(out); FileUnderConstructionFeature uc = cons.getFileUnderConstructionFeature(); writeString(uc.getClientName(), out); writeString(uc.getClientMachine(), out); out.writeInt(0); // do not store locations of last block }
if (StringUtils.isEmpty(path) || fullPathName.startsWith(path)) { openFileEntries.add(new OpenFileEntry(inodeFile.getId(), fullPathName, inodeFile.getFileUnderConstructionFeature().getClientName(), inodeFile.getFileUnderConstructionFeature().getClientMachine())); count++;
/** * Serialize a {@link INodeFile} node * @param file The INodeFile to write * @param out The {@link DataOutputStream} where the fields are written * @param writeUnderConstruction Whether to write under construction information */ public static void writeINodeFile(INodeFile file, DataOutput out, boolean writeUnderConstruction) throws IOException { writeLocalName(file, out); out.writeLong(file.getId()); out.writeShort(file.getFileReplication()); out.writeLong(file.getModificationTime()); out.writeLong(file.getAccessTime()); out.writeLong(file.getPreferredBlockSize()); writeBlocks(file.getBlocks(), out); SnapshotFSImageFormat.saveFileDiffList(file, out); if (writeUnderConstruction) { if (file.isUnderConstruction()) { out.writeBoolean(true); final FileUnderConstructionFeature uc = file.getFileUnderConstructionFeature(); writeString(uc.getClientName(), out); writeString(uc.getClientMachine(), out); } else { out.writeBoolean(false); } } writePermissionStatus(file, out); }
.getClientName())) { throw new LeaseExpiredException("Lease mismatch: " + block + " is accessed by a non lease holder " + clientName);
void finalizeINodeFileUnderConstruction(String src, INodeFile pendingFile, int latestSnapshot, boolean allowCommittedBlock) throws IOException { assert hasWriteLock(); FileUnderConstructionFeature uc = pendingFile.getFileUnderConstructionFeature(); if (uc == null) { throw new IOException("Cannot finalize file " + src + " because it is not under construction"); } pendingFile.recordModification(latestSnapshot); // The file is no longer pending. // Create permanent INode, update blocks. No need to replace the inode here // since we just remove the uc feature from pendingFile pendingFile.toCompleteFile(now(), allowCommittedBlock? numCommittedAllowed: 0, blockManager.getMinReplication()); leaseManager.removeLease(uc.getClientName(), pendingFile); // close file and persist block allocations for this file closeFile(src, pendingFile); blockManager.checkRedundancy(pendingFile); }
public void logAppendFile(String path, INodeFile file, boolean newBlock, boolean toLogRpcIds) { FileUnderConstructionFeature uc = file.getFileUnderConstructionFeature(); assert uc != null; AppendOp op = AppendOp.getInstance(cache.get()).setPath(path) .setClientName(uc.getClientName()) .setClientMachine(uc.getClientMachine()) .setNewBlock(newBlock); logRpcIds(op, toLogRpcIds); logEdit(op); }
openFileEntries.add(new OpenFileEntry(inodeFile.getId(), inodeFile.getFullPathName(), inodeFile.getFileUnderConstructionFeature().getClientName(), inodeFile.getFileUnderConstructionFeature().getClientMachine()));
+ leaseExceptionString(src, fileId, holder)); final String owner = file.getFileUnderConstructionFeature().getClientName(); if (holder != null && !owner.equals(holder)) { throw new LeaseExpiredException("Client (=" + holder
oldnode.toUnderConstruction(uc.getClientName(), uc.getClientMachine()); if (oldnode.numBlocks() > 0) { BlockInfo ucBlock = cons.getLastBlock(); namesystem.leaseManager.addLease(uc.getClientName(), oldnode.getId());
String clientName = uc.getClientName(); lease = leaseManager.getLease(clientName); if (lease == null) {
newNode.getFileUnderConstructionFeature().getClientName(), newNode.getId()); if (feInfo != null) {
private void save(OutputStream out, INodeFile n) throws IOException { INodeSection.INodeFile.Builder b = buildINodeFile(n, parent.getSaverContext()); BlockInfo[] blocks = n.getBlocks(); if (blocks != null) { for (Block block : n.getBlocks()) { b.addBlocks(PBHelperClient.convert(block)); } } FileUnderConstructionFeature uc = n.getFileUnderConstructionFeature(); if (uc != null) { INodeSection.FileUnderConstructionFeature f = INodeSection.FileUnderConstructionFeature .newBuilder().setClientName(uc.getClientName()) .setClientMachine(uc.getClientMachine()).build(); b.setFileUC(f); } INodeSection.INode r = buildINodeCommon(n) .setType(INodeSection.INode.Type.FILE).setFile(b).build(); r.writeDelimitedTo(out); }
file.getFileUnderConstructionFeature().getClientName(), file.getId());
.setBlocks(newNode.getBlocks()) .setPermissionStatus(permissions) .setClientName(newNode.getFileUnderConstructionFeature().getClientName()) .setClientMachine( newNode.getFileUnderConstructionFeature().getClientMachine())
assert file.isUnderConstruction() : "inode should be under construction."; fsn.getLeaseManager().addLease( file.getFileUnderConstructionFeature().getClientName(), file.getId()); boolean shouldRecoverNow = (newBlock == null); BlockInfo oldBlock = file.getLastBlock();
static void writeINodeUnderConstruction(DataOutputStream out, INodeFile cons, String path) throws IOException { writeString(path, out); out.writeLong(cons.getId()); out.writeShort(cons.getFileReplication()); out.writeLong(cons.getModificationTime()); out.writeLong(cons.getPreferredBlockSize()); writeBlocks(cons.getBlocks(), out); cons.getPermissionStatus().write(out); FileUnderConstructionFeature uc = cons.getFileUnderConstructionFeature(); writeString(uc.getClientName(), out); writeString(uc.getClientMachine(), out); out.writeInt(0); // do not store locations of last block }
static void writeINodeUnderConstruction(DataOutputStream out, INodeFile cons, String path) throws IOException { writeString(path, out); out.writeLong(cons.getId()); out.writeShort(cons.getFileReplication()); out.writeLong(cons.getModificationTime()); out.writeLong(cons.getPreferredBlockSize()); writeBlocks(cons.getBlocks(), out); cons.getPermissionStatus().write(out); FileUnderConstructionFeature uc = cons.getFileUnderConstructionFeature(); writeString(uc.getClientName(), out); writeString(uc.getClientMachine(), out); out.writeInt(0); // do not store locations of last block }
public void logAppendFile(String path, INodeFile file, boolean newBlock, boolean toLogRpcIds) { FileUnderConstructionFeature uc = file.getFileUnderConstructionFeature(); assert uc != null; AppendOp op = AppendOp.getInstance(cache.get()).setPath(path) .setClientName(uc.getClientName()) .setClientMachine(uc.getClientMachine()) .setNewBlock(newBlock); logRpcIds(op, toLogRpcIds); logEdit(op); }
public void logAppendFile(String path, INodeFile file, boolean newBlock, boolean toLogRpcIds) { FileUnderConstructionFeature uc = file.getFileUnderConstructionFeature(); assert uc != null; AppendOp op = AppendOp.getInstance(cache.get()).setPath(path) .setClientName(uc.getClientName()) .setClientMachine(uc.getClientMachine()) .setNewBlock(newBlock); logRpcIds(op, toLogRpcIds); logEdit(op); }
@Test public void testFileUnderConstruction() { replication = 3; final INodeFile file = new INodeFile(INodeId.GRANDFATHER_INODE_ID, null, perm, 0L, 0L, null, replication, 1024L, (byte)0); assertFalse(file.isUnderConstruction()); final String clientName = "client"; final String clientMachine = "machine"; file.toUnderConstruction(clientName, clientMachine); assertTrue(file.isUnderConstruction()); FileUnderConstructionFeature uc = file.getFileUnderConstructionFeature(); assertEquals(clientName, uc.getClientName()); assertEquals(clientMachine, uc.getClientMachine()); file.toCompleteFile(Time.now()); assertFalse(file.isUnderConstruction()); }