HDFS-9348. Erasure Coding: DFS GetErasureCodingPolicy API on a non-existent file should be handled properly. (Rakesh R via umamahesh)
This commit is contained in:
parent
da1016365a
commit
5b714a2819
@ -864,6 +864,9 @@ Trunk (Unreleased)
|
|||||||
HDFS-9275. Wait previous ErasureCodingWork to finish before schedule
|
HDFS-9275. Wait previous ErasureCodingWork to finish before schedule
|
||||||
another one. (Walter Su via yliu)
|
another one. (Walter Su via yliu)
|
||||||
|
|
||||||
|
HDFS-9348. Erasure Coding: DFS GetErasureCodingPolicy API on a non-existent
|
||||||
|
file should be handled properly. (Rakesh R via umamahesh)
|
||||||
|
|
||||||
Release 2.8.0 - UNRELEASED
|
Release 2.8.0 - UNRELEASED
|
||||||
|
|
||||||
NEW FEATURES
|
NEW FEATURES
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
@ -154,12 +155,16 @@ static List<XAttr> createErasureCodingPolicyXAttr(final FSNamesystem fsn,
|
|||||||
* @param src path
|
* @param src path
|
||||||
* @return {@link ErasureCodingPolicy}
|
* @return {@link ErasureCodingPolicy}
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
* @throws FileNotFoundException if the path does not exist.
|
||||||
*/
|
*/
|
||||||
static ErasureCodingPolicy getErasureCodingPolicy(final FSNamesystem fsn,
|
static ErasureCodingPolicy getErasureCodingPolicy(final FSNamesystem fsn,
|
||||||
final String src) throws IOException {
|
final String src) throws IOException {
|
||||||
assert fsn.hasReadLock();
|
assert fsn.hasReadLock();
|
||||||
|
|
||||||
final INodesInPath iip = getINodesInPath(fsn, src);
|
final INodesInPath iip = getINodesInPath(fsn, src);
|
||||||
|
if (iip.getLastINode() == null) {
|
||||||
|
throw new FileNotFoundException("Path not found: " + iip.getPath());
|
||||||
|
}
|
||||||
return getErasureCodingPolicyForPath(fsn, iip);
|
return getErasureCodingPolicyForPath(fsn, iip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,12 +25,14 @@
|
|||||||
import org.apache.hadoop.hdfs.server.namenode.ErasureCodingPolicyManager;
|
import org.apache.hadoop.hdfs.server.namenode.ErasureCodingPolicyManager;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
|
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.INode;
|
import org.apache.hadoop.hdfs.server.namenode.INode;
|
||||||
|
import org.apache.hadoop.hdfs.client.HdfsAdmin;
|
||||||
import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
|
import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
|
||||||
import org.apache.hadoop.io.erasurecode.ECSchema;
|
import org.apache.hadoop.io.erasurecode.ECSchema;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@ -57,10 +59,12 @@ public void setupCluster() throws IOException {
|
|||||||
|
|
||||||
@After
|
@After
|
||||||
public void shutdownCluster() throws IOException {
|
public void shutdownCluster() throws IOException {
|
||||||
cluster.shutdown();
|
if (cluster != null) {
|
||||||
|
cluster.shutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(timeout = 60000)
|
||||||
public void testBasicSetECPolicy()
|
public void testBasicSetECPolicy()
|
||||||
throws IOException, InterruptedException {
|
throws IOException, InterruptedException {
|
||||||
final Path testDir = new Path("/ec");
|
final Path testDir = new Path("/ec");
|
||||||
@ -115,7 +119,7 @@ public void testBasicSetECPolicy()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(timeout = 60000)
|
||||||
public void testMoveValidity() throws IOException, InterruptedException {
|
public void testMoveValidity() throws IOException, InterruptedException {
|
||||||
final Path srcECDir = new Path("/srcEC");
|
final Path srcECDir = new Path("/srcEC");
|
||||||
final Path dstECDir = new Path("/dstEC");
|
final Path dstECDir = new Path("/dstEC");
|
||||||
@ -152,7 +156,7 @@ public void testMoveValidity() throws IOException, InterruptedException {
|
|||||||
fs.rename(nonECFile, dstECDir);
|
fs.rename(nonECFile, dstECDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(timeout = 60000)
|
||||||
public void testReplication() throws IOException {
|
public void testReplication() throws IOException {
|
||||||
final Path testDir = new Path("/ec");
|
final Path testDir = new Path("/ec");
|
||||||
fs.mkdir(testDir, FsPermission.getDirDefault());
|
fs.mkdir(testDir, FsPermission.getDirDefault());
|
||||||
@ -166,7 +170,7 @@ public void testReplication() throws IOException {
|
|||||||
fs.setReplication(fooFile, (short) 3);
|
fs.setReplication(fooFile, (short) 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(timeout = 60000)
|
||||||
public void testGetErasureCodingPolicyWithSystemDefaultECPolicy() throws Exception {
|
public void testGetErasureCodingPolicyWithSystemDefaultECPolicy() throws Exception {
|
||||||
String src = "/ec";
|
String src = "/ec";
|
||||||
final Path ecDir = new Path(src);
|
final Path ecDir = new Path(src);
|
||||||
@ -182,7 +186,7 @@ public void testGetErasureCodingPolicyWithSystemDefaultECPolicy() throws Excepti
|
|||||||
verifyErasureCodingInfo(src + "/child1", sysDefaultECPolicy);
|
verifyErasureCodingInfo(src + "/child1", sysDefaultECPolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(timeout = 60000)
|
||||||
public void testGetErasureCodingPolicy() throws Exception {
|
public void testGetErasureCodingPolicy() throws Exception {
|
||||||
ErasureCodingPolicy[] sysECPolicies = ErasureCodingPolicyManager.getSystemPolices();
|
ErasureCodingPolicy[] sysECPolicies = ErasureCodingPolicyManager.getSystemPolices();
|
||||||
assertTrue("System ecPolicies should be of only 1 for now",
|
assertTrue("System ecPolicies should be of only 1 for now",
|
||||||
@ -211,7 +215,7 @@ private void verifyErasureCodingInfo(
|
|||||||
usingECPolicy, ecPolicy);
|
usingECPolicy, ecPolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(timeout = 60000)
|
||||||
public void testCreationErasureCodingZoneWithInvalidPolicy()
|
public void testCreationErasureCodingZoneWithInvalidPolicy()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
ECSchema rsSchema = new ECSchema("rs", 4, 2);
|
ECSchema rsSchema = new ECSchema("rs", 4, 2);
|
||||||
@ -219,7 +223,7 @@ public void testCreationErasureCodingZoneWithInvalidPolicy()
|
|||||||
int cellSize = 128 * 1024;
|
int cellSize = 128 * 1024;
|
||||||
ErasureCodingPolicy ecPolicy=
|
ErasureCodingPolicy ecPolicy=
|
||||||
new ErasureCodingPolicy(policyName,rsSchema,cellSize);
|
new ErasureCodingPolicy(policyName,rsSchema,cellSize);
|
||||||
String src = "/ecZone4-2";
|
String src = "/ecDir4-2";
|
||||||
final Path ecDir = new Path(src);
|
final Path ecDir = new Path(src);
|
||||||
try {
|
try {
|
||||||
fs.mkdir(ecDir, FsPermission.getDirDefault());
|
fs.mkdir(ecDir, FsPermission.getDirDefault());
|
||||||
@ -232,7 +236,7 @@ public void testCreationErasureCodingZoneWithInvalidPolicy()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(timeout = 60000)
|
||||||
public void testGetAllErasureCodingPolicies() throws Exception {
|
public void testGetAllErasureCodingPolicies() throws Exception {
|
||||||
ErasureCodingPolicy[] sysECPolicies = ErasureCodingPolicyManager
|
ErasureCodingPolicy[] sysECPolicies = ErasureCodingPolicyManager
|
||||||
.getSystemPolices();
|
.getSystemPolices();
|
||||||
@ -246,4 +250,24 @@ public void testGetAllErasureCodingPolicies() throws Exception {
|
|||||||
assertEquals("Erasure coding policy mismatches",
|
assertEquals("Erasure coding policy mismatches",
|
||||||
sysECPolicies[0], allECPolicies.iterator().next());
|
sysECPolicies[0], allECPolicies.iterator().next());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(timeout = 60000)
|
||||||
|
public void testGetErasureCodingPolicyOnANonExistentFile() throws Exception {
|
||||||
|
Path path = new Path("/ecDir");
|
||||||
|
try {
|
||||||
|
fs.getErasureCodingPolicy(path);
|
||||||
|
fail("FileNotFoundException should be thrown for a non-existent"
|
||||||
|
+ " file path");
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
assertExceptionContains("Path not found: " + path, e);
|
||||||
|
}
|
||||||
|
HdfsAdmin dfsAdmin = new HdfsAdmin(cluster.getURI(), conf);
|
||||||
|
try {
|
||||||
|
dfsAdmin.getErasureCodingPolicy(path);
|
||||||
|
fail("FileNotFoundException should be thrown for a non-existent"
|
||||||
|
+ " file path");
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
assertExceptionContains("Path not found: " + path, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user