|
@@ -74,15 +74,39 @@ public class TestINodeFile {
|
|
|
static final short BLOCKBITS = 48;
|
|
|
static final long BLKSIZE_MAXVALUE = ~(0xffffL << BLOCKBITS);
|
|
|
|
|
|
- private final PermissionStatus perm = new PermissionStatus(
|
|
|
+ private static final PermissionStatus perm = new PermissionStatus(
|
|
|
"userName", null, FsPermission.getDefault());
|
|
|
private short replication;
|
|
|
private long preferredBlockSize = 1024;
|
|
|
|
|
|
INodeFile createINodeFile(short replication, long preferredBlockSize) {
|
|
|
return new INodeFile(INodeId.GRANDFATHER_INODE_ID, null, perm, 0L, 0L,
|
|
|
- null, replication, preferredBlockSize);
|
|
|
+ null, replication, preferredBlockSize, (byte)0);
|
|
|
}
|
|
|
+
|
|
|
+ private static INodeFile createINodeFile(byte storagePolicyID) {
|
|
|
+ return new INodeFile(INodeId.GRANDFATHER_INODE_ID, null, perm, 0L, 0L,
|
|
|
+ null, (short)3, 1024L, storagePolicyID);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testStoragePolicyID () {
|
|
|
+ for(byte i = 0; i < 16; i++) {
|
|
|
+ final INodeFile f = createINodeFile(i);
|
|
|
+ assertEquals(i, f.getStoragePolicyID());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test(expected=IllegalArgumentException.class)
|
|
|
+ public void testStoragePolicyIdBelowLowerBound () throws IllegalArgumentException {
|
|
|
+ createINodeFile((byte)-1);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test(expected=IllegalArgumentException.class)
|
|
|
+ public void testStoragePolicyIdAboveUpperBound () throws IllegalArgumentException {
|
|
|
+ createINodeFile((byte)16);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Test for the Replication value. Sets a value and checks if it was set
|
|
|
* correct.
|
|
@@ -258,7 +282,7 @@ public class TestINodeFile {
|
|
|
INodeFile[] iNodes = new INodeFile[nCount];
|
|
|
for (int i = 0; i < nCount; i++) {
|
|
|
iNodes[i] = new INodeFile(i, null, perm, 0L, 0L, null, replication,
|
|
|
- preferredBlockSize);
|
|
|
+ preferredBlockSize, (byte)0);
|
|
|
iNodes[i].setLocalName(DFSUtil.string2Bytes(fileNamePrefix + i));
|
|
|
BlockInfo newblock = new BlockInfo(replication);
|
|
|
iNodes[i].addBlock(newblock);
|
|
@@ -315,7 +339,8 @@ public class TestINodeFile {
|
|
|
|
|
|
{//cast from INodeFileUnderConstruction
|
|
|
final INode from = new INodeFile(
|
|
|
- INodeId.GRANDFATHER_INODE_ID, null, perm, 0L, 0L, null, replication, 1024L);
|
|
|
+ INodeId.GRANDFATHER_INODE_ID, null, perm, 0L, 0L, null, replication,
|
|
|
+ 1024L, (byte)0);
|
|
|
from.asFile().toUnderConstruction("client", "machine");
|
|
|
|
|
|
//cast to INodeFile, should success
|
|
@@ -1063,7 +1088,7 @@ public class TestINodeFile {
|
|
|
public void testFileUnderConstruction() {
|
|
|
replication = 3;
|
|
|
final INodeFile file = new INodeFile(INodeId.GRANDFATHER_INODE_ID, null,
|
|
|
- perm, 0L, 0L, null, replication, 1024L);
|
|
|
+ perm, 0L, 0L, null, replication, 1024L, (byte)0);
|
|
|
assertFalse(file.isUnderConstruction());
|
|
|
|
|
|
final String clientName = "client";
|