|
@@ -31,13 +31,13 @@ import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
|
|
+import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.fs.RemoteIterator;
|
|
import org.apache.hadoop.fs.RemoteIterator;
|
|
import org.apache.hadoop.fs.permission.FsPermission;
|
|
import org.apache.hadoop.fs.permission.FsPermission;
|
|
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
|
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
|
import org.apache.hadoop.hdfs.DistributedFileSystem;
|
|
import org.apache.hadoop.hdfs.DistributedFileSystem;
|
|
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
|
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
|
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
|
import org.apache.hadoop.hdfs.MiniDFSCluster;
|
|
-import org.apache.hadoop.hdfs.protocol.AddPathBasedCacheDirectiveException.EmptyPathError;
|
|
|
|
import org.apache.hadoop.hdfs.protocol.AddPathBasedCacheDirectiveException.InvalidPathNameError;
|
|
import org.apache.hadoop.hdfs.protocol.AddPathBasedCacheDirectiveException.InvalidPathNameError;
|
|
import org.apache.hadoop.hdfs.protocol.AddPathBasedCacheDirectiveException.InvalidPoolNameError;
|
|
import org.apache.hadoop.hdfs.protocol.AddPathBasedCacheDirectiveException.InvalidPoolNameError;
|
|
import org.apache.hadoop.hdfs.protocol.AddPathBasedCacheDirectiveException.PoolWritePermissionDeniedError;
|
|
import org.apache.hadoop.hdfs.protocol.AddPathBasedCacheDirectiveException.PoolWritePermissionDeniedError;
|
|
@@ -312,12 +312,18 @@ public class TestPathBasedCacheRequests {
|
|
proto.addCachePool(new CachePoolInfo("pool4").
|
|
proto.addCachePool(new CachePoolInfo("pool4").
|
|
setMode(new FsPermission((short)0)));
|
|
setMode(new FsPermission((short)0)));
|
|
|
|
|
|
- PathBasedCacheDirective alpha =
|
|
|
|
- new PathBasedCacheDirective("/alpha", "pool1");
|
|
|
|
- PathBasedCacheDirective beta =
|
|
|
|
- new PathBasedCacheDirective("/beta", "pool2");
|
|
|
|
- PathBasedCacheDirective delta =
|
|
|
|
- new PathBasedCacheDirective("/delta", "pool1");
|
|
|
|
|
|
+ PathBasedCacheDirective alpha = new PathBasedCacheDirective.Builder().
|
|
|
|
+ setPath(new Path("/alpha")).
|
|
|
|
+ setPool("pool1").
|
|
|
|
+ build();
|
|
|
|
+ PathBasedCacheDirective beta = new PathBasedCacheDirective.Builder().
|
|
|
|
+ setPath(new Path("/beta")).
|
|
|
|
+ setPool("pool2").
|
|
|
|
+ build();
|
|
|
|
+ PathBasedCacheDirective delta = new PathBasedCacheDirective.Builder().
|
|
|
|
+ setPath(new Path("/delta")).
|
|
|
|
+ setPool("pool1").
|
|
|
|
+ build();
|
|
|
|
|
|
PathBasedCacheDescriptor alphaD = addAsUnprivileged(alpha);
|
|
PathBasedCacheDescriptor alphaD = addAsUnprivileged(alpha);
|
|
PathBasedCacheDescriptor alphaD2 = addAsUnprivileged(alpha);
|
|
PathBasedCacheDescriptor alphaD2 = addAsUnprivileged(alpha);
|
|
@@ -326,21 +332,20 @@ public class TestPathBasedCacheRequests {
|
|
PathBasedCacheDescriptor betaD = addAsUnprivileged(beta);
|
|
PathBasedCacheDescriptor betaD = addAsUnprivileged(beta);
|
|
|
|
|
|
try {
|
|
try {
|
|
- addAsUnprivileged(new PathBasedCacheDirective("", "pool3"));
|
|
|
|
- fail("expected an error when adding an empty path");
|
|
|
|
- } catch (IOException ioe) {
|
|
|
|
- assertTrue(ioe instanceof EmptyPathError);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- addAsUnprivileged(new PathBasedCacheDirective("/unicorn", "no_such_pool"));
|
|
|
|
|
|
+ addAsUnprivileged(new PathBasedCacheDirective.Builder().
|
|
|
|
+ setPath(new Path("/unicorn")).
|
|
|
|
+ setPool("no_such_pool").
|
|
|
|
+ build());
|
|
fail("expected an error when adding to a non-existent pool.");
|
|
fail("expected an error when adding to a non-existent pool.");
|
|
} catch (IOException ioe) {
|
|
} catch (IOException ioe) {
|
|
assertTrue(ioe instanceof InvalidPoolNameError);
|
|
assertTrue(ioe instanceof InvalidPoolNameError);
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
- addAsUnprivileged(new PathBasedCacheDirective("/blackhole", "pool4"));
|
|
|
|
|
|
+ addAsUnprivileged(new PathBasedCacheDirective.Builder().
|
|
|
|
+ setPath(new Path("/blackhole")).
|
|
|
|
+ setPool("pool4").
|
|
|
|
+ build());
|
|
fail("expected an error when adding to a pool with " +
|
|
fail("expected an error when adding to a pool with " +
|
|
"mode 0 (no permissions for anyone).");
|
|
"mode 0 (no permissions for anyone).");
|
|
} catch (IOException ioe) {
|
|
} catch (IOException ioe) {
|
|
@@ -348,43 +353,49 @@ public class TestPathBasedCacheRequests {
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
- addAsUnprivileged(new PathBasedCacheDirective("//illegal/path/", "pool1"));
|
|
|
|
|
|
+ addAsUnprivileged(new PathBasedCacheDirective.Builder().
|
|
|
|
+ setPath(new Path("/illegal:path/")).
|
|
|
|
+ setPool("pool1").
|
|
|
|
+ build());
|
|
fail("expected an error when adding a malformed path " +
|
|
fail("expected an error when adding a malformed path " +
|
|
"to the cache directives.");
|
|
"to the cache directives.");
|
|
- } catch (IOException ioe) {
|
|
|
|
- assertTrue(ioe instanceof InvalidPathNameError);
|
|
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
+ // expected
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
- addAsUnprivileged(new PathBasedCacheDirective("/emptypoolname", ""));
|
|
|
|
|
|
+ addAsUnprivileged(new PathBasedCacheDirective.Builder().
|
|
|
|
+ setPath(new Path("/emptypoolname")).
|
|
|
|
+ setPool("").
|
|
|
|
+ build());
|
|
Assert.fail("expected an error when adding a PathBasedCache " +
|
|
Assert.fail("expected an error when adding a PathBasedCache " +
|
|
"directive with an empty pool name.");
|
|
"directive with an empty pool name.");
|
|
} catch (IOException ioe) {
|
|
} catch (IOException ioe) {
|
|
Assert.assertTrue(ioe instanceof InvalidPoolNameError);
|
|
Assert.assertTrue(ioe instanceof InvalidPoolNameError);
|
|
}
|
|
}
|
|
|
|
|
|
- try {
|
|
|
|
- addAsUnprivileged(new PathBasedCacheDirective("bogus", "pool1"));
|
|
|
|
- Assert.fail("expected an error when adding a PathBasedCache " +
|
|
|
|
- "directive with a non-absolute path name.");
|
|
|
|
- } catch (IOException ioe) {
|
|
|
|
- Assert.assertTrue(ioe instanceof InvalidPathNameError);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
PathBasedCacheDescriptor deltaD = addAsUnprivileged(delta);
|
|
PathBasedCacheDescriptor deltaD = addAsUnprivileged(delta);
|
|
|
|
|
|
|
|
+ // We expect the following to succeed, because DistributedFileSystem
|
|
|
|
+ // qualifies the path.
|
|
|
|
+ PathBasedCacheDescriptor relativeD = addAsUnprivileged(
|
|
|
|
+ new PathBasedCacheDirective.Builder().
|
|
|
|
+ setPath(new Path("relative")).
|
|
|
|
+ setPool("pool1").
|
|
|
|
+ build());
|
|
|
|
+
|
|
RemoteIterator<PathBasedCacheDescriptor> iter;
|
|
RemoteIterator<PathBasedCacheDescriptor> iter;
|
|
- iter = proto.listPathBasedCacheDescriptors(0, null, null);
|
|
|
|
- validateListAll(iter, alphaD, betaD, deltaD);
|
|
|
|
- iter = proto.listPathBasedCacheDescriptors(0, "pool3", null);
|
|
|
|
|
|
+ iter = dfs.listPathBasedCacheDescriptors(null, null);
|
|
|
|
+ validateListAll(iter, alphaD, betaD, deltaD, relativeD);
|
|
|
|
+ iter = dfs.listPathBasedCacheDescriptors("pool3", null);
|
|
Assert.assertFalse(iter.hasNext());
|
|
Assert.assertFalse(iter.hasNext());
|
|
- iter = proto.listPathBasedCacheDescriptors(0, "pool1", null);
|
|
|
|
- validateListAll(iter, alphaD, deltaD);
|
|
|
|
- iter = proto.listPathBasedCacheDescriptors(0, "pool2", null);
|
|
|
|
|
|
+ iter = dfs.listPathBasedCacheDescriptors("pool1", null);
|
|
|
|
+ validateListAll(iter, alphaD, deltaD, relativeD);
|
|
|
|
+ iter = dfs.listPathBasedCacheDescriptors("pool2", null);
|
|
validateListAll(iter, betaD);
|
|
validateListAll(iter, betaD);
|
|
|
|
|
|
dfs.removePathBasedCacheDescriptor(betaD);
|
|
dfs.removePathBasedCacheDescriptor(betaD);
|
|
- iter = proto.listPathBasedCacheDescriptors(0, "pool2", null);
|
|
|
|
|
|
+ iter = dfs.listPathBasedCacheDescriptors("pool2", null);
|
|
Assert.assertFalse(iter.hasNext());
|
|
Assert.assertFalse(iter.hasNext());
|
|
|
|
|
|
try {
|
|
try {
|
|
@@ -409,7 +420,8 @@ public class TestPathBasedCacheRequests {
|
|
|
|
|
|
dfs.removePathBasedCacheDescriptor(alphaD);
|
|
dfs.removePathBasedCacheDescriptor(alphaD);
|
|
dfs.removePathBasedCacheDescriptor(deltaD);
|
|
dfs.removePathBasedCacheDescriptor(deltaD);
|
|
- iter = proto.listPathBasedCacheDescriptors(0, null, null);
|
|
|
|
|
|
+ dfs.removePathBasedCacheDescriptor(relativeD);
|
|
|
|
+ iter = dfs.listPathBasedCacheDescriptors(null, null);
|
|
assertFalse(iter.hasNext());
|
|
assertFalse(iter.hasNext());
|
|
}
|
|
}
|
|
}
|
|
}
|