/** add DirectorySnapshottableFeature */ public void addSnapshottableFeature() { Preconditions.checkState(!isSnapshottable(), "this is already snapshottable, this=%s", this); DirectoryWithSnapshotFeature s = this.getDirectoryWithSnapshotFeature(); final DirectorySnapshottableFeature snapshottable = new DirectorySnapshottableFeature(s); if (s != null) { this.removeFeature(s); } this.addFeature(snapshottable); }
/** 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); } }
/** * Copy constructor * @param other The INodeDirectory to be copied * @param adopt Indicate whether or not need to set the parent field of child * INodes to the new node * @param featuresToCopy any number of features to copy to the new node. * The method will do a reference copy, not a deep copy. */ public INodeDirectory(INodeDirectory other, boolean adopt, Feature... featuresToCopy) { super(other); this.children = other.children; if (adopt && this.children != null) { for (INode child : children) { child.setParent(this); } } this.features = featuresToCopy; AclFeature aclFeature = getFeature(AclFeature.class); if (aclFeature != null) { // for the de-duplication of AclFeature removeFeature(aclFeature); addFeature(AclStorage.addAclFeature(aclFeature)); } }
void setQuota(BlockStoragePolicySuite bsps, long nsQuota, long ssQuota, StorageType type) { DirectoryWithQuotaFeature quota = getDirectoryWithQuotaFeature(); if (quota != null) { // already has quota; so set the quota to the new values if (type != null) { quota.setQuota(ssQuota, type); } else { quota.setQuota(nsQuota, ssQuota); } if (!isQuotaSet() && !isRoot()) { removeFeature(quota); } } else { final QuotaCounts c = computeQuotaUsage(bsps); DirectoryWithQuotaFeature.Builder builder = new DirectoryWithQuotaFeature.Builder().nameSpaceQuota(nsQuota); if (type != null) { builder.typeQuota(type, ssQuota); } else { builder.storageSpaceQuota(ssQuota); } addDirectoryWithQuotaFeature(builder.build()).setSpaceConsumed(c); } }
/** add DirectorySnapshottableFeature */ public void addSnapshottableFeature() { Preconditions.checkState(!isSnapshottable(), "this is already snapshottable, this=%s", this); DirectoryWithSnapshotFeature s = this.getDirectoryWithSnapshotFeature(); final DirectorySnapshottableFeature snapshottable = new DirectorySnapshottableFeature(s); if (s != null) { this.removeFeature(s); } this.addFeature(snapshottable); }
/** 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); } }
/** add DirectorySnapshottableFeature */ public void addSnapshottableFeature() { Preconditions.checkState(!isSnapshottable(), "this is already snapshottable, this=%s", this); DirectoryWithSnapshotFeature s = this.getDirectoryWithSnapshotFeature(); final DirectorySnapshottableFeature snapshottable = new DirectorySnapshottableFeature(s); if (s != null) { this.removeFeature(s); } this.addFeature(snapshottable); }
/** 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); } }
/** * Copy constructor * @param other The INodeDirectory to be copied * @param adopt Indicate whether or not need to set the parent field of child * INodes to the new node * @param featuresToCopy any number of features to copy to the new node. * The method will do a reference copy, not a deep copy. */ public INodeDirectory(INodeDirectory other, boolean adopt, Feature... featuresToCopy) { super(other); this.children = other.children; if (adopt && this.children != null) { for (INode child : children) { child.setParent(this); } } this.features = featuresToCopy; AclFeature aclFeature = getFeature(AclFeature.class); if (aclFeature != null) { // for the de-duplication of AclFeature removeFeature(aclFeature); addFeature(AclStorage.addAclFeature(aclFeature)); } }
/** * Copy constructor * @param other The INodeDirectory to be copied * @param adopt Indicate whether or not need to set the parent field of child * INodes to the new node * @param featuresToCopy any number of features to copy to the new node. * The method will do a reference copy, not a deep copy. */ public INodeDirectory(INodeDirectory other, boolean adopt, Feature... featuresToCopy) { super(other); this.children = other.children; if (adopt && this.children != null) { for (INode child : children) { child.setParent(this); } } this.features = featuresToCopy; AclFeature aclFeature = getFeature(AclFeature.class); if (aclFeature != null) { // for the de-duplication of AclFeature removeFeature(aclFeature); addFeature(AclStorage.addAclFeature(aclFeature)); } }
void setQuota(BlockStoragePolicySuite bsps, long nsQuota, long ssQuota, StorageType type) { DirectoryWithQuotaFeature quota = getDirectoryWithQuotaFeature(); if (quota != null) { // already has quota; so set the quota to the new values if (type != null) { quota.setQuota(ssQuota, type); } else { quota.setQuota(nsQuota, ssQuota); } if (!isQuotaSet() && !isRoot()) { removeFeature(quota); } } else { final QuotaCounts c = computeQuotaUsage(bsps); DirectoryWithQuotaFeature.Builder builder = new DirectoryWithQuotaFeature.Builder().nameSpaceQuota(nsQuota); if (type != null) { builder.typeQuota(type, ssQuota); } else { builder.storageSpaceQuota(ssQuota); } addDirectoryWithQuotaFeature(builder.build()).setSpaceConsumed(c); } }
void setQuota(BlockStoragePolicySuite bsps, long nsQuota, long ssQuota, StorageType type) { DirectoryWithQuotaFeature quota = getDirectoryWithQuotaFeature(); if (quota != null) { // already has quota; so set the quota to the new values if (type != null) { quota.setQuota(ssQuota, type); } else { quota.setQuota(nsQuota, ssQuota); } if (!isQuotaSet() && !isRoot()) { removeFeature(quota); } } else { final QuotaCounts c = computeQuotaUsage(bsps); DirectoryWithQuotaFeature.Builder builder = new DirectoryWithQuotaFeature.Builder().nameSpaceQuota(nsQuota); if (type != null) { builder.typeQuota(type, ssQuota); } else { builder.storageSpaceQuota(ssQuota); } addDirectoryWithQuotaFeature(builder.build()).setSpaceConsumed(c); } }