|
@@ -44,27 +44,39 @@ import java.io.IOException;
|
|
|
* Make sure we correctly update the quota usage with the striped blocks.
|
|
|
*/
|
|
|
public class TestQuotaWithStripedBlocks {
|
|
|
- private static final int BLOCK_SIZE = 1024 * 1024;
|
|
|
- private static final long DISK_QUOTA = BLOCK_SIZE * 10;
|
|
|
- private final ErasureCodingPolicy ecPolicy =
|
|
|
- StripedFileTestUtil.getDefaultECPolicy();
|
|
|
- private final int dataBlocks = ecPolicy.getNumDataUnits();
|
|
|
- private final int parityBlocsk = ecPolicy.getNumParityUnits();
|
|
|
- private final int groupSize = dataBlocks + parityBlocsk;
|
|
|
- private final int cellSize = ecPolicy.getCellSize();
|
|
|
- private static final Path ecDir = new Path("/ec");
|
|
|
+ private int blockSize;
|
|
|
+ private ErasureCodingPolicy ecPolicy;
|
|
|
+ private int dataBlocks;
|
|
|
+ private int parityBlocsk;
|
|
|
+ private int groupSize;
|
|
|
+ private int cellSize;
|
|
|
+ private Path ecDir;
|
|
|
+ private long diskQuota;
|
|
|
|
|
|
private MiniDFSCluster cluster;
|
|
|
private FSDirectory dir;
|
|
|
private DistributedFileSystem dfs;
|
|
|
|
|
|
+ public ErasureCodingPolicy getEcPolicy() {
|
|
|
+ return StripedFileTestUtil.getDefaultECPolicy();
|
|
|
+ }
|
|
|
+
|
|
|
@Rule
|
|
|
public Timeout globalTimeout = new Timeout(300000);
|
|
|
|
|
|
@Before
|
|
|
public void setUp() throws IOException {
|
|
|
+ blockSize = 1024 * 1024;
|
|
|
+ ecPolicy = getEcPolicy();
|
|
|
+ dataBlocks = ecPolicy.getNumDataUnits();
|
|
|
+ parityBlocsk = ecPolicy.getNumParityUnits();
|
|
|
+ groupSize = dataBlocks + parityBlocsk;
|
|
|
+ cellSize = ecPolicy.getCellSize();
|
|
|
+ ecDir = new Path("/ec");
|
|
|
+ diskQuota = blockSize * (groupSize + 1);
|
|
|
+
|
|
|
final Configuration conf = new Configuration();
|
|
|
- conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, BLOCK_SIZE);
|
|
|
+ conf.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, blockSize);
|
|
|
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(groupSize).build();
|
|
|
cluster.waitActive();
|
|
|
|
|
@@ -75,8 +87,8 @@ public class TestQuotaWithStripedBlocks {
|
|
|
dfs.mkdirs(ecDir);
|
|
|
dfs.getClient()
|
|
|
.setErasureCodingPolicy(ecDir.toString(), ecPolicy.getName());
|
|
|
- dfs.setQuota(ecDir, Long.MAX_VALUE - 1, DISK_QUOTA);
|
|
|
- dfs.setQuotaByStorageType(ecDir, StorageType.DISK, DISK_QUOTA);
|
|
|
+ dfs.setQuota(ecDir, Long.MAX_VALUE - 1, diskQuota);
|
|
|
+ dfs.setQuotaByStorageType(ecDir, StorageType.DISK, diskQuota);
|
|
|
dfs.setStoragePolicy(ecDir, HdfsConstants.HOT_STORAGE_POLICY_NAME);
|
|
|
}
|
|
|
|
|
@@ -112,8 +124,8 @@ public class TestQuotaWithStripedBlocks {
|
|
|
final long diskUsed = dirNode.getDirectoryWithQuotaFeature()
|
|
|
.getSpaceConsumed().getTypeSpaces().get(StorageType.DISK);
|
|
|
// When we add a new block we update the quota using the full block size.
|
|
|
- Assert.assertEquals(BLOCK_SIZE * groupSize, spaceUsed);
|
|
|
- Assert.assertEquals(BLOCK_SIZE * groupSize, diskUsed);
|
|
|
+ Assert.assertEquals(blockSize * groupSize, spaceUsed);
|
|
|
+ Assert.assertEquals(blockSize * groupSize, diskUsed);
|
|
|
|
|
|
dfs.getClient().getNamenode().complete(file.toString(),
|
|
|
dfs.getClient().getClientName(), previous, fileNode.getId());
|