@Override public String toString() { return "name space=" + getNameSpace() + "\nstorage space=" + getStorageSpace() + "\nstorage types=" + getTypeSpaces(); }
boolean isQuotaByStorageTypeSet(StorageType t) { return quota.getTypeSpace(t) >= 0; }
public QuotaCounts build() { return new QuotaCounts(this); } }
public void setCounts(QuotaCounts c) { this.counts.setNameSpace(c.getNameSpace()); this.counts.setStorageSpace(c.getStorageSpace()); this.counts.setTypeSpaces(c.getTypeSpaces()); }
boolean isQuotaSet() { return quota.anyNsSsCountGreaterOrEqual(0) || quota.anyTypeSpaceCountGreaterOrEqual(0); }
} else { myCounts.add(child.computeQuotaUsage(bsps, childPolicyId, false, CURRENT_STATE_ID)); final long nsConsumed = myCounts.getNameSpace(); final long nsQuota = q.getNameSpace(); if (Quota.isViolated(nsQuota, nsConsumed)) { LOG.warn("Namespace quota violation in image for " final long ssConsumed = myCounts.getStorageSpace(); final long ssQuota = q.getStorageSpace(); if (Quota.isViolated(ssQuota, ssConsumed)) { LOG.warn("Storagespace quota violation in image for " final EnumCounters<StorageType> tsConsumed = myCounts.getTypeSpaces(); for (StorageType t : StorageType.getTypesSupportingQuota()) { final long typeSpace = tsConsumed.get(t); final long typeQuota = q.getTypeSpaces().get(t); if (Quota.isViolated(typeQuota, typeSpace)) { LOG.warn("Storage type quota violation in image for " counts.add(myCounts);
long blockSize = b.isComplete() ? b.getNumBytes() : getPreferredBlockSize(); counts.addStorageSpace(blockSize * replication); if (bsp != null) { List<StorageType> types = bsp.chooseStorageTypes(replication); for (StorageType t : types) { if (t.supportTypeQuota()) { counts.addTypeSpace(t, blockSize);
private static void writeQuota(QuotaCounts quota, DataOutput out) throws IOException { out.writeLong(quota.getNameSpace()); out.writeLong(quota.getStorageSpace()); }
@Override public final ContentSummaryComputationContext computeContentSummary( int snapshotId, ContentSummaryComputationContext summary) { final int s = snapshotId < lastSnapshotId ? snapshotId : lastSnapshotId; // only count storagespace for WithName final QuotaCounts q = computeQuotaUsage( summary.getBlockStoragePolicySuite(), getStoragePolicyID(), false, s); summary.getCounts().addContent(Content.DISKSPACE, q.getStorageSpace()); summary.getCounts().addTypeSpaces(q.getTypeSpaces()); return summary; }
replication = getBlockReplication(); counts.addNameSpace(nsDelta); counts.addStorageSpace(ssDeltaNoReplication * replication); continue; counts.addTypeSpace(t, ssDeltaNoReplication);
/** * Add current quota usage to counts and return the updated counts * @param counts counts to be added with current quota usage * @return counts that have been added with the current qutoa usage */ QuotaCounts AddCurrentSpaceUsage(QuotaCounts counts) { counts.add(this.usage); return counts; }
FileWithSnapshotFeature sf = getFileWithSnapshotFeature(); if (sf == null) { counts.add(storagespaceConsumed(bsp)); return counts; counts.add(storagespaceConsumed(bsp)); return counts; counts.addStorageSpace(ssDeltaNoReplication * replication); if (bsp != null) { List<StorageType> storageTypes = bsp.chooseStorageTypes(replication); continue; counts.addTypeSpace(t, ssDeltaNoReplication);
.getSpaceConsumed().getTypeSpaces().get(StorageType.SSD); assertEquals(file1Len, ssdConsumed); assertEquals(SSD_QUOTA, qc.getTypeSpace(StorageType.SSD)); for (StorageType t: StorageType.getTypesSupportingQuota()) { if (t != StorageType.SSD) { assertEquals(HdfsConstants.QUOTA_RESET, qc.getTypeSpace(t)); .getSpaceConsumed().getTypeSpaces().get(StorageType.SSD); assertEquals(file1Len, ssdConsumedAfterNNRestart);
.getPreferredBlockSize(); oldCounts.addStorageSpace(blockSize * replication); for (StorageType t : oldTypeChosen) { if (t.supportTypeQuota()) { oldCounts.addTypeSpace(t, blockSize); reclaimContext.quotaDelta().add(oldCounts.subtract(current));
/** * Compute quota of striped file. Note that currently EC files do not support * append/hflush/hsync, thus the file length recorded in snapshots should be * the same with the current file length. */ public final QuotaCounts computeQuotaUsageWithStriped( BlockStoragePolicy bsp, QuotaCounts counts) { counts.addNameSpace(1); counts.add(storagespaceConsumed(bsp)); return counts; }
private String storagespaceString() { return "storagespace: " + (quota.getStorageSpace() < 0? "-": usage.getStorageSpace() + "/" + quota.getStorageSpace()); }
private String namespaceString() { return "namespace: " + (quota.getNameSpace() < 0? "-": usage.getNameSpace() + "/" + quota.getNameSpace()); } private String storagespaceString() {
@Override public QuotaCounts computeQuotaUsage( BlockStoragePolicySuite bsps, byte blockStoragePolicyId, QuotaCounts counts, boolean useCache, int lastSnapshotId) { counts.addNameSpace(1); return counts; }
public final QuotaCounts storagespaceConsumedStriped() { QuotaCounts counts = new QuotaCounts.Builder().build(); for (BlockInfo b : blocks) { Preconditions.checkState(b.isStriped()); long blockSize = b.isComplete() ? ((BlockInfoStriped)b).spaceConsumed() : getPreferredBlockSize() * ((BlockInfoStriped)b).getTotalBlockNum(); counts.addStorageSpace(blockSize); } return counts; }
void testQuotaByStorageTypeWithFileCreateCase( String storagePolicy, StorageType storageType, short replication) throws Exception { final Path foo = new Path(dir, "foo"); Path createdFile1 = new Path(foo, "created_file1.data"); dfs.mkdirs(foo); // set storage policy on directory "foo" to storagePolicy dfs.setStoragePolicy(foo, storagePolicy); // set quota by storage type on directory "foo" dfs.setQuotaByStorageType(foo, storageType, BLOCKSIZE * 10); INode fnode = fsdir.getINode4Write(foo.toString()); assertTrue(fnode.isDirectory()); assertTrue(fnode.isQuotaSet()); // Create file of size 2 * BLOCKSIZE under directory "foo" long file1Len = BLOCKSIZE * 2 + BLOCKSIZE / 2; int bufLen = BLOCKSIZE / 16; DFSTestUtil.createFile(dfs, createdFile1, bufLen, file1Len, BLOCKSIZE, REPLICATION, seed); // Verify space consumed and remaining quota long storageTypeConsumed = fnode.asDirectory().getDirectoryWithQuotaFeature() .getSpaceConsumed().getTypeSpaces().get(storageType); assertEquals(file1Len * replication, storageTypeConsumed); }