[
https://issues.apache.org/jira/browse/HDFS-9534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15110288#comment-15110288
]
Vinayakumar B commented on HDFS-9534:
-------------------------------------
1.
{code}
/**
+ * Remove the storage policy st for a given file or directory,
+ * and set it to unspecified storage policy.
+ * @param src file or directory path.
+ * @throws IOException
+ */
{code}
There is a nit, {{storage policy st for a}}.
Also I think, {{set it to unspecified storage policy}} this sentence is not
required. As chris said, let it be transparent to user.
Similar changes in other places as well.
2. In {{FSDirAttrOp#setDirStoragePolicy}}, in case of removal, we should
actually remove the xattr, instead of setting with UNSPECIFIED. It will be
extra xattr, which adds to memory.
May be following would work.
{code}
@@ -485,11 +489,18 @@ private static void setDirStoragePolicy(
int latestSnapshotId) throws IOException {
List<XAttr> existingXAttrs = XAttrStorage.readINodeXAttrs(inode);
XAttr xAttr = BlockStoragePolicySuite.buildXAttr(policyId);
- List<XAttr> newXAttrs = FSDirXAttrOp.setINodeXAttrs(fsd, existingXAttrs,
- Arrays.asList(xAttr),
- EnumSet.of(
-
XAttrSetFlag.CREATE,
-
XAttrSetFlag.REPLACE));
+ List<XAttr> newXAttrs = null;
+ if (policyId == BLOCK_STORAGE_POLICY_ID_UNSPECIFIED) {
+ List<XAttr> toRemove = Lists.newArrayList();
+ toRemove.add(xAttr);
+ List<XAttr> removed = Lists.newArrayList();
+ newXAttrs =
+ FSDirXAttrOp.filterINodeXAttrs(existingXAttrs, toRemove, removed);
+ } else {
+ newXAttrs =
+ FSDirXAttrOp.setINodeXAttrs(fsd, existingXAttrs,
Arrays.asList(xAttr),
+ EnumSet.of(XAttrSetFlag.CREATE, XAttrSetFlag.REPLACE));
+ }
XAttrStorage.updateINodeXAttrs(inode, newXAttrs, latestSnapshotId);
}
{code}
Agree?
> Add CLI command to clear storage policy from a path.
> ----------------------------------------------------
>
> Key: HDFS-9534
> URL: https://issues.apache.org/jira/browse/HDFS-9534
> Project: Hadoop HDFS
> Issue Type: Improvement
> Components: tools
> Reporter: Chris Nauroth
> Assignee: Xiaobing Zhou
> Attachments: HDFS-9534.001.patch
>
>
> The {{hdfs storagepolicies}} command has sub-commands for
> {{-setStoragePolicy}} and {{-getStoragePolicy}} on a path. However, there is
> no {{-removeStoragePolicy}} to remove a previously set storage policy on a
> path.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)