|
@@ -41,23 +41,6 @@ import com.google.common.base.Preconditions;
|
|
|
@InterfaceAudience.Private
|
|
|
public class INodeFile extends INodeWithAdditionalFields
|
|
|
implements INodeFileAttributes, BlockCollection {
|
|
|
- /**
|
|
|
- * A feature contains specific information for a type of INodeFile. E.g.,
|
|
|
- * we can have separate features for Under-Construction and Snapshot.
|
|
|
- */
|
|
|
- public static abstract class Feature implements INode.Feature<Feature> {
|
|
|
- private Feature nextFeature;
|
|
|
-
|
|
|
- @Override
|
|
|
- public Feature getNextFeature() {
|
|
|
- return nextFeature;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void setNextFeature(Feature next) {
|
|
|
- this.nextFeature = next;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
/** The same as valueOf(inode, path, false). */
|
|
|
public static INodeFile valueOf(INode inode, String path
|
|
@@ -120,8 +103,6 @@ public class INodeFile extends INodeWithAdditionalFields
|
|
|
|
|
|
private BlockInfo[] blocks;
|
|
|
|
|
|
- private Feature headFeature;
|
|
|
-
|
|
|
INodeFile(long id, byte[] name, PermissionStatus permissions, long mtime,
|
|
|
long atime, BlockInfo[] blklist, short replication,
|
|
|
long preferredBlockSize) {
|
|
@@ -135,7 +116,7 @@ public class INodeFile extends INodeWithAdditionalFields
|
|
|
super(that);
|
|
|
this.header = that.header;
|
|
|
this.blocks = that.blocks;
|
|
|
- this.headFeature = that.headFeature;
|
|
|
+ this.features = that.features;
|
|
|
}
|
|
|
|
|
|
public INodeFile(INodeFile that, FileDiffList diffs) {
|
|
@@ -144,14 +125,6 @@ public class INodeFile extends INodeWithAdditionalFields
|
|
|
this.addSnapshotFeature(diffs);
|
|
|
}
|
|
|
|
|
|
- private void addFeature(Feature f) {
|
|
|
- headFeature = INode.Feature.Util.addFeature(f, headFeature);
|
|
|
- }
|
|
|
-
|
|
|
- private void removeFeature(Feature f) {
|
|
|
- headFeature = INode.Feature.Util.removeFeature(f, headFeature);
|
|
|
- }
|
|
|
-
|
|
|
/** @return true unconditionally. */
|
|
|
@Override
|
|
|
public final boolean isFile() {
|
|
@@ -171,7 +144,7 @@ public class INodeFile extends INodeWithAdditionalFields
|
|
|
* otherwise, return null.
|
|
|
*/
|
|
|
public final FileUnderConstructionFeature getFileUnderConstructionFeature() {
|
|
|
- for (Feature f = this.headFeature; f != null; f = f.nextFeature) {
|
|
|
+ for (Feature f : features) {
|
|
|
if (f instanceof FileUnderConstructionFeature) {
|
|
|
return (FileUnderConstructionFeature) f;
|
|
|
}
|
|
@@ -283,7 +256,7 @@ public class INodeFile extends INodeWithAdditionalFields
|
|
|
* otherwise, return null.
|
|
|
*/
|
|
|
public final FileWithSnapshotFeature getFileWithSnapshotFeature() {
|
|
|
- for (Feature f = headFeature; f != null; f = f.nextFeature) {
|
|
|
+ for (Feature f: features) {
|
|
|
if (f instanceof FileWithSnapshotFeature) {
|
|
|
return (FileWithSnapshotFeature) f;
|
|
|
}
|