You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by vi...@apache.org on 2013/09/03 20:30:16 UTC
svn commit: r1519787 [3/4] - in
/hadoop/common/branches/YARN-321/hadoop-hdfs-project: ./ hadoop-hdfs-nfs/
hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/mount/
hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/ hadoop-hdfs/
hadoop...
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/metrics/NameNodeMetrics.java Tue Sep 3 18:30:05 2013
@@ -80,8 +80,10 @@ public class NameNodeMetrics {
@Metric("Block report") MutableRate blockReport;
MutableQuantiles[] blockReportQuantiles;
- @Metric("Duration in SafeMode at startup") MutableGaugeInt safeModeTime;
- @Metric("Time loading FS Image at startup") MutableGaugeInt fsImageLoadTime;
+ @Metric("Duration in SafeMode at startup in msec")
+ MutableGaugeInt safeModeTime;
+ @Metric("Time loading FS Image at startup in msec")
+ MutableGaugeInt fsImageLoadTime;
NameNodeMetrics(String processName, String sessionId, int[] intervals) {
registry.tag(ProcessName, processName).tag(SessionId, sessionId);
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/proto/QJournalProtocol.proto
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/proto/QJournalProtocol.proto?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/proto/QJournalProtocol.proto (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/proto/QJournalProtocol.proto Tue Sep 3 18:30:05 2013
@@ -177,6 +177,7 @@ message GetEditLogManifestRequestProto {
required uint64 sinceTxId = 2; // Transaction ID
// Whether or not the client will be reading from the returned streams.
optional bool forReading = 3 [default = true];
+ optional bool inProgressOk = 4 [default = false];
}
message GetEditLogManifestResponseProto {
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml Tue Sep 3 18:30:05 2013
@@ -52,6 +52,18 @@
</property>
<property>
+ <name>dfs.namenode.rpc-bind-host</name>
+ <value></value>
+ <description>
+ The actual address the server will bind to. If this optional address is
+ set, the RPC server will bind to this address and the port specified in
+ dfs.namenode.rpc-address for the RPC server. It can also be specified
+ per name node or name service for HA/Federation. This is most useful for
+ making name node listen to all interfaces by setting to 0.0.0.0.
+ </description>
+</property>
+
+<property>
<name>dfs.namenode.servicerpc-address</name>
<value></value>
<description>
@@ -65,6 +77,18 @@
</property>
<property>
+ <name>dfs.namenode.servicerpc-bind-host</name>
+ <value></value>
+ <description>
+ The actual address the server will bind to. If this optional address is
+ set, the service RPC server will bind to this address and the port
+ specified in dfs.namenode.servicerpc-address. It can also be specified
+ per name node or name service for HA/Federation. This is most useful for
+ making name node listen to all interfaces by setting to 0.0.0.0.
+ </description>
+</property>
+
+<property>
<name>dfs.namenode.secondary.http-address</name>
<value>0.0.0.0:50090</value>
<description>
Propchange: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode/
------------------------------------------------------------------------------
Merged /hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/datanode:r1503799-1519783
Propchange: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/
------------------------------------------------------------------------------
Merged /hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs:r1513206-1519783
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.jsp
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.jsp?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.jsp (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.jsp Tue Sep 3 18:30:05 2013
@@ -65,6 +65,7 @@
<h3>Cluster Summary</h3>
<b> <%= NamenodeJspHelper.getSecurityModeText()%> </b>
<b> <%= NamenodeJspHelper.getSafeModeText(fsn)%> </b>
+<b> <%= NamenodeJspHelper.getRollingUpgradeText(fsn)%> </b>
<b> <%= NamenodeJspHelper.getInodeLimitText(fsn)%> </b>
<%= NamenodeJspHelper.getCorruptFilesWarning(fsn)%>
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/index.html
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/index.html?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/index.html (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/index.html Tue Sep 3 18:30:05 2013
@@ -1,5 +1,3 @@
-<meta HTTP-EQUIV="REFRESH" content="0;url=dfshealth.jsp"/>
-<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -16,6 +14,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
+<meta HTTP-EQUIV="REFRESH" content="0;url=dfshealth.jsp"/>
+<html>
<head>
<title>Hadoop Administration</title>
</head>
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestGlobPaths.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestGlobPaths.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestGlobPaths.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestGlobPaths.java Tue Sep 3 18:30:05 2013
@@ -20,7 +20,6 @@ package org.apache.hadoop.fs;
import static org.junit.Assert.*;
import java.io.IOException;
-import java.util.Arrays;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
@@ -30,8 +29,6 @@ import org.apache.hadoop.hdfs.HdfsConfig
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.junit.*;
-import com.google.common.base.Joiner;
-
public class TestGlobPaths {
static class RegexPathFilter implements PathFilter {
@@ -50,6 +47,7 @@ public class TestGlobPaths {
static private MiniDFSCluster dfsCluster;
static private FileSystem fs;
+ static private FileContext fc;
static final private int NUM_OF_PATHS = 4;
static private String USER_DIR;
private Path[] path = new Path[NUM_OF_PATHS];
@@ -59,6 +57,7 @@ public class TestGlobPaths {
Configuration conf = new HdfsConfiguration();
dfsCluster = new MiniDFSCluster.Builder(conf).build();
fs = FileSystem.get(conf);
+ fc = FileContext.getFileContext(conf);
USER_DIR = fs.getHomeDirectory().toUri().getPath().toString();
}
@@ -405,6 +404,8 @@ public class TestGlobPaths {
status = fs.globStatus(new Path("/x/x"), falseFilter);
assertNull(status);
+
+ cleanupDFS();
}
private void checkStatus(FileStatus[] status, Path ... expectedMatches) {
@@ -464,6 +465,9 @@ public class TestGlobPaths {
@Test
public void pTestEscape() throws IOException {
+ // Skip the test case on Windows because backslash will be treated as a
+ // path separator instead of an escaping character on Windows.
+ org.junit.Assume.assumeTrue(!Path.WINDOWS);
try {
String [] files = new String[] {USER_DIR+"/ab\\[c.d"};
Path[] matchedPath = prepareTesting(USER_DIR+"/ab\\[c.d", files);
@@ -618,21 +622,7 @@ public class TestGlobPaths {
cleanupDFS();
}
}
-
- @Test
- public void pTestRelativePath() throws IOException {
- try {
- String [] files = new String[] {"a", "abc", "abc.p", "bacd"};
- Path[] matchedPath = prepareTesting("a*", files);
- assertEquals(matchedPath.length, 3);
- assertEquals(matchedPath[0], new Path(USER_DIR, path[0]));
- assertEquals(matchedPath[1], new Path(USER_DIR, path[1]));
- assertEquals(matchedPath[2], new Path(USER_DIR, path[2]));
- } finally {
- cleanupDFS();
- }
- }
-
+
/* Test {xx,yy} */
@Test
public void pTestCurlyBracket() throws IOException {
@@ -783,8 +773,7 @@ public class TestGlobPaths {
return globResults;
}
- @After
- public void cleanupDFS() throws IOException {
+ private void cleanupDFS() throws IOException {
fs.delete(new Path(USER_DIR), true);
}
@@ -799,28 +788,24 @@ public class TestGlobPaths {
/**
* Run a glob test on FileSystem.
*/
- private static void testOnFileSystem(FSTestWrapperGlobTest test) throws Exception {
- Configuration conf = new HdfsConfiguration();
- MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
+ private void testOnFileSystem(FSTestWrapperGlobTest test) throws Exception {
try {
- FileSystem fs = FileSystem.get(conf);
+ fc.mkdir(new Path(USER_DIR), FsPermission.getDefault(), true);
test.run(new FileSystemTestWrapper(fs), fs, null);
} finally {
- cluster.shutdown();
+ fc.delete(new Path(USER_DIR), true);
}
}
/**
* Run a glob test on FileContext.
*/
- private static void testOnFileContext(FSTestWrapperGlobTest test) throws Exception {
- Configuration conf = new HdfsConfiguration();
- MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
+ private void testOnFileContext(FSTestWrapperGlobTest test) throws Exception {
try {
- FileContext fc = FileContext.getFileContext(conf);
+ fs.mkdirs(new Path(USER_DIR));
test.run(new FileContextTestWrapper(fc), null, fc);
} finally {
- cluster.shutdown();
+ cleanupDFS();
}
}
@@ -853,32 +838,33 @@ public class TestGlobPaths {
throws Exception {
// Test that globbing through a symlink to a directory yields a path
// containing that symlink.
- wrap.mkdir(new Path("/alpha"),
- FsPermission.getDirDefault(), false);
- wrap.createSymlink(new Path("/alpha"), new Path("/alphaLink"), false);
- wrap.mkdir(new Path("/alphaLink/beta"),
+ wrap.mkdir(new Path(USER_DIR + "/alpha"), FsPermission.getDirDefault(),
+ false);
+ wrap.createSymlink(new Path(USER_DIR + "/alpha"), new Path(USER_DIR
+ + "/alphaLink"), false);
+ wrap.mkdir(new Path(USER_DIR + "/alphaLink/beta"),
FsPermission.getDirDefault(), false);
// Test simple glob
- FileStatus[] statuses =
- wrap.globStatus(new Path("/alpha/*"), new AcceptAllPathFilter());
+ FileStatus[] statuses = wrap.globStatus(new Path(USER_DIR + "/alpha/*"),
+ new AcceptAllPathFilter());
Assert.assertEquals(1, statuses.length);
- Assert.assertEquals("/alpha/beta",
- statuses[0].getPath().toUri().getPath());
+ Assert.assertEquals(USER_DIR + "/alpha/beta", statuses[0].getPath()
+ .toUri().getPath());
// Test glob through symlink
- statuses =
- wrap.globStatus(new Path("/alphaLink/*"), new AcceptAllPathFilter());
+ statuses = wrap.globStatus(new Path(USER_DIR + "/alphaLink/*"),
+ new AcceptAllPathFilter());
Assert.assertEquals(1, statuses.length);
- Assert.assertEquals("/alphaLink/beta",
- statuses[0].getPath().toUri().getPath());
+ Assert.assertEquals(USER_DIR + "/alphaLink/beta", statuses[0].getPath()
+ .toUri().getPath());
// If the terminal path component in a globbed path is a symlink,
// we don't dereference that link.
- wrap.createSymlink(new Path("beta"), new Path("/alphaLink/betaLink"),
- false);
- statuses = wrap.globStatus(new Path("/alpha/betaLi*"),
+ wrap.createSymlink(new Path("beta"), new Path(USER_DIR
+ + "/alphaLink/betaLink"), false);
+ statuses = wrap.globStatus(new Path(USER_DIR + "/alpha/betaLi*"),
new AcceptAllPathFilter());
Assert.assertEquals(1, statuses.length);
- Assert.assertEquals("/alpha/betaLink",
- statuses[0].getPath().toUri().getPath());
+ Assert.assertEquals(USER_DIR + "/alpha/betaLink", statuses[0].getPath()
+ .toUri().getPath());
// todo: test symlink-to-symlink-to-dir, etc.
}
}
@@ -898,58 +884,64 @@ public class TestGlobPaths {
*
* Also test globbing dangling symlinks. It should NOT throw any exceptions!
*/
- private static class TestGlobWithSymlinksToSymlinks
- implements FSTestWrapperGlobTest {
+ private static class TestGlobWithSymlinksToSymlinks implements
+ FSTestWrapperGlobTest {
public void run(FSTestWrapper wrap, FileSystem fs, FileContext fc)
throws Exception {
// Test that globbing through a symlink to a symlink to a directory
// fully resolves
- wrap.mkdir(new Path("/alpha"), FsPermission.getDirDefault(), false);
- wrap.createSymlink(new Path("/alpha"), new Path("/alphaLink"), false);
- wrap.createSymlink(new Path("/alphaLink"),
- new Path("/alphaLinkLink"), false);
- wrap.mkdir(new Path("/alpha/beta"), FsPermission.getDirDefault(), false);
+ wrap.mkdir(new Path(USER_DIR + "/alpha"), FsPermission.getDirDefault(),
+ false);
+ wrap.createSymlink(new Path(USER_DIR + "/alpha"), new Path(USER_DIR
+ + "/alphaLink"), false);
+ wrap.createSymlink(new Path(USER_DIR + "/alphaLink"), new Path(USER_DIR
+ + "/alphaLinkLink"), false);
+ wrap.mkdir(new Path(USER_DIR + "/alpha/beta"),
+ FsPermission.getDirDefault(), false);
// Test glob through symlink to a symlink to a directory
- FileStatus statuses[] =
- wrap.globStatus(new Path("/alphaLinkLink"), new AcceptAllPathFilter());
+ FileStatus statuses[] = wrap.globStatus(new Path(USER_DIR
+ + "/alphaLinkLink"), new AcceptAllPathFilter());
Assert.assertEquals(1, statuses.length);
- Assert.assertEquals("/alphaLinkLink",
- statuses[0].getPath().toUri().getPath());
- statuses =
- wrap.globStatus(new Path("/alphaLinkLink/*"), new AcceptAllPathFilter());
+ Assert.assertEquals(USER_DIR + "/alphaLinkLink", statuses[0].getPath()
+ .toUri().getPath());
+ statuses = wrap.globStatus(new Path(USER_DIR + "/alphaLinkLink/*"),
+ new AcceptAllPathFilter());
Assert.assertEquals(1, statuses.length);
- Assert.assertEquals("/alphaLinkLink/beta",
- statuses[0].getPath().toUri().getPath());
+ Assert.assertEquals(USER_DIR + "/alphaLinkLink/beta", statuses[0]
+ .getPath().toUri().getPath());
// Test glob of dangling symlink (theta does not actually exist)
- wrap.createSymlink(new Path("theta"), new Path("/alpha/kappa"), false);
- statuses = wrap.globStatus(new Path("/alpha/kappa/kappa"),
- new AcceptAllPathFilter());
+ wrap.createSymlink(new Path(USER_DIR + "theta"), new Path(USER_DIR
+ + "/alpha/kappa"), false);
+ statuses = wrap.globStatus(new Path(USER_DIR + "/alpha/kappa/kappa"),
+ new AcceptAllPathFilter());
Assert.assertNull(statuses);
// Test glob of symlinks
- wrap.createFile("/alpha/beta/gamma");
- wrap.createSymlink(new Path("gamma"),
- new Path("/alpha/beta/gammaLink"), false);
- wrap.createSymlink(new Path("gammaLink"),
- new Path("/alpha/beta/gammaLinkLink"), false);
- wrap.createSymlink(new Path("gammaLinkLink"),
- new Path("/alpha/beta/gammaLinkLinkLink"), false);
- statuses = wrap.globStatus(new Path("/alpha/*/gammaLinkLinkLink"),
- new AcceptAllPathFilter());
+ wrap.createFile(USER_DIR + "/alpha/beta/gamma");
+ wrap.createSymlink(new Path(USER_DIR + "gamma"), new Path(USER_DIR
+ + "/alpha/beta/gammaLink"), false);
+ wrap.createSymlink(new Path(USER_DIR + "gammaLink"), new Path(USER_DIR
+ + "/alpha/beta/gammaLinkLink"), false);
+ wrap.createSymlink(new Path(USER_DIR + "gammaLinkLink"), new Path(
+ USER_DIR + "/alpha/beta/gammaLinkLinkLink"), false);
+ statuses = wrap.globStatus(new Path(USER_DIR
+ + "/alpha/*/gammaLinkLinkLink"), new AcceptAllPathFilter());
Assert.assertEquals(1, statuses.length);
- Assert.assertEquals("/alpha/beta/gammaLinkLinkLink",
+ Assert.assertEquals(USER_DIR + "/alpha/beta/gammaLinkLinkLink",
statuses[0].getPath().toUri().getPath());
- statuses = wrap.globStatus(new Path("/alpha/beta/*"),
- new AcceptAllPathFilter());
- Assert.assertEquals("/alpha/beta/gamma;/alpha/beta/gammaLink;" +
- "/alpha/beta/gammaLinkLink;/alpha/beta/gammaLinkLinkLink",
+ statuses = wrap.globStatus(new Path(USER_DIR + "/alpha/beta/*"),
+ new AcceptAllPathFilter());
+ Assert.assertEquals(USER_DIR + "/alpha/beta/gamma;" + USER_DIR
+ + "/alpha/beta/gammaLink;" + USER_DIR + "/alpha/beta/gammaLinkLink;"
+ + USER_DIR + "/alpha/beta/gammaLinkLinkLink",
TestPath.mergeStatuses(statuses));
// Let's create two symlinks that point to each other, and glob on them.
- wrap.createSymlink(new Path("tweedledee"),
- new Path("/tweedledum"), false);
- wrap.createSymlink(new Path("tweedledum"),
- new Path("/tweedledee"), false);
- statuses = wrap.globStatus(new Path("/tweedledee/unobtainium"),
- new AcceptAllPathFilter());
+ wrap.createSymlink(new Path(USER_DIR + "tweedledee"), new Path(USER_DIR
+ + "/tweedledum"), false);
+ wrap.createSymlink(new Path(USER_DIR + "tweedledum"), new Path(USER_DIR
+ + "/tweedledee"), false);
+ statuses = wrap.globStatus(
+ new Path(USER_DIR + "/tweedledee/unobtainium"),
+ new AcceptAllPathFilter());
Assert.assertNull(statuses);
}
}
@@ -967,34 +959,39 @@ public class TestGlobPaths {
/**
* Test globbing symlinks with a custom PathFilter
*/
- private static class TestGlobSymlinksWithCustomPathFilter
- implements FSTestWrapperGlobTest {
+ private static class TestGlobSymlinksWithCustomPathFilter implements
+ FSTestWrapperGlobTest {
public void run(FSTestWrapper wrap, FileSystem fs, FileContext fc)
throws Exception {
// Test that globbing through a symlink to a symlink to a directory
// fully resolves
- wrap.mkdir(new Path("/alpha"), FsPermission.getDirDefault(), false);
- wrap.createSymlink(new Path("/alpha"), new Path("/alphaLinkz"), false);
- wrap.mkdir(new Path("/alpha/beta"), FsPermission.getDirDefault(), false);
- wrap.mkdir(new Path("/alpha/betaz"), FsPermission.getDirDefault(), false);
- // Test glob through symlink to a symlink to a directory, with a PathFilter
- FileStatus statuses[] =
- wrap.globStatus(new Path("/alpha/beta"), new AcceptPathsEndingInZ());
+ wrap.mkdir(new Path(USER_DIR + "/alpha"), FsPermission.getDirDefault(),
+ false);
+ wrap.createSymlink(new Path(USER_DIR + "/alpha"), new Path(USER_DIR
+ + "/alphaLinkz"), false);
+ wrap.mkdir(new Path(USER_DIR + "/alpha/beta"),
+ FsPermission.getDirDefault(), false);
+ wrap.mkdir(new Path(USER_DIR + "/alpha/betaz"),
+ FsPermission.getDirDefault(), false);
+ // Test glob through symlink to a symlink to a directory, with a
+ // PathFilter
+ FileStatus statuses[] = wrap.globStatus(
+ new Path(USER_DIR + "/alpha/beta"), new AcceptPathsEndingInZ());
Assert.assertNull(statuses);
- statuses =
- wrap.globStatus(new Path("/alphaLinkz/betaz"), new AcceptPathsEndingInZ());
+ statuses = wrap.globStatus(new Path(USER_DIR + "/alphaLinkz/betaz"),
+ new AcceptPathsEndingInZ());
Assert.assertEquals(1, statuses.length);
- Assert.assertEquals("/alphaLinkz/betaz",
- statuses[0].getPath().toUri().getPath());
- statuses =
- wrap.globStatus(new Path("/*/*"), new AcceptPathsEndingInZ());
- Assert.assertEquals("/alpha/betaz;/alphaLinkz/betaz",
- TestPath.mergeStatuses(statuses));
- statuses =
- wrap.globStatus(new Path("/*/*"), new AcceptAllPathFilter());
- Assert.assertEquals("/alpha/beta;/alpha/betaz;" +
- "/alphaLinkz/beta;/alphaLinkz/betaz",
- TestPath.mergeStatuses(statuses));
+ Assert.assertEquals(USER_DIR + "/alphaLinkz/betaz", statuses[0].getPath()
+ .toUri().getPath());
+ statuses = wrap.globStatus(new Path(USER_DIR + "/*/*"),
+ new AcceptPathsEndingInZ());
+ Assert.assertEquals(USER_DIR + "/alpha/betaz;" + USER_DIR
+ + "/alphaLinkz/betaz", TestPath.mergeStatuses(statuses));
+ statuses = wrap.globStatus(new Path(USER_DIR + "/*/*"),
+ new AcceptAllPathFilter());
+ Assert.assertEquals(USER_DIR + "/alpha/beta;" + USER_DIR
+ + "/alpha/betaz;" + USER_DIR + "/alphaLinkz/beta;" + USER_DIR
+ + "/alphaLinkz/betaz", TestPath.mergeStatuses(statuses));
}
}
@@ -1011,24 +1008,25 @@ public class TestGlobPaths {
/**
* Test that globStatus fills in the scheme even when it is not provided.
*/
- private static class TestGlobFillsInScheme
- implements FSTestWrapperGlobTest {
- public void run(FSTestWrapper wrap, FileSystem fs, FileContext fc)
+ private static class TestGlobFillsInScheme implements FSTestWrapperGlobTest {
+ public void run(FSTestWrapper wrap, FileSystem fs, FileContext fc)
throws Exception {
// Verify that the default scheme is hdfs, when we don't supply one.
- wrap.mkdir(new Path("/alpha"), FsPermission.getDirDefault(), false);
- wrap.createSymlink(new Path("/alpha"), new Path("/alphaLink"), false);
- FileStatus statuses[] =
- wrap.globStatus(new Path("/alphaLink"), new AcceptAllPathFilter());
+ wrap.mkdir(new Path(USER_DIR + "/alpha"), FsPermission.getDirDefault(),
+ false);
+ wrap.createSymlink(new Path(USER_DIR + "/alpha"), new Path(USER_DIR
+ + "/alphaLink"), false);
+ FileStatus statuses[] = wrap.globStatus(
+ new Path(USER_DIR + "/alphaLink"), new AcceptAllPathFilter());
Assert.assertEquals(1, statuses.length);
Path path = statuses[0].getPath();
- Assert.assertEquals("/alphaLink", path.toUri().getPath());
+ Assert.assertEquals(USER_DIR + "/alphaLink", path.toUri().getPath());
Assert.assertEquals("hdfs", path.toUri().getScheme());
if (fc != null) {
// If we're using FileContext, then we can list a file:/// URI.
// Since everyone should have the root directory, we list that.
- statuses =
- wrap.globStatus(new Path("file:///"), new AcceptAllPathFilter());
+ statuses = wrap.globStatus(new Path("file:///"),
+ new AcceptAllPathFilter());
Assert.assertEquals(1, statuses.length);
Path filePath = statuses[0].getPath();
Assert.assertEquals("file", filePath.toUri().getScheme());
@@ -1049,4 +1047,43 @@ public class TestGlobPaths {
public void testGlobFillsInSchemeOnFC() throws Exception {
testOnFileContext(new TestGlobFillsInScheme());
}
+
+ /**
+ * Test that globStatus works with relative paths.
+ **/
+ private static class TestRelativePath implements FSTestWrapperGlobTest {
+ public void run(FSTestWrapper wrap, FileSystem fs, FileContext fc)
+ throws Exception {
+ String[] files = new String[] { "a", "abc", "abc.p", "bacd" };
+
+ Path[] path = new Path[files.length];
+ for(int i=0; i < files.length; i++) {
+ path[i] = wrap.makeQualified(new Path(files[i]));
+ wrap.mkdir(path[i], FsPermission.getDirDefault(), true);
+ }
+
+ Path patternPath = new Path("a*");
+ Path[] globResults = FileUtil.stat2Paths(wrap.globStatus(patternPath,
+ new AcceptAllPathFilter()),
+ patternPath);
+
+ for(int i=0; i < globResults.length; i++) {
+ globResults[i] = wrap.makeQualified(globResults[i]);
+ }
+
+ assertEquals(globResults.length, 3);
+ assertEquals(USER_DIR + "/a;" + USER_DIR + "/abc;" + USER_DIR + "/abc.p",
+ TestPath.mergeStatuses(globResults));
+ }
+ }
+
+ @Test
+ public void testRelativePathOnFS() throws Exception {
+ testOnFileSystem(new TestRelativePath());
+ }
+
+ @Test
+ public void testRelativePathOnFC() throws Exception {
+ testOnFileContext(new TestRelativePath());
+ }
}
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestHDFSFileContextMainOperations.java Tue Sep 3 18:30:05 2013
@@ -59,6 +59,9 @@ public class TestHDFSFileContextMainOper
defaultWorkingDirectory = fc.makeQualified( new Path("/user/" +
UserGroupInformation.getCurrentUser().getShortUserName()));
fc.mkdir(defaultWorkingDirectory, FileContext.DEFAULT_PERM, true);
+ // Make defaultWorkingDirectory snapshottable to enable
+ // testGlobStatusFilterWithHiddenPathTrivialFilter
+ cluster.getFileSystem().allowSnapshot(defaultWorkingDirectory);
}
private static void restartCluster() throws IOException, LoginException {
@@ -73,6 +76,9 @@ public class TestHDFSFileContextMainOper
defaultWorkingDirectory = fc.makeQualified( new Path("/user/" +
UserGroupInformation.getCurrentUser().getShortUserName()));
fc.mkdir(defaultWorkingDirectory, FileContext.DEFAULT_PERM, true);
+ // Make defaultWorkingDirectory snapshottable to enable
+ // testGlobStatusFilterWithHiddenPathTrivialFilter
+ cluster.getFileSystem().allowSnapshot(defaultWorkingDirectory);
}
@AfterClass
@@ -93,6 +99,11 @@ public class TestHDFSFileContextMainOper
}
@Override
+ protected Path getHiddenPathForTest() {
+ return new Path(defaultWorkingDirectory, ".snapshot");
+ }
+
+ @Override
protected Path getDefaultWorkingDirectory() {
return defaultWorkingDirectory;
}
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDatanodeBlockScanner.java Tue Sep 3 18:30:05 2013
@@ -440,7 +440,8 @@ public class TestDatanodeBlockScanner {
}
}
- private static final String BASE_PATH = "/data/current/finalized";
+ private static final String BASE_PATH = (new File("/data/current/finalized"))
+ .getAbsolutePath();
@Test
public void testReplicaInfoParsing() throws Exception {
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileAppend.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileAppend.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileAppend.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestFileAppend.java Tue Sep 3 18:30:05 2013
@@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hdfs;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -337,4 +338,47 @@ public class TestFileAppend{
cluster.shutdown();
}
}
+
+ /** Tests appending after soft-limit expires. */
+ @Test
+ public void testAppendAfterSoftLimit()
+ throws IOException, InterruptedException {
+ Configuration conf = new HdfsConfiguration();
+ conf.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, 1);
+ conf.setBoolean(DFSConfigKeys.DFS_SUPPORT_APPEND_KEY, true);
+ //Set small soft-limit for lease
+ final long softLimit = 1L;
+ final long hardLimit = 9999999L;
+
+ MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1)
+ .build();
+ cluster.setLeasePeriod(softLimit, hardLimit);
+ cluster.waitActive();
+
+ FileSystem fs = cluster.getFileSystem();
+ FileSystem fs2 = new DistributedFileSystem();
+ fs2.initialize(fs.getUri(), conf);
+
+ final Path testPath = new Path("/testAppendAfterSoftLimit");
+ final byte[] fileContents = AppendTestUtil.initBuffer(32);
+
+ // create a new file without closing
+ FSDataOutputStream out = fs.create(testPath);
+ out.write(fileContents);
+
+ //Wait for > soft-limit
+ Thread.sleep(250);
+
+ try {
+ FSDataOutputStream appendStream2 = fs2.append(testPath);
+ appendStream2.write(fileContents);
+ appendStream2.close();
+ assertEquals(fileContents.length, fs.getFileStatus(testPath).getLen());
+ } finally {
+ fs.close();
+ fs2.close();
+ cluster.shutdown();
+ }
+ }
+
}
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDirectoryScanner.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDirectoryScanner.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDirectoryScanner.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDirectoryScanner.java Tue Sep 3 18:30:05 2013
@@ -394,12 +394,12 @@ public class TestDirectoryScanner {
@Override
public String getBasePath() {
- return "/base";
+ return (new File("/base")).getAbsolutePath();
}
@Override
public String getPath(String bpid) throws IOException {
- return "/base/current/" + bpid;
+ return (new File("/base/current/" + bpid)).getAbsolutePath();
}
@Override
@@ -416,8 +416,6 @@ public class TestDirectoryScanner {
void testScanInfoObject(long blockId, File blockFile, File metaFile)
throws Exception {
- assertEquals("/base/current/" + BPID_1 + "/finalized",
- TEST_VOLUME.getFinalizedDir(BPID_1).getAbsolutePath());
DirectoryScanner.ScanInfo scanInfo =
new DirectoryScanner.ScanInfo(blockId, blockFile, metaFile, TEST_VOLUME);
assertEquals(blockId, scanInfo.getBlockId());
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSImageTestUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSImageTestUtil.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSImageTestUtil.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/FSImageTestUtil.java Tue Sep 3 18:30:05 2013
@@ -62,6 +62,7 @@ import org.mockito.Mockito;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -548,4 +549,16 @@ public abstract class FSImageTestUtil {
public static FSImage getFSImage(NameNode node) {
return node.getFSImage();
}
+
+ public static void assertNNFilesMatch(MiniDFSCluster cluster) throws Exception {
+ List<File> curDirs = Lists.newArrayList();
+ curDirs.addAll(FSImageTestUtil.getNameNodeCurrentDirs(cluster, 0));
+ curDirs.addAll(FSImageTestUtil.getNameNodeCurrentDirs(cluster, 1));
+
+ // Ignore seen_txid file, since the newly bootstrapped standby
+ // will have a higher seen_txid than the one it bootstrapped from.
+ Set<String> ignoredFiles = ImmutableSet.of("seen_txid");
+ FSImageTestUtil.assertParallelFilesAreIdentical(curDirs,
+ ignoredFiles);
+ }
}
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/NNThroughputBenchmark.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/NNThroughputBenchmark.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/NNThroughputBenchmark.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/NNThroughputBenchmark.java Tue Sep 3 18:30:05 2013
@@ -61,6 +61,8 @@ import org.apache.hadoop.net.NetworkTopo
import org.apache.hadoop.security.Groups;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.util.Time;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
import org.apache.hadoop.util.VersionInfo;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
@@ -100,7 +102,7 @@ import org.apache.log4j.LogManager;
* Then the benchmark executes the specified number of operations using
* the specified number of threads and outputs the resulting stats.
*/
-public class NNThroughputBenchmark {
+public class NNThroughputBenchmark implements Tool {
private static final Log LOG = LogFactory.getLog(NNThroughputBenchmark.class);
private static final int BLOCK_SIZE = 16;
private static final String GENERAL_OPTIONS_USAGE =
@@ -115,6 +117,8 @@ public class NNThroughputBenchmark {
// We do not need many handlers, since each thread simulates a handler
// by calling name-node methods directly
config.setInt(DFSConfigKeys.DFS_DATANODE_HANDLER_COUNT_KEY, 1);
+ // Turn off minimum block size verification
+ config.setInt(DFSConfigKeys.DFS_NAMENODE_MIN_BLOCK_SIZE_KEY, 0);
// set exclude file
config.set(DFSConfigKeys.DFS_HOSTS_EXCLUDE,
"${hadoop.tmp.dir}/dfs/hosts/exclude");
@@ -129,14 +133,11 @@ public class NNThroughputBenchmark {
config.set(DFSConfigKeys.DFS_HOSTS, "${hadoop.tmp.dir}/dfs/hosts/include");
File includeFile = new File(config.get(DFSConfigKeys.DFS_HOSTS, "include"));
new FileOutputStream(includeFile).close();
- // Start the NameNode
- String[] argv = new String[] {};
- nameNode = NameNode.createNameNode(argv, config);
- nameNodeProto = nameNode.getRpcServer();
}
void close() {
- nameNode.stop();
+ if(nameNode != null)
+ nameNode.stop();
}
static void setNameNodeLoggingLevel(Level logLevel) {
@@ -1290,52 +1291,69 @@ public class NNThroughputBenchmark {
System.exit(-1);
}
+ public static void runBenchmark(Configuration conf, List<String> args)
+ throws Exception {
+ NNThroughputBenchmark bench = null;
+ try {
+ bench = new NNThroughputBenchmark(conf);
+ bench.run(args.toArray(new String[]{}));
+ } finally {
+ if(bench != null)
+ bench.close();
+ }
+ }
+
/**
* Main method of the benchmark.
* @param args command line parameters
*/
- public static void runBenchmark(Configuration conf, List<String> args) throws Exception {
+ @Override // Tool
+ public int run(String[] aArgs) throws Exception {
+ List<String> args = new ArrayList<String>(Arrays.asList(aArgs));
if(args.size() < 2 || ! args.get(0).startsWith("-op"))
printUsage();
String type = args.get(1);
boolean runAll = OperationStatsBase.OP_ALL_NAME.equals(type);
- NNThroughputBenchmark bench = null;
+ // Start the NameNode
+ String[] argv = new String[] {};
+ nameNode = NameNode.createNameNode(argv, config);
+ nameNodeProto = nameNode.getRpcServer();
+
List<OperationStatsBase> ops = new ArrayList<OperationStatsBase>();
OperationStatsBase opStat = null;
try {
- bench = new NNThroughputBenchmark(conf);
if(runAll || CreateFileStats.OP_CREATE_NAME.equals(type)) {
- opStat = bench.new CreateFileStats(args);
+ opStat = new CreateFileStats(args);
ops.add(opStat);
}
if(runAll || OpenFileStats.OP_OPEN_NAME.equals(type)) {
- opStat = bench.new OpenFileStats(args);
+ opStat = new OpenFileStats(args);
ops.add(opStat);
}
if(runAll || DeleteFileStats.OP_DELETE_NAME.equals(type)) {
- opStat = bench.new DeleteFileStats(args);
+ opStat = new DeleteFileStats(args);
ops.add(opStat);
}
if(runAll || FileStatusStats.OP_FILE_STATUS_NAME.equals(type)) {
- opStat = bench.new FileStatusStats(args);
+ opStat = new FileStatusStats(args);
ops.add(opStat);
}
if(runAll || RenameFileStats.OP_RENAME_NAME.equals(type)) {
- opStat = bench.new RenameFileStats(args);
+ opStat = new RenameFileStats(args);
ops.add(opStat);
}
if(runAll || BlockReportStats.OP_BLOCK_REPORT_NAME.equals(type)) {
- opStat = bench.new BlockReportStats(args);
+ opStat = new BlockReportStats(args);
ops.add(opStat);
}
if(runAll || ReplicationStats.OP_REPLICATION_NAME.equals(type)) {
- opStat = bench.new ReplicationStats(args);
+ opStat = new ReplicationStats(args);
ops.add(opStat);
}
if(runAll || CleanAllStats.OP_CLEAN_NAME.equals(type)) {
- opStat = bench.new CleanAllStats(args);
+ opStat = new CleanAllStats(args);
ops.add(opStat);
}
if(ops.size() == 0)
@@ -1354,14 +1372,28 @@ public class NNThroughputBenchmark {
} catch(Exception e) {
LOG.error(StringUtils.stringifyException(e));
throw e;
+ }
+ return 0;
+ }
+
+ public static void main(String[] args) throws Exception {
+ NNThroughputBenchmark bench = null;
+ try {
+ bench = new NNThroughputBenchmark(new HdfsConfiguration());
+ ToolRunner.run(bench, args);
} finally {
if(bench != null)
bench.close();
}
}
- public static void main(String[] args) throws Exception {
- runBenchmark(new HdfsConfiguration(),
- new ArrayList<String>(Arrays.asList(args)));
+ @Override // Configurable
+ public void setConf(Configuration conf) {
+ config = conf;
+ }
+
+ @Override // Configurable
+ public Configuration getConf() {
+ return config;
}
}
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCommitBlockSynchronization.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCommitBlockSynchronization.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCommitBlockSynchronization.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestCommitBlockSynchronization.java Tue Sep 3 18:30:05 2013
@@ -169,4 +169,23 @@ public class TestCommitBlockSynchronizat
namesystemSpy.commitBlockSynchronization(
lastBlock, genStamp, length, true, false, newTargets, null);
}
+
+ @Test
+ public void testCommitBlockSynchronizationWithCloseAndNonExistantTarget()
+ throws IOException {
+ INodeFileUnderConstruction file = mock(INodeFileUnderConstruction.class);
+ Block block = new Block(blockId, length, genStamp);
+ FSNamesystem namesystemSpy = makeNameSystemSpy(block, file);
+ DatanodeID[] newTargets = new DatanodeID[]{
+ new DatanodeID("0.0.0.0", "nonexistantHost", "1", 0, 0, 0)};
+
+ ExtendedBlock lastBlock = new ExtendedBlock();
+ namesystemSpy.commitBlockSynchronization(
+ lastBlock, genStamp, length, true,
+ false, newTargets, null);
+
+ // Repeat the call to make sure it returns true
+ namesystemSpy.commitBlockSynchronization(
+ lastBlock, genStamp, length, true, false, newTargets, null);
+ }
}
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogFileInputStream.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogFileInputStream.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogFileInputStream.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestEditLogFileInputStream.java Tue Sep 3 18:30:05 2013
@@ -41,7 +41,8 @@ public class TestEditLogFileInputStream
@Test
public void testReadURL() throws Exception {
// Start a simple web server which hosts the log data.
- HttpServer server = new HttpServer("test", "0.0.0.0", 0, true);
+ HttpServer server = new HttpServer.Builder().setName("test")
+ .setBindAddress("0.0.0.0").setPort(0).setFindPort(true).build();
server.start();
try {
server.addServlet("fakeLog", "/fakeLog", FakeLogServlet.class);
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileJournalManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileJournalManager.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileJournalManager.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFileJournalManager.java Tue Sep 3 18:30:05 2013
@@ -480,6 +480,6 @@ public class TestFileJournalManager {
private static String getLogsAsString(
FileJournalManager fjm, long firstTxId) throws IOException {
- return Joiner.on(",").join(fjm.getRemoteEditLogs(firstTxId, true));
+ return Joiner.on(",").join(fjm.getRemoteEditLogs(firstTxId, true, false));
}
}
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFsck.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFsck.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFsck.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFsck.java Tue Sep 3 18:30:05 2013
@@ -153,8 +153,8 @@ public class TestFsck {
String outStr = runFsck(conf, 0, true, "/");
verifyAuditLogs();
assertEquals(aTime, fs.getFileStatus(file).getAccessTime());
- assertTrue(outStr.contains(NamenodeFsck.HEALTHY_STATUS));
System.out.println(outStr);
+ assertTrue(outStr.contains(NamenodeFsck.HEALTHY_STATUS));
if (fs != null) {try{fs.close();} catch(Exception e){}}
cluster.shutdown();
@@ -194,18 +194,30 @@ public class TestFsck {
// Turn off the logs
Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger();
logger.setLevel(Level.OFF);
-
- // Audit log should contain one getfileinfo and one fsck
- BufferedReader reader = new BufferedReader(new FileReader(auditLogFile));
- String line = reader.readLine();
- assertNotNull(line);
- assertTrue("Expected getfileinfo event not found in audit log",
- getfileinfoPattern.matcher(line).matches());
- line = reader.readLine();
- assertNotNull(line);
- assertTrue("Expected fsck event not found in audit log",
- fsckPattern.matcher(line).matches());
- assertNull("Unexpected event in audit log", reader.readLine());
+
+ BufferedReader reader = null;
+ try {
+ // Audit log should contain one getfileinfo and one fsck
+ reader = new BufferedReader(new FileReader(auditLogFile));
+ String line = reader.readLine();
+ assertNotNull(line);
+ assertTrue("Expected getfileinfo event not found in audit log",
+ getfileinfoPattern.matcher(line).matches());
+ line = reader.readLine();
+ assertNotNull(line);
+ assertTrue("Expected fsck event not found in audit log", fsckPattern
+ .matcher(line).matches());
+ assertNull("Unexpected event in audit log", reader.readLine());
+ } finally {
+ // Close the reader and remove the appender to release the audit log file
+ // handle after verifying the content of the file.
+ if (reader != null) {
+ reader.close();
+ }
+ if (logger != null) {
+ logger.removeAllAppenders();
+ }
+ }
}
@Test
@@ -963,9 +975,9 @@ public class TestFsck {
String outStr = runFsck(conf, 0, true, "/");
verifyAuditLogs();
assertEquals(aTime, fc.getFileStatus(symlink).getAccessTime());
- assertTrue(outStr.contains(NamenodeFsck.HEALTHY_STATUS));
- assertTrue(outStr.contains("Total symlinks:\t\t1\n"));
System.out.println(outStr);
+ assertTrue(outStr.contains(NamenodeFsck.HEALTHY_STATUS));
+ assertTrue(outStr.contains("Total symlinks:\t\t1"));
util.cleanup(fs, fileName);
} finally {
if (fs != null) {try{fs.close();} catch(Exception e){}}
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestINodeFile.java Tue Sep 3 18:30:05 2013
@@ -44,6 +44,7 @@ import org.apache.hadoop.fs.PathIsNotDir
import org.apache.hadoop.fs.RemoteIterator;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.permission.PermissionStatus;
+import org.apache.hadoop.hdfs.DFSClient;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.DFSTestUtil;
import org.apache.hadoop.hdfs.DFSUtil;
@@ -892,4 +893,34 @@ public class TestINodeFile {
assertTrue(e instanceof FileNotFoundException);
}
}
+
+ @Test
+ public void testDotdotInodePath() throws Exception {
+ final Configuration conf = new Configuration();
+ MiniDFSCluster cluster = null;
+ try {
+ cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
+ cluster.waitActive();
+ final DistributedFileSystem hdfs = cluster.getFileSystem();
+ final FSDirectory fsdir = cluster.getNamesystem().getFSDirectory();
+
+ final Path dir = new Path("/dir");
+ hdfs.mkdirs(dir);
+ long dirId = fsdir.getINode(dir.toString()).getId();
+ long parentId = fsdir.getINode("/").getId();
+ String testPath = "/.reserved/.inodes/" + dirId + "/..";
+
+ DFSClient client = new DFSClient(NameNode.getAddress(conf), conf);
+ HdfsFileStatus status = client.getFileInfo(testPath);
+ assertTrue(parentId == status.getFileId());
+
+ // Test root's parent is still root
+ testPath = "/.reserved/.inodes/" + parentId + "/..";
+ status = client.getFileInfo(testPath);
+ assertTrue(parentId == status.getFileId());
+
+ } finally {
+ cluster.shutdown();
+ }
+ }
}
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java Tue Sep 3 18:30:05 2013
@@ -120,6 +120,11 @@ public class TestNameNodeMXBean {
String nameJournalStatus = (String) (mbs.getAttribute(mxbeanName,
"NameJournalStatus"));
assertEquals("Bad value for NameJournalStatus", fsn.getNameJournalStatus(), nameJournalStatus);
+ // get attribute JournalTransactionInfo
+ String journalTxnInfo = (String) mbs.getAttribute(mxbeanName,
+ "JournalTransactionInfo");
+ assertEquals("Bad value for NameTxnIds", fsn.getJournalTransactionInfo(),
+ journalTxnInfo);
// get attribute "NNStarted"
String nnStarted = (String) mbs.getAttribute(mxbeanName, "NNStarted");
assertEquals("Bad value for NNStarted", fsn.getNNStarted(), nnStarted);
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNamenodeRetryCache.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNamenodeRetryCache.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNamenodeRetryCache.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNamenodeRetryCache.java Tue Sep 3 18:30:05 2013
@@ -96,7 +96,7 @@ public class TestNamenodeRetryCache {
* @throws AccessControlException */
@After
public void cleanup() throws IOException {
- namesystem.delete("/", true);
+ cluster.shutdown();
}
public static void incrementCallId() {
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestBootstrapStandby.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestBootstrapStandby.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestBootstrapStandby.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestBootstrapStandby.java Tue Sep 3 18:30:05 2013
@@ -24,8 +24,6 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.net.URI;
-import java.util.List;
-import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -45,8 +43,6 @@ import org.junit.Before;
import org.junit.Test;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
public class TestBootstrapStandby {
private static final Log LOG = LogFactory.getLog(TestBootstrapStandby.class);
@@ -107,7 +103,7 @@ public class TestBootstrapStandby {
// Should have copied over the namespace from the active
FSImageTestUtil.assertNNHasCheckpoints(cluster, 1,
ImmutableList.of(0));
- assertNNFilesMatch();
+ FSImageTestUtil.assertNNFilesMatch(cluster);
// We should now be able to start the standby successfully.
cluster.restartNameNode(1);
@@ -138,7 +134,7 @@ public class TestBootstrapStandby {
// Should have copied over the namespace from the active
FSImageTestUtil.assertNNHasCheckpoints(cluster, 1,
ImmutableList.of((int)expectedCheckpointTxId));
- assertNNFilesMatch();
+ FSImageTestUtil.assertNNFilesMatch(cluster);
// We should now be able to start the standby successfully.
cluster.restartNameNode(1);
@@ -208,18 +204,6 @@ public class TestBootstrapStandby {
cluster.getConfiguration(1));
assertEquals(0, rc);
}
-
- private void assertNNFilesMatch() throws Exception {
- List<File> curDirs = Lists.newArrayList();
- curDirs.addAll(FSImageTestUtil.getNameNodeCurrentDirs(cluster, 0));
- curDirs.addAll(FSImageTestUtil.getNameNodeCurrentDirs(cluster, 1));
-
- // Ignore seen_txid file, since the newly bootstrapped standby
- // will have a higher seen_txid than the one it bootstrapped from.
- Set<String> ignoredFiles = ImmutableSet.of("seen_txid");
- FSImageTestUtil.assertParallelFilesAreIdentical(curDirs,
- ignoredFiles);
- }
private void removeStandbyNameDirs() {
for (URI u : cluster.getNameDirs(1)) {
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRetryCacheWithHA.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRetryCacheWithHA.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRetryCacheWithHA.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRetryCacheWithHA.java Tue Sep 3 18:30:05 2013
@@ -26,15 +26,22 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URI;
import java.net.UnknownHostException;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.CreateFlag;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.Options.Rename;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.hdfs.DFSClient;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.DFSTestUtil;
@@ -43,9 +50,20 @@ import org.apache.hadoop.hdfs.HdfsConfig
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.MiniDFSNNTopology;
import org.apache.hadoop.hdfs.NameNodeProxies;
+import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
+import org.apache.hadoop.hdfs.client.HdfsDataOutputStream.SyncFlag;
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
-import org.apache.hadoop.hdfs.protocol.HdfsConstants;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
+import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
+import org.apache.hadoop.hdfs.protocol.LocatedBlock;
+import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
+import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction;
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
+import org.apache.hadoop.hdfs.server.namenode.INodeFile;
+import org.apache.hadoop.hdfs.server.namenode.INodeFileUnderConstruction;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotTestHelper;
+import org.apache.hadoop.io.EnumSetWritable;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.io.retry.FailoverProxyProvider;
import org.apache.hadoop.io.retry.RetryInvocationHandler;
@@ -60,14 +78,13 @@ import org.junit.Test;
public class TestRetryCacheWithHA {
private static final Log LOG = LogFactory.getLog(TestRetryCacheWithHA.class);
- private static MiniDFSCluster cluster;
- private static DistributedFileSystem dfs;
- private static Configuration conf = new HdfsConfiguration();
-
private static final int BlockSize = 1024;
private static final short DataNodes = 3;
- private final static Map<String, Object> results =
- new HashMap<String, Object>();
+ private static final int CHECKTIMES = 10;
+
+ private MiniDFSCluster cluster;
+ private DistributedFileSystem dfs;
+ private Configuration conf = new HdfsConfiguration();
/**
* A dummy invocation handler extending RetryInvocationHandler. We can use
@@ -120,7 +137,7 @@ public class TestRetryCacheWithHA {
* 2. Trigger the NN failover
* 3. Check the retry cache on the original standby NN
*/
- @Test
+ @Test (timeout=60000)
public void testRetryCacheOnStandbyNN() throws Exception {
// 1. run operations
DFSTestUtil.runOperations(cluster, dfs, conf, BlockSize, 0);
@@ -180,26 +197,624 @@ public class TestRetryCacheWithHA {
return client;
}
+ abstract class AtMostOnceOp {
+ private final String name;
+ final DFSClient client;
+
+ AtMostOnceOp(String name, DFSClient client) {
+ this.name = name;
+ this.client = client;
+ }
+
+ abstract void prepare() throws Exception;
+ abstract void invoke() throws Exception;
+ abstract boolean checkNamenodeBeforeReturn() throws Exception;
+ abstract Object getResult();
+ }
+
+ /** createSnapshot operaiton */
+ class CreateSnapshotOp extends AtMostOnceOp {
+ private String snapshotPath;
+ private String dir;
+ private String snapshotName;
+
+ CreateSnapshotOp(DFSClient client, String dir, String snapshotName) {
+ super("createSnapshot", client);
+ this.dir = dir;
+ this.snapshotName = snapshotName;
+ }
+
+ @Override
+ void prepare() throws Exception {
+ final Path dirPath = new Path(dir);
+ if (!dfs.exists(dirPath)) {
+ dfs.mkdirs(dirPath);
+ dfs.allowSnapshot(dirPath);
+ }
+ }
+
+ @Override
+ void invoke() throws Exception {
+ this.snapshotPath = client.createSnapshot(dir, snapshotName);
+ }
+
+ @Override
+ boolean checkNamenodeBeforeReturn() throws Exception {
+ final Path sPath = SnapshotTestHelper.getSnapshotRoot(new Path(dir),
+ snapshotName);
+ boolean snapshotCreated = dfs.exists(sPath);
+ for (int i = 0; i < CHECKTIMES && !snapshotCreated; i++) {
+ Thread.sleep(1000);
+ snapshotCreated = dfs.exists(sPath);
+ }
+ return snapshotCreated;
+ }
+
+ @Override
+ Object getResult() {
+ return snapshotPath;
+ }
+ }
+
+ /** deleteSnapshot */
+ class DeleteSnapshotOp extends AtMostOnceOp {
+ private String dir;
+ private String snapshotName;
+
+ DeleteSnapshotOp(DFSClient client, String dir, String snapshotName) {
+ super("deleteSnapshot", client);
+ this.dir = dir;
+ this.snapshotName = snapshotName;
+ }
+
+ @Override
+ void prepare() throws Exception {
+ final Path dirPath = new Path(dir);
+ if (!dfs.exists(dirPath)) {
+ dfs.mkdirs(dirPath);
+ }
+
+ Path sPath = SnapshotTestHelper.getSnapshotRoot(dirPath, snapshotName);
+ if (!dfs.exists(sPath)) {
+ dfs.allowSnapshot(dirPath);
+ dfs.createSnapshot(dirPath, snapshotName);
+ }
+ }
+
+ @Override
+ void invoke() throws Exception {
+ client.deleteSnapshot(dir, snapshotName);
+ }
+
+ @Override
+ boolean checkNamenodeBeforeReturn() throws Exception {
+ final Path sPath = SnapshotTestHelper.getSnapshotRoot(new Path(dir),
+ snapshotName);
+ boolean snapshotNotDeleted = dfs.exists(sPath);
+ for (int i = 0; i < CHECKTIMES && snapshotNotDeleted; i++) {
+ Thread.sleep(1000);
+ snapshotNotDeleted = dfs.exists(sPath);
+ }
+ return !snapshotNotDeleted;
+ }
+
+ @Override
+ Object getResult() {
+ return null;
+ }
+ }
+
+ /** renameSnapshot */
+ class RenameSnapshotOp extends AtMostOnceOp {
+ private String dir;
+ private String oldName;
+ private String newName;
+
+ RenameSnapshotOp(DFSClient client, String dir, String oldName,
+ String newName) {
+ super("renameSnapshot", client);
+ this.dir = dir;
+ this.oldName = oldName;
+ this.newName = newName;
+ }
+
+ @Override
+ void prepare() throws Exception {
+ final Path dirPath = new Path(dir);
+ if (!dfs.exists(dirPath)) {
+ dfs.mkdirs(dirPath);
+ }
+
+ Path sPath = SnapshotTestHelper.getSnapshotRoot(dirPath, oldName);
+ if (!dfs.exists(sPath)) {
+ dfs.allowSnapshot(dirPath);
+ dfs.createSnapshot(dirPath, oldName);
+ }
+ }
+
+ @Override
+ void invoke() throws Exception {
+ client.renameSnapshot(dir, oldName, newName);
+ }
+
+ @Override
+ boolean checkNamenodeBeforeReturn() throws Exception {
+ final Path sPath = SnapshotTestHelper.getSnapshotRoot(new Path(dir),
+ newName);
+ boolean snapshotRenamed = dfs.exists(sPath);
+ for (int i = 0; i < CHECKTIMES && !snapshotRenamed; i++) {
+ Thread.sleep(1000);
+ snapshotRenamed = dfs.exists(sPath);
+ }
+ return snapshotRenamed;
+ }
+
+ @Override
+ Object getResult() {
+ return null;
+ }
+ }
+
+ /** create file operation (without OverWrite) */
+ class CreateOp extends AtMostOnceOp {
+ private String fileName;
+ private HdfsFileStatus status;
+
+ CreateOp(DFSClient client, String fileName) {
+ super("create", client);
+ this.fileName = fileName;
+ }
+
+ @Override
+ void prepare() throws Exception {
+ final Path filePath = new Path(fileName);
+ if (dfs.exists(filePath)) {
+ dfs.delete(filePath, true);
+ }
+ final Path fileParent = filePath.getParent();
+ if (!dfs.exists(fileParent)) {
+ dfs.mkdirs(fileParent);
+ }
+ }
+
+ @Override
+ void invoke() throws Exception {
+ EnumSet<CreateFlag> createFlag = EnumSet.of(CreateFlag.CREATE);
+ this.status = client.getNamenode().create(fileName,
+ FsPermission.getFileDefault(), client.getClientName(),
+ new EnumSetWritable<CreateFlag>(createFlag), false, DataNodes,
+ BlockSize);
+ }
+
+ @Override
+ boolean checkNamenodeBeforeReturn() throws Exception {
+ final Path filePath = new Path(fileName);
+ boolean fileCreated = dfs.exists(filePath);
+ for (int i = 0; i < CHECKTIMES && !fileCreated; i++) {
+ Thread.sleep(1000);
+ fileCreated = dfs.exists(filePath);
+ }
+ return fileCreated;
+ }
+
+ @Override
+ Object getResult() {
+ return status;
+ }
+ }
+
+ /** append operation */
+ class AppendOp extends AtMostOnceOp {
+ private String fileName;
+ private LocatedBlock lbk;
+
+ AppendOp(DFSClient client, String fileName) {
+ super("append", client);
+ this.fileName = fileName;
+ }
+
+ @Override
+ void prepare() throws Exception {
+ final Path filePath = new Path(fileName);
+ if (!dfs.exists(filePath)) {
+ DFSTestUtil.createFile(dfs, filePath, BlockSize / 2, DataNodes, 0);
+ }
+ }
+
+ @Override
+ void invoke() throws Exception {
+ lbk = client.getNamenode().append(fileName, client.getClientName());
+ }
+
+ // check if the inode of the file is under construction
+ @Override
+ boolean checkNamenodeBeforeReturn() throws Exception {
+ INodeFile fileNode = cluster.getNameNode(0).getNamesystem()
+ .getFSDirectory().getINode4Write(fileName).asFile();
+ boolean fileIsUC = fileNode.isUnderConstruction();
+ for (int i = 0; i < CHECKTIMES && !fileIsUC; i++) {
+ Thread.sleep(1000);
+ fileNode = cluster.getNameNode(0).getNamesystem().getFSDirectory()
+ .getINode4Write(fileName).asFile();
+ fileIsUC = fileNode.isUnderConstruction();
+ }
+ return fileIsUC;
+ }
+
+ @Override
+ Object getResult() {
+ return lbk;
+ }
+ }
+
+ /** rename */
+ class RenameOp extends AtMostOnceOp {
+ private String oldName;
+ private String newName;
+ private boolean renamed;
+
+ RenameOp(DFSClient client, String oldName, String newName) {
+ super("rename", client);
+ this.oldName = oldName;
+ this.newName = newName;
+ }
+
+ @Override
+ void prepare() throws Exception {
+ final Path filePath = new Path(oldName);
+ if (!dfs.exists(filePath)) {
+ DFSTestUtil.createFile(dfs, filePath, BlockSize, DataNodes, 0);
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ void invoke() throws Exception {
+ this.renamed = client.rename(oldName, newName);
+ }
+
+ @Override
+ boolean checkNamenodeBeforeReturn() throws Exception {
+ Path targetPath = new Path(newName);
+ boolean renamed = dfs.exists(targetPath);
+ for (int i = 0; i < CHECKTIMES && !renamed; i++) {
+ Thread.sleep(1000);
+ renamed = dfs.exists(targetPath);
+ }
+ return renamed;
+ }
+
+ @Override
+ Object getResult() {
+ return new Boolean(renamed);
+ }
+ }
+
+ /** rename2 */
+ class Rename2Op extends AtMostOnceOp {
+ private String oldName;
+ private String newName;
+
+ Rename2Op(DFSClient client, String oldName, String newName) {
+ super("rename2", client);
+ this.oldName = oldName;
+ this.newName = newName;
+ }
+
+ @Override
+ void prepare() throws Exception {
+ final Path filePath = new Path(oldName);
+ if (!dfs.exists(filePath)) {
+ DFSTestUtil.createFile(dfs, filePath, BlockSize, DataNodes, 0);
+ }
+ }
+
+ @Override
+ void invoke() throws Exception {
+ client.rename(oldName, newName, Rename.OVERWRITE);
+ }
+
+ @Override
+ boolean checkNamenodeBeforeReturn() throws Exception {
+ Path targetPath = new Path(newName);
+ boolean renamed = dfs.exists(targetPath);
+ for (int i = 0; i < CHECKTIMES && !renamed; i++) {
+ Thread.sleep(1000);
+ renamed = dfs.exists(targetPath);
+ }
+ return renamed;
+ }
+
+ @Override
+ Object getResult() {
+ return null;
+ }
+ }
+
+ /** concat */
+ class ConcatOp extends AtMostOnceOp {
+ private String target;
+ private String[] srcs;
+ private Path[] srcPaths;
+
+ ConcatOp(DFSClient client, Path target, int numSrc) {
+ super("concat", client);
+ this.target = target.toString();
+ this.srcs = new String[numSrc];
+ this.srcPaths = new Path[numSrc];
+ Path parent = target.getParent();
+ for (int i = 0; i < numSrc; i++) {
+ srcPaths[i] = new Path(parent, "srcfile" + i);
+ srcs[i] = srcPaths[i].toString();
+ }
+ }
+
+ @Override
+ void prepare() throws Exception {
+ DFSTestUtil.createFile(dfs, new Path(target), BlockSize, DataNodes, 0);
+ for (int i = 0; i < srcPaths.length; i++) {
+ DFSTestUtil.createFile(dfs, srcPaths[i], BlockSize, DataNodes, 0);
+ }
+ }
+
+ @Override
+ void invoke() throws Exception {
+ client.concat(target, srcs);
+ }
+
+ @Override
+ boolean checkNamenodeBeforeReturn() throws Exception {
+ Path targetPath = new Path(target);
+ boolean done = dfs.exists(targetPath);
+ for (int i = 0; i < CHECKTIMES && !done; i++) {
+ Thread.sleep(1000);
+ done = dfs.exists(targetPath);
+ }
+ return done;
+ }
+
+ @Override
+ Object getResult() {
+ return null;
+ }
+ }
+
+ /** delete */
+ class DeleteOp extends AtMostOnceOp {
+ private String target;
+ private boolean deleted;
+
+ DeleteOp(DFSClient client, String target) {
+ super("delete", client);
+ this.target = target;
+ }
+
+ @Override
+ void prepare() throws Exception {
+ Path p = new Path(target);
+ if (!dfs.exists(p)) {
+ DFSTestUtil.createFile(dfs, p, BlockSize, DataNodes, 0);
+ }
+ }
+
+ @Override
+ void invoke() throws Exception {
+ deleted = client.delete(target, true);
+ }
+
+ @Override
+ boolean checkNamenodeBeforeReturn() throws Exception {
+ Path targetPath = new Path(target);
+ boolean del = !dfs.exists(targetPath);
+ for (int i = 0; i < CHECKTIMES && !del; i++) {
+ Thread.sleep(1000);
+ del = !dfs.exists(targetPath);
+ }
+ return del;
+ }
+
+ @Override
+ Object getResult() {
+ return new Boolean(deleted);
+ }
+ }
+
+ /** createSymlink */
+ class CreateSymlinkOp extends AtMostOnceOp {
+ private String target;
+ private String link;
+
+ public CreateSymlinkOp(DFSClient client, String target, String link) {
+ super("createSymlink", client);
+ this.target = target;
+ this.link = link;
+ }
+
+ @Override
+ void prepare() throws Exception {
+ Path p = new Path(target);
+ if (!dfs.exists(p)) {
+ DFSTestUtil.createFile(dfs, p, BlockSize, DataNodes, 0);
+ }
+ }
+
+ @Override
+ void invoke() throws Exception {
+ client.createSymlink(target, link, false);
+ }
+
+ @Override
+ boolean checkNamenodeBeforeReturn() throws Exception {
+ Path linkPath = new Path(link);
+ FileStatus linkStatus = dfs.getFileLinkStatus(linkPath);
+ for (int i = 0; i < CHECKTIMES && linkStatus == null; i++) {
+ Thread.sleep(1000);
+ linkStatus = dfs.getFileLinkStatus(linkPath);
+ }
+ return linkStatus != null;
+ }
+
+ @Override
+ Object getResult() {
+ return null;
+ }
+ }
+
+ /** updatePipeline */
+ class UpdatePipelineOp extends AtMostOnceOp {
+ private String file;
+ private ExtendedBlock oldBlock;
+ private ExtendedBlock newBlock;
+ private DatanodeInfo[] nodes;
+ private FSDataOutputStream out;
+
+ public UpdatePipelineOp(DFSClient client, String file) {
+ super("updatePipeline", client);
+ this.file = file;
+ }
+
+ @Override
+ void prepare() throws Exception {
+ final Path filePath = new Path(file);
+ DFSTestUtil.createFile(dfs, filePath, BlockSize, DataNodes, 0);
+ // append to the file and leave the last block under construction
+ out = this.client.append(file, BlockSize, null, null);
+ byte[] appendContent = new byte[100];
+ new Random().nextBytes(appendContent);
+ out.write(appendContent);
+ ((HdfsDataOutputStream) out).hsync(EnumSet.of(SyncFlag.UPDATE_LENGTH));
+
+ LocatedBlocks blks = dfs.getClient()
+ .getLocatedBlocks(file, BlockSize + 1);
+ assertEquals(1, blks.getLocatedBlocks().size());
+ nodes = blks.get(0).getLocations();
+ oldBlock = blks.get(0).getBlock();
+
+ LocatedBlock newLbk = client.getNamenode().updateBlockForPipeline(
+ oldBlock, client.getClientName());
+ newBlock = new ExtendedBlock(oldBlock.getBlockPoolId(),
+ oldBlock.getBlockId(), oldBlock.getNumBytes(),
+ newLbk.getBlock().getGenerationStamp());
+ }
+
+ @Override
+ void invoke() throws Exception {
+ DatanodeInfo[] newNodes = new DatanodeInfo[2];
+ newNodes[0] = nodes[0];
+ newNodes[1] = nodes[1];
+
+ client.getNamenode().updatePipeline(client.getClientName(), oldBlock,
+ newBlock, newNodes);
+ out.close();
+ }
+
+ @Override
+ boolean checkNamenodeBeforeReturn() throws Exception {
+ INodeFileUnderConstruction fileNode = (INodeFileUnderConstruction) cluster
+ .getNamesystem(0).getFSDirectory().getINode4Write(file).asFile();
+ BlockInfoUnderConstruction blkUC =
+ (BlockInfoUnderConstruction) (fileNode.getBlocks())[1];
+ int datanodeNum = blkUC.getExpectedLocations().length;
+ for (int i = 0; i < CHECKTIMES && datanodeNum != 2; i++) {
+ Thread.sleep(1000);
+ datanodeNum = blkUC.getExpectedLocations().length;
+ }
+ return datanodeNum == 2;
+ }
+
+ @Override
+ Object getResult() {
+ return null;
+ }
+ }
+
+ @Test (timeout=60000)
+ public void testCreateSnapshot() throws Exception {
+ final DFSClient client = genClientWithDummyHandler();
+ AtMostOnceOp op = new CreateSnapshotOp(client, "/test", "s1");
+ testClientRetryWithFailover(op);
+ }
+
+ @Test (timeout=60000)
+ public void testDeleteSnapshot() throws Exception {
+ final DFSClient client = genClientWithDummyHandler();
+ AtMostOnceOp op = new DeleteSnapshotOp(client, "/test", "s1");
+ testClientRetryWithFailover(op);
+ }
+
+ @Test (timeout=60000)
+ public void testRenameSnapshot() throws Exception {
+ final DFSClient client = genClientWithDummyHandler();
+ AtMostOnceOp op = new RenameSnapshotOp(client, "/test", "s1", "s2");
+ testClientRetryWithFailover(op);
+ }
+
+ @Test (timeout=60000)
+ public void testCreate() throws Exception {
+ final DFSClient client = genClientWithDummyHandler();
+ AtMostOnceOp op = new CreateOp(client, "/testfile");
+ testClientRetryWithFailover(op);
+ }
+
+ @Test (timeout=60000)
+ public void testAppend() throws Exception {
+ final DFSClient client = genClientWithDummyHandler();
+ AtMostOnceOp op = new AppendOp(client, "/testfile");
+ testClientRetryWithFailover(op);
+ }
+
+ @Test (timeout=60000)
+ public void testRename() throws Exception {
+ final DFSClient client = genClientWithDummyHandler();
+ AtMostOnceOp op = new RenameOp(client, "/file1", "/file2");
+ testClientRetryWithFailover(op);
+ }
+
+ @Test (timeout=60000)
+ public void testRename2() throws Exception {
+ final DFSClient client = genClientWithDummyHandler();
+ AtMostOnceOp op = new Rename2Op(client, "/file1", "/file2");
+ testClientRetryWithFailover(op);
+ }
+
+ @Test (timeout=60000)
+ public void testConcat() throws Exception {
+ final DFSClient client = genClientWithDummyHandler();
+ AtMostOnceOp op = new ConcatOp(client, new Path("/test/file"), 5);
+ testClientRetryWithFailover(op);
+ }
+
+ @Test (timeout=60000)
+ public void testDelete() throws Exception {
+ final DFSClient client = genClientWithDummyHandler();
+ AtMostOnceOp op = new DeleteOp(client, "/testfile");
+ testClientRetryWithFailover(op);
+ }
+
+ @Test (timeout=60000)
+ public void testCreateSymlink() throws Exception {
+ final DFSClient client = genClientWithDummyHandler();
+ AtMostOnceOp op = new CreateSymlinkOp(client, "/testfile", "/testlink");
+ testClientRetryWithFailover(op);
+ }
+
+ @Test (timeout=60000)
+ public void testUpdatePipeline() throws Exception {
+ final DFSClient client = genClientWithDummyHandler();
+ AtMostOnceOp op = new UpdatePipelineOp(client, "/testfile");
+ testClientRetryWithFailover(op);
+ }
+
/**
* When NN failover happens, if the client did not receive the response and
* send a retry request to the other NN, the same response should be recieved
* based on the retry cache.
- *
- * TODO: currently we only test the createSnapshot from the client side. We
- * may need to cover all the calls with "@AtMostOnce" annotation.
*/
- @Test
- public void testClientRetryWithFailover() throws Exception {
- final String dir = "/test";
- final Path dirPath = new Path(dir);
- final String sName = "s1";
- final String dirSnapshot = dir + HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR
- + Path.SEPARATOR + sName;
+ public void testClientRetryWithFailover(final AtMostOnceOp op)
+ throws Exception {
+ final Map<String, Object> results = new HashMap<String, Object>();
- dfs.mkdirs(dirPath);
- dfs.allowSnapshot(dirPath);
-
- final DFSClient client = genClientWithDummyHandler();
+ op.prepare();
// set DummyRetryInvocationHandler#block to true
DummyRetryInvocationHandler.block.set(true);
@@ -207,28 +822,25 @@ public class TestRetryCacheWithHA {
@Override
public void run() {
try {
- final String snapshotPath = client.createSnapshot(dir, "s1");
- assertEquals(dirSnapshot, snapshotPath);
- LOG.info("Created snapshot " + snapshotPath);
+ op.invoke();
+ Object result = op.getResult();
+ LOG.info("Operation " + op.name + " finished");
synchronized (TestRetryCacheWithHA.this) {
- results.put("createSnapshot", snapshotPath);
+ results.put(op.name, result == null ? "SUCCESS" : result);
TestRetryCacheWithHA.this.notifyAll();
}
- } catch (IOException e) {
- LOG.info("Got IOException " + e + " while creating snapshot");
+ } catch (Exception e) {
+ LOG.info("Got Exception while calling " + op.name, e);
} finally {
- IOUtils.cleanup(null, client);
+ IOUtils.cleanup(null, op.client);
}
}
}.start();
- // make sure the client's createSnapshot call has actually been handled by
- // the active NN
- boolean snapshotCreated = dfs.exists(new Path(dirSnapshot));
- while (!snapshotCreated) {
- Thread.sleep(1000);
- snapshotCreated = dfs.exists(new Path(dirSnapshot));
- }
+ // make sure the client's call has actually been handled by the active NN
+ assertTrue("After waiting the operation " + op.name
+ + " still has not taken effect on NN yet",
+ op.checkNamenodeBeforeReturn());
// force the failover
cluster.transitionToStandby(0);
@@ -238,11 +850,11 @@ public class TestRetryCacheWithHA {
DummyRetryInvocationHandler.block.set(false);
synchronized (this) {
- while (!results.containsKey("createSnapshot")) {
+ while (!results.containsKey(op.name)) {
this.wait();
}
- LOG.info("Got the result of createSnapshot: "
- + results.get("createSnapshot"));
+ LOG.info("Got the result of " + op.name + ": "
+ + results.get(op.name));
}
}
}
\ No newline at end of file
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestStandbyCheckpoints.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestStandbyCheckpoints.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestStandbyCheckpoints.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestStandbyCheckpoints.java Tue Sep 3 18:30:05 2013
@@ -239,6 +239,34 @@ public class TestStandbyCheckpoints {
assertTrue(canceledOne);
}
+
+ /**
+ * Test cancellation of ongoing checkpoints when failover happens
+ * mid-checkpoint during image upload from standby to active NN.
+ */
+ @Test(timeout=60000)
+ public void testCheckpointCancellationDuringUpload() throws Exception {
+ // don't compress, we want a big image
+ cluster.getConfiguration(0).setBoolean(
+ DFSConfigKeys.DFS_IMAGE_COMPRESS_KEY, false);
+ cluster.getConfiguration(1).setBoolean(
+ DFSConfigKeys.DFS_IMAGE_COMPRESS_KEY, false);
+ // Throttle SBN upload to make it hang during upload to ANN
+ cluster.getConfiguration(1).setLong(
+ DFSConfigKeys.DFS_IMAGE_TRANSFER_RATE_KEY, 100);
+ cluster.restartNameNode(0);
+ cluster.restartNameNode(1);
+ nn0 = cluster.getNameNode(0);
+ nn1 = cluster.getNameNode(1);
+
+ cluster.transitionToActive(0);
+
+ doEdits(0, 100);
+ HATestUtil.waitForStandbyToCatchUp(nn0, nn1);
+ HATestUtil.waitForCheckpoint(cluster, 1, ImmutableList.of(104));
+ cluster.transitionToStandby(0);
+ cluster.transitionToActive(1);
+ }
/**
* Make sure that clients will receive StandbyExceptions even when a
Modified: hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshot.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshot.java?rev=1519787&r1=1519786&r2=1519787&view=diff
==============================================================================
--- hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshot.java (original)
+++ hadoop/common/branches/YARN-321/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshot.java Tue Sep 3 18:30:05 2013
@@ -44,6 +44,7 @@ import org.apache.hadoop.hdfs.DFSTestUti
import org.apache.hadoop.hdfs.DistributedFileSystem;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
+import org.apache.hadoop.hdfs.protocol.HdfsConstants;
import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction;
import org.apache.hadoop.hdfs.server.namenode.FSDirectory;
import org.apache.hadoop.hdfs.server.namenode.FSImageTestUtil;
@@ -54,6 +55,7 @@ import org.apache.hadoop.hdfs.server.nam
import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotTestHelper.TestDirectoryTree.Node;
import org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewer;
import org.apache.hadoop.hdfs.tools.offlineImageViewer.XmlImageVisitor;
+import org.apache.hadoop.ipc.RemoteException;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.util.Time;
import org.apache.log4j.Level;
@@ -342,6 +344,37 @@ public class TestSnapshot {
}
/**
+ * Test creating a snapshot with illegal name
+ */
+ @Test
+ public void testCreateSnapshotWithIllegalName() throws Exception {
+ final Path dir = new Path("/dir");
+ hdfs.mkdirs(dir);
+
+ final String name1 = HdfsConstants.DOT_SNAPSHOT_DIR;
+ try {
+ hdfs.createSnapshot(dir, name1);
+ fail("Exception expected when an illegal name is given");
+ } catch (RemoteException e) {
+ String errorMsg = "\"" + HdfsConstants.DOT_SNAPSHOT_DIR
+ + "\" is a reserved name.";
+ GenericTestUtils.assertExceptionContains(errorMsg, e);
+ }
+
+ String errorMsg = "Snapshot name cannot contain \"" + Path.SEPARATOR + "\"";
+ final String[] badNames = new String[] { "foo" + Path.SEPARATOR,
+ Path.SEPARATOR + "foo", Path.SEPARATOR, "foo" + Path.SEPARATOR + "bar" };
+ for (String badName : badNames) {
+ try {
+ hdfs.createSnapshot(dir, badName);
+ fail("Exception expected when an illegal name is given");
+ } catch (RemoteException e) {
+ GenericTestUtils.assertExceptionContains(errorMsg, e);
+ }
+ }
+ }
+
+ /**
* Creating snapshots for a directory that is not snapshottable must fail.
*/
@Test (timeout=60000)