return; if (!namenode.getRpcServer().mkdirs( target, file.getPermission(), true)) { throw new IOException("failed to create directory " + target);
@Override public void run() { thr = Thread.currentThread(); FsPermission p = new FsPermission((short)0777); int i = 0; while (!stopped) { try { String dirname = "/thr-" + thr.getId() + "-dir-" + i; nn.mkdirs(dirname, p, true); nn.delete(dirname, true); } catch (SafeModeException sme) { // This is OK - the tests will bring NN in and out of safemode } catch (Throwable e) { LOG.warn("Got error in transaction thread", e); caught.compareAndSet(null, e); break; } i++; } }
return; if (!namenode.getRpcServer().mkdirs( target, file.getPermission(), true)) { throw new IOException("failed to create directory " + target);
return; if (!namenode.getRpcServer().mkdirs( target, file.getPermission(), true)) { throw new IOException("failed to create directory " + target);
final boolean b = np.mkdirs(fullpath, permission.getFsPermission(), true); final String js = JsonUtil.toJsonString("boolean", b); return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
final boolean b = np.mkdirs(fullpath, permission.getFsPermission(), true); final String js = JsonUtil.toJsonString("boolean", b); return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
/** * Regression test for HDFS-3626. Creates a file using a non-canonical path * (i.e. with extra slashes between components) and makes sure that the NN * rejects it. */ @Test public void testMkdirRpcNonCanonicalPath() throws IOException { MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build(); try { NamenodeProtocols nnrpc = cluster.getNameNodeRpc(); for (String pathStr : NON_CANONICAL_PATHS) { try { nnrpc.mkdirs(pathStr, new FsPermission((short)0755), true); fail("Did not fail when called with a non-canonicalized path: " + pathStr); } catch (InvalidPathException ipe) { // expected } } } finally { cluster.shutdown(); } } }
/** * Test for rename2 */ @Test public void testRename2() throws Exception { String src = "/testNamenodeRetryCache/testRename2/src"; String target = "/testNamenodeRetryCache/testRename2/target"; resetCall(); nnRpc.mkdirs(src, perm, true); // Retried renames succeed newCall(); nnRpc.rename2(src, target, Rename.NONE); nnRpc.rename2(src, target, Rename.NONE); nnRpc.rename2(src, target, Rename.NONE); // A non-retried request fails newCall(); try { nnRpc.rename2(src, target, Rename.NONE); Assert.fail("testRename 2 expected exception is not thrown"); } catch (IOException e) { // expected } }
/** * Tests for delete call */ @Test public void testDelete() throws Exception { String dir = "/testNamenodeRetryCache/testDelete"; // Two retried calls to create a non existent file newCall(); nnRpc.mkdirs(dir, perm, true); newCall(); Assert.assertTrue(nnRpc.delete(dir, false)); Assert.assertTrue(nnRpc.delete(dir, false)); Assert.assertTrue(nnRpc.delete(dir, false)); // non-retried call fails and gets false as return newCall(); Assert.assertFalse(nnRpc.delete(dir, false)); }
/** * Test for rename1 */ @SuppressWarnings("deprecation") @Test public void testRename1() throws Exception { String src = "/testNamenodeRetryCache/testRename1/src"; String target = "/testNamenodeRetryCache/testRename1/target"; resetCall(); nnRpc.mkdirs(src, perm, true); // Retried renames succeed newCall(); Assert.assertTrue(nnRpc.rename(src, target)); Assert.assertTrue(nnRpc.rename(src, target)); Assert.assertTrue(nnRpc.rename(src, target)); // A non-retried request fails newCall(); Assert.assertFalse(nnRpc.rename(src, target)); }
String dir = "/testNamenodeRetryCache/testCreateSnapshot/src"; resetCall(); nnRpc.mkdirs(dir, perm, true); nnRpc.allowSnapshot(dir);