/** * The same as getFileReplication(null). * For erasure coded files, this returns the EC policy ID. * */ @Override // INodeFileAttributes public final short getFileReplication() { if (isStriped()) { return DEFAULT_REPL_FOR_STRIPED_BLOCKS; } return getFileReplication(CURRENT_STATE_ID); }
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 }
/** * 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); }
public short getPreferredBlockReplication() { short max = getFileReplication(CURRENT_STATE_ID); FileWithSnapshotFeature sf = this.getFileWithSnapshotFeature(); if (sf != null) { short maxInSnapshot = sf.getMaxBlockRepInDiffs(null); if (sf.isCurrentFileDeleted()) { return maxInSnapshot; } max = maxInSnapshot > max ? maxInSnapshot : max; } if(!isStriped()){ return max; } ErasureCodingPolicy ecPolicy = ErasureCodingPolicyManager.getInstance() .getByID(getErasureCodingPolicyID()); Preconditions.checkNotNull(ecPolicy, "Could not find EC policy with ID 0x" + StringUtils.byteToHexString(getErasureCodingPolicyID())); return (short) (ecPolicy.getNumDataUnits() + ecPolicy.getNumParityUnits()); }
/** The same as getFileReplication(null). */ @Override // INodeFileAttributes public final short getFileReplication() { return getFileReplication(CURRENT_STATE_ID); }
fileINode.getFileReplication(), true); short numLocations = fileINode.getFileReplication(); blockInfo = new BlockInfoContiguous(block, numLocations); blockInfo.convertToBlockUnderConstruction(
final INodeFile fileNode = inode.asFile(); size = fileNode.computeFileSize(snapshot); replication = fileNode.getFileReplication(snapshot); blocksize = fileNode.getPreferredBlockSize(); } else if (inode.isSymlink()) {
/** * Add close lease record to edit log. */ public void logCloseFile(String path, INodeFile newNode) { CloseOp op = CloseOp.getInstance(cache.get()) .setPath(path) .setReplication(newNode.getFileReplication()) .setModificationTime(newNode.getModificationTime()) .setAccessTime(newNode.getAccessTime()) .setBlockSize(newNode.getPreferredBlockSize()) .setBlocks(newNode.getBlocks()) .setPermissionStatus(newNode.getPermissionStatus()); logEdit(op); }
replication = getFileReplication(); } else { int sid = fileDiffList.getSnapshotById(lastSnapshotId); ssDeltaNoReplication = computeFileSize(sid); replication = getFileReplication(sid);
} else { diff = fileINode.getPreferredBlockSize() - completeBlk.getNumBytes(); replicationFactor = fileINode.getFileReplication();
@Override public final ContentSummaryComputationContext computeContentSummary( int snapshotId, final ContentSummaryComputationContext summary) { final ContentCounts counts = summary.getCounts(); counts.addContent(Content.FILE, 1); final long fileLen = computeFileSize(snapshotId); counts.addContent(Content.LENGTH, fileLen); counts.addContent(Content.DISKSPACE, storagespaceConsumed(null) .getStorageSpace()); if (getStoragePolicyID() != BLOCK_STORAGE_POLICY_ID_UNSPECIFIED){ BlockStoragePolicy bsp = summary.getBlockStoragePolicySuite(). getPolicy(getStoragePolicyID()); List<StorageType> storageTypes = bsp.chooseStorageTypes(getFileReplication()); for (StorageType t : storageTypes) { if (!t.supportTypeQuota()) { continue; } counts.addTypeSpace(t, fileLen); } } return summary; }
public final short getReplication(int lastSnapshotId) { if (lastSnapshotId != CURRENT_STATE_ID) { return getFileReplication(lastSnapshotId); } else { return getBlockReplication(); } }
public final short getReplication(int lastSnapshotId) { if (lastSnapshotId != CURRENT_STATE_ID) { return getFileReplication(lastSnapshotId); } else { return getBlockReplication(); } }
private static QuotaCounts computeQuotaDeltas(FSDirectory fsd, INodeFile target, INodeFile[] srcList) { QuotaCounts deltas = new QuotaCounts.Builder().build(); final short targetRepl = target.getPreferredBlockReplication(); for (INodeFile src : srcList) { short srcRepl = src.getFileReplication(); long fileSize = src.computeFileSize(); if (targetRepl != srcRepl) { deltas.addStorageSpace(fileSize * (targetRepl - srcRepl)); BlockStoragePolicy bsp = fsd.getBlockStoragePolicySuite().getPolicy(src.getStoragePolicyID()); if (bsp != null) { List<StorageType> srcTypeChosen = bsp.chooseStorageTypes(srcRepl); for (StorageType t : srcTypeChosen) { if (t.supportTypeQuota()) { deltas.addTypeSpace(t, -fileSize); } } List<StorageType> targetTypeChosen = bsp.chooseStorageTypes(targetRepl); for (StorageType t : targetTypeChosen) { if (t.supportTypeQuota()) { deltas.addTypeSpace(t, fileSize); } } } } } return deltas; }
+ ecPolicy.getSchema().getNumParityUnits()); } else { numTargets = pendingFile.getFileReplication();
final INodeFile fileNode = node.asFile(); size = fileNode.computeFileSize(snapshot); replication = fileNode.getFileReplication(snapshot); blocksize = fileNode.getPreferredBlockSize(); if (isEncrypted) {
} else { newBI = new BlockInfoContiguous(newBlock, file.getFileReplication());
public final long storagespaceConsumed(int lastSnapshotId) { if (lastSnapshotId != CURRENT_STATE_ID) { return computeFileSize(lastSnapshotId) * getFileReplication(lastSnapshotId); } else { return storagespaceConsumed(); } }
.setInodeId(newNode.getId()) .setPath(path) .setReplication(newNode.getFileReplication()) .setModificationTime(newNode.getModificationTime()) .setAccessTime(newNode.getAccessTime())
/** * Test for the Replication value. Sets a value and checks if it was set * correct. */ @Test public void testReplication () { replication = 3; preferredBlockSize = 128*1024*1024; INodeFile inf = createINodeFile(replication, preferredBlockSize); assertEquals("True has to be returned in this case", replication, inf.getFileReplication()); }