Search in sources :

Example 1 with DirectoryWithSnapshotFeature

use of org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature in project hadoop by apache.

the class INodeDirectory method computeQuotaUsage.

@Override
public QuotaCounts computeQuotaUsage(BlockStoragePolicySuite bsps, byte blockStoragePolicyId, boolean useCache, int lastSnapshotId) {
    final DirectoryWithSnapshotFeature sf = getDirectoryWithSnapshotFeature();
    QuotaCounts counts = new QuotaCounts.Builder().build();
    // given snapshot
    if (sf != null && lastSnapshotId != Snapshot.CURRENT_STATE_ID && !(useCache && isQuotaSet())) {
        ReadOnlyList<INode> childrenList = getChildrenList(lastSnapshotId);
        for (INode child : childrenList) {
            final byte childPolicyId = child.getStoragePolicyIDForQuota(blockStoragePolicyId);
            counts.add(child.computeQuotaUsage(bsps, childPolicyId, useCache, lastSnapshotId));
        }
        counts.addNameSpace(1);
        return counts;
    }
    // compute the quota usage in the scope of the current directory tree
    final DirectoryWithQuotaFeature q = getDirectoryWithQuotaFeature();
    if (useCache && q != null && q.isQuotaSet()) {
        // use the cached quota
        return q.AddCurrentSpaceUsage(counts);
    } else {
        useCache = q != null && !q.isQuotaSet() ? false : useCache;
        return computeDirectoryQuotaUsage(bsps, blockStoragePolicyId, counts, useCache, lastSnapshotId);
    }
}
Also used : DirectoryWithSnapshotFeature(org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature)

Example 2 with DirectoryWithSnapshotFeature

use of org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature in project hadoop by apache.

the class INodeDirectory method computeQuotaUsage4CurrentDirectory.

/** Add quota usage for this inode excluding children. */
public QuotaCounts computeQuotaUsage4CurrentDirectory(BlockStoragePolicySuite bsps, byte storagePolicyId, QuotaCounts counts) {
    counts.addNameSpace(1);
    // include the diff list
    DirectoryWithSnapshotFeature sf = getDirectoryWithSnapshotFeature();
    if (sf != null) {
        counts.add(sf.computeQuotaUsage4CurrentDirectory(bsps, storagePolicyId));
    }
    return counts;
}
Also used : DirectoryWithSnapshotFeature(org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature)

Example 3 with DirectoryWithSnapshotFeature

use of org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature in project hadoop by apache.

the class INodeDirectory method destroyAndCollectBlocks.

@Override
public void destroyAndCollectBlocks(ReclaimContext reclaimContext) {
    reclaimContext.quotaDelta().add(new QuotaCounts.Builder().nameSpace(1).build());
    final DirectoryWithSnapshotFeature sf = getDirectoryWithSnapshotFeature();
    if (sf != null) {
        sf.clear(reclaimContext, this);
    }
    for (INode child : getChildrenList(Snapshot.CURRENT_STATE_ID)) {
        child.destroyAndCollectBlocks(reclaimContext);
    }
    if (getAclFeature() != null) {
        AclStorage.removeAclFeature(getAclFeature());
    }
    clear();
    reclaimContext.removedINodes.add(this);
}
Also used : DirectoryWithSnapshotFeature(org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature)

Example 4 with DirectoryWithSnapshotFeature

use of org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature in project hadoop by apache.

the class INodeDirectory method removeSnapshottableFeature.

/** remove DirectorySnapshottableFeature */
public void removeSnapshottableFeature() {
    DirectorySnapshottableFeature s = getDirectorySnapshottableFeature();
    Preconditions.checkState(s != null, "The dir does not have snapshottable feature: this=%s", this);
    this.removeFeature(s);
    if (s.getDiffs().asList().size() > 0) {
        // add a DirectoryWithSnapshotFeature back
        DirectoryWithSnapshotFeature sf = new DirectoryWithSnapshotFeature(s.getDiffs());
        addFeature(sf);
    }
}
Also used : DirectoryWithSnapshotFeature(org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature) DirectorySnapshottableFeature(org.apache.hadoop.hdfs.server.namenode.snapshot.DirectorySnapshottableFeature)

Example 5 with DirectoryWithSnapshotFeature

use of org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature in project hadoop by apache.

the class INodeDirectory method computeContentSummary.

@Override
public ContentSummaryComputationContext computeContentSummary(int snapshotId, ContentSummaryComputationContext summary) {
    summary.nodeIncluded(this);
    final DirectoryWithSnapshotFeature sf = getDirectoryWithSnapshotFeature();
    if (sf != null && snapshotId == Snapshot.CURRENT_STATE_ID) {
        sf.computeContentSummary4Snapshot(summary);
    }
    final DirectoryWithQuotaFeature q = getDirectoryWithQuotaFeature();
    if (q != null && snapshotId == Snapshot.CURRENT_STATE_ID) {
        return q.computeContentSummary(this, summary);
    } else {
        return computeDirectoryContentSummary(summary, snapshotId);
    }
}
Also used : DirectoryWithSnapshotFeature(org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature)

Aggregations

DirectoryWithSnapshotFeature (org.apache.hadoop.hdfs.server.namenode.snapshot.DirectoryWithSnapshotFeature)15 DirectorySnapshottableFeature (org.apache.hadoop.hdfs.server.namenode.snapshot.DirectorySnapshottableFeature)2 WithCount (org.apache.hadoop.hdfs.server.namenode.INodeReference.WithCount)1 Snapshot (org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot)1