/** * Update xattrs of inode. * <p/> * Must be called while holding the FSDirectory write lock. * * @param inode INode to update * @param xAttrs to update xAttrs. * @param snapshotId id of the latest snapshot of the inode */ public static void updateINodeXAttrs(INode inode, List<XAttr> xAttrs, int snapshotId) throws QuotaExceededException { if (inode.getXAttrFeature() != null) { inode.removeXAttrFeature(snapshotId); } if (xAttrs == null || xAttrs.isEmpty()) { return; } inode.addXAttrFeature(new XAttrFeature(xAttrs), snapshotId); } }
xAttrs = new XAttrFeature(FSImageFormatPBINode.Loader.loadXAttrs( fileInPb.getXAttrs(), state.getStringTable()));
file.addXAttrFeature(new XAttrFeature( loadXAttrs(f.getXAttrs(), state.getStringTable())));
dir.addXAttrFeature(new XAttrFeature( loadXAttrs(d.getXAttrs(), state.getStringTable())));
xAttrs = new XAttrFeature(FSImageFormatPBINode.Loader.loadXAttrs( dirCopyInPb.getXAttrs(), state.getStringTable()));
inode.removeXAttrFeature(snapshotId); inode.addXAttrFeature(new XAttrFeature(newXAttrs), snapshotId);
inode.removeXAttrFeature(snapshotId); inode.addXAttrFeature(new XAttrFeature(newXAttrs), snapshotId);
@Override public XAttrFeature getXAttrFeature() { XAttrFeature x; if (useDefault) { x = inode.getXAttrFeature(); } else { x = new XAttrFeature(ImmutableList.copyOf( Lists.newArrayList( new XAttr.Builder().setName("test") .setValue(new byte[] {1, 2}) .build()))); } return x; }
@Test public void testXAttrFeature() { replication = 3; preferredBlockSize = 128*1024*1024; INodeFile inf = createINodeFile(replication, preferredBlockSize); ImmutableList.Builder<XAttr> builder = new ImmutableList.Builder<XAttr>(); XAttr xAttr = new XAttr.Builder().setNameSpace(XAttr.NameSpace.USER). setName("a1").setValue(new byte[]{0x31, 0x32, 0x33}).build(); builder.add(xAttr); XAttrFeature f = new XAttrFeature(builder.build()); inf.addXAttrFeature(f); XAttrFeature f1 = inf.getXAttrFeature(); assertEquals(xAttr, f1.getXAttrs().get(0)); inf.removeXAttrFeature(); f1 = inf.getXAttrFeature(); assertEquals(f1, null); } }
file.addXAttrFeature(new XAttrFeature( loadXAttrs(f.getXAttrs(), state.getStringTable())));
file.addXAttrFeature(new XAttrFeature( loadXAttrs(f.getXAttrs(), state.getStringTable())));
xAttrs = new XAttrFeature(FSImageFormatPBINode.Loader.loadXAttrs( fileInPb.getXAttrs(), state.getStringTable()));
xAttrs = new XAttrFeature(FSImageFormatPBINode.Loader.loadXAttrs( fileInPb.getXAttrs(), state.getStringTable()));
xAttrs = new XAttrFeature(FSImageFormatPBINode.Loader.loadXAttrs( dirCopyInPb.getXAttrs(), state.getStringTable()));
dir.addXAttrFeature(new XAttrFeature( loadXAttrs(d.getXAttrs(), state.getStringTable())));
xAttrs = new XAttrFeature(FSImageFormatPBINode.Loader.loadXAttrs( dirCopyInPb.getXAttrs(), state.getStringTable()));
dir.addXAttrFeature(new XAttrFeature( loadXAttrs(d.getXAttrs(), state.getStringTable())));