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 sz...@apache.org on 2012/10/19 04:28:07 UTC
svn commit: r1399950 [20/27] - in
/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project: ./
hadoop-hdfs-httpfs/ hadoop-hdfs-httpfs/dev-support/
hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/
hadoop-hdfs-httpfs/src/main/java/org/apac...
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestGetBlocks.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestGetBlocks.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestGetBlocks.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestGetBlocks.java Fri Oct 19 02:25:55 2012
@@ -17,80 +17,201 @@
*/
package org.apache.hadoop.hdfs;
+import static org.junit.Assert.*;
+
import java.io.IOException;
import java.net.InetSocketAddress;
-import java.util.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.CommonConfigurationKeys;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.protocol.Block;
+import org.apache.hadoop.hdfs.protocol.ClientProtocol;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
+import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
+import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor;
import org.apache.hadoop.hdfs.server.common.GenerationStamp;
+import org.apache.hadoop.hdfs.server.datanode.DataNode;
+import org.apache.hadoop.hdfs.server.datanode.DataNodeTestUtils;
import org.apache.hadoop.hdfs.server.namenode.NameNode;
-import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocol;
import org.apache.hadoop.hdfs.server.protocol.BlocksWithLocations.BlockWithLocations;
-import org.apache.hadoop.fs.FSDataOutputStream;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocol;
import org.apache.hadoop.ipc.RemoteException;
-import junit.framework.TestCase;
+import org.apache.hadoop.util.Time;
+import org.junit.Test;
+
/**
- * This class tests if block replacement request to data nodes work correctly.
+ * This class tests if getblocks request works correctly.
*/
-public class TestGetBlocks extends TestCase {
+public class TestGetBlocks {
+ private static final int blockSize = 8192;
+ private static final String racks[] = new String[] { "/d1/r1", "/d1/r1",
+ "/d1/r2", "/d1/r2", "/d1/r2", "/d2/r3", "/d2/r3" };
+ private static final int numDatanodes = racks.length;
+
+ /**
+ * Stop the heartbeat of a datanode in the MiniDFSCluster
+ *
+ * @param cluster
+ * The MiniDFSCluster
+ * @param hostName
+ * The hostName of the datanode to be stopped
+ * @return The DataNode whose heartbeat has been stopped
+ */
+ private DataNode stopDataNodeHeartbeat(MiniDFSCluster cluster, String hostName) {
+ for (DataNode dn : cluster.getDataNodes()) {
+ if (dn.getDatanodeId().getHostName().equals(hostName)) {
+ DataNodeTestUtils.setHeartbeatsDisabledForTests(dn, true);
+ return dn;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Test if the datanodes returned by
+ * {@link ClientProtocol#getBlockLocations(String, long, long)} is correct
+ * when stale nodes checking is enabled. Also test during the scenario when 1)
+ * stale nodes checking is enabled, 2) a writing is going on, 3) a datanode
+ * becomes stale happen simultaneously
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testReadSelectNonStaleDatanode() throws Exception {
+ HdfsConfiguration conf = new HdfsConfiguration();
+ conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_CHECK_STALE_DATANODE_KEY, true);
+ long staleInterval = 30 * 1000 * 60;
+ conf.setLong(DFSConfigKeys.DFS_NAMENODE_STALE_DATANODE_INTERVAL_KEY,
+ staleInterval);
+ MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
+ .numDataNodes(numDatanodes).racks(racks).build();
+
+ cluster.waitActive();
+ InetSocketAddress addr = new InetSocketAddress("localhost",
+ cluster.getNameNodePort());
+ DFSClient client = new DFSClient(addr, conf);
+ List<DatanodeDescriptor> nodeInfoList = cluster.getNameNode()
+ .getNamesystem().getBlockManager().getDatanodeManager()
+ .getDatanodeListForReport(DatanodeReportType.LIVE);
+ assertEquals("Unexpected number of datanodes", numDatanodes,
+ nodeInfoList.size());
+ FileSystem fileSys = cluster.getFileSystem();
+ FSDataOutputStream stm = null;
+ try {
+ // do the writing but do not close the FSDataOutputStream
+ // in order to mimic the ongoing writing
+ final Path fileName = new Path("/file1");
+ stm = fileSys.create(fileName, true,
+ fileSys.getConf().getInt(
+ CommonConfigurationKeys.IO_FILE_BUFFER_SIZE_KEY, 4096),
+ (short) 3, blockSize);
+ stm.write(new byte[(blockSize * 3) / 2]);
+ // We do not close the stream so that
+ // the writing seems to be still ongoing
+ stm.hflush();
+
+ LocatedBlocks blocks = client.getNamenode().getBlockLocations(
+ fileName.toString(), 0, blockSize);
+ DatanodeInfo[] nodes = blocks.get(0).getLocations();
+ assertEquals(nodes.length, 3);
+ DataNode staleNode = null;
+ DatanodeDescriptor staleNodeInfo = null;
+ // stop the heartbeat of the first node
+ staleNode = this.stopDataNodeHeartbeat(cluster, nodes[0].getHostName());
+ assertNotNull(staleNode);
+ // set the first node as stale
+ staleNodeInfo = cluster.getNameNode().getNamesystem().getBlockManager()
+ .getDatanodeManager()
+ .getDatanode(staleNode.getDatanodeId());
+ staleNodeInfo.setLastUpdate(Time.now() - staleInterval - 1);
+
+ LocatedBlocks blocksAfterStale = client.getNamenode().getBlockLocations(
+ fileName.toString(), 0, blockSize);
+ DatanodeInfo[] nodesAfterStale = blocksAfterStale.get(0).getLocations();
+ assertEquals(nodesAfterStale.length, 3);
+ assertEquals(nodesAfterStale[2].getHostName(), nodes[0].getHostName());
+
+ // restart the staleNode's heartbeat
+ DataNodeTestUtils.setHeartbeatsDisabledForTests(staleNode, false);
+ // reset the first node as non-stale, so as to avoid two stale nodes
+ staleNodeInfo.setLastUpdate(Time.now());
+
+ LocatedBlock lastBlock = client.getLocatedBlocks(fileName.toString(), 0,
+ Long.MAX_VALUE).getLastLocatedBlock();
+ nodes = lastBlock.getLocations();
+ assertEquals(nodes.length, 3);
+ // stop the heartbeat of the first node for the last block
+ staleNode = this.stopDataNodeHeartbeat(cluster, nodes[0].getHostName());
+ assertNotNull(staleNode);
+ // set the node as stale
+ cluster.getNameNode().getNamesystem().getBlockManager()
+ .getDatanodeManager()
+ .getDatanode(staleNode.getDatanodeId())
+ .setLastUpdate(Time.now() - staleInterval - 1);
+
+ LocatedBlock lastBlockAfterStale = client.getLocatedBlocks(
+ fileName.toString(), 0, Long.MAX_VALUE).getLastLocatedBlock();
+ nodesAfterStale = lastBlockAfterStale.getLocations();
+ assertEquals(nodesAfterStale.length, 3);
+ assertEquals(nodesAfterStale[2].getHostName(), nodes[0].getHostName());
+ } finally {
+ if (stm != null) {
+ stm.close();
+ }
+ cluster.shutdown();
+ }
+ }
+
/** test getBlocks */
+ @Test
public void testGetBlocks() throws Exception {
final Configuration CONF = new HdfsConfiguration();
- final short REPLICATION_FACTOR = (short)2;
+ final short REPLICATION_FACTOR = (short) 2;
final int DEFAULT_BLOCK_SIZE = 1024;
- final Random r = new Random();
-
+
CONF.setLong(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, DEFAULT_BLOCK_SIZE);
- MiniDFSCluster cluster = new MiniDFSCluster.Builder(CONF)
- .numDataNodes(REPLICATION_FACTOR)
- .build();
+ MiniDFSCluster cluster = new MiniDFSCluster.Builder(CONF).numDataNodes(
+ REPLICATION_FACTOR).build();
try {
cluster.waitActive();
-
- // create a file with two blocks
- FileSystem fs = cluster.getFileSystem();
- FSDataOutputStream out = fs.create(new Path("/tmp.txt"),
- REPLICATION_FACTOR);
- byte [] data = new byte[1024];
- long fileLen = 2*DEFAULT_BLOCK_SIZE;
- long bytesToWrite = fileLen;
- while( bytesToWrite > 0 ) {
- r.nextBytes(data);
- int bytesToWriteNext = (1024<bytesToWrite)?1024:(int)bytesToWrite;
- out.write(data, 0, bytesToWriteNext);
- bytesToWrite -= bytesToWriteNext;
- }
- out.close();
+ long fileLen = 2 * DEFAULT_BLOCK_SIZE;
+ DFSTestUtil.createFile(cluster.getFileSystem(), new Path("/tmp.txt"),
+ fileLen, REPLICATION_FACTOR, 0L);
// get blocks & data nodes
List<LocatedBlock> locatedBlocks;
- DatanodeInfo[] dataNodes=null;
+ DatanodeInfo[] dataNodes = null;
boolean notWritten;
do {
- final DFSClient dfsclient = new DFSClient(NameNode.getAddress(CONF), CONF);
- locatedBlocks = dfsclient.getNamenode().
- getBlockLocations("/tmp.txt", 0, fileLen).getLocatedBlocks();
+ final DFSClient dfsclient = new DFSClient(NameNode.getAddress(CONF),
+ CONF);
+ locatedBlocks = dfsclient.getNamenode()
+ .getBlockLocations("/tmp.txt", 0, fileLen).getLocatedBlocks();
assertEquals(2, locatedBlocks.size());
notWritten = false;
- for(int i=0; i<2; i++) {
+ for (int i = 0; i < 2; i++) {
dataNodes = locatedBlocks.get(i).getLocations();
- if(dataNodes.length != REPLICATION_FACTOR) {
+ if (dataNodes.length != REPLICATION_FACTOR) {
notWritten = true;
try {
Thread.sleep(10);
- } catch(InterruptedException e) {
+ } catch (InterruptedException e) {
}
break;
}
}
- } while(notWritten);
-
+ } while (notWritten);
+
// get RPC client to namenode
InetSocketAddress addr = new InetSocketAddress("localhost",
cluster.getNameNodePort());
@@ -115,7 +236,7 @@ public class TestGetBlocks extends TestC
assertEquals(locs[0].getStorageIDs().length, 2);
// get blocks of size 0 from dataNodes[0]
- getBlocksWithException(namenode, dataNodes[0], 0);
+ getBlocksWithException(namenode, dataNodes[0], 0);
// get blocks of size -1 from dataNodes[0]
getBlocksWithException(namenode, dataNodes[0], -1);
@@ -129,45 +250,39 @@ public class TestGetBlocks extends TestC
}
private void getBlocksWithException(NamenodeProtocol namenode,
- DatanodeInfo datanode,
- long size) throws IOException {
+ DatanodeInfo datanode, long size) throws IOException {
boolean getException = false;
try {
- namenode.getBlocks(DFSTestUtil.getLocalDatanodeInfo(), 2);
- } catch(RemoteException e) {
+ namenode.getBlocks(DFSTestUtil.getLocalDatanodeInfo(), 2);
+ } catch (RemoteException e) {
getException = true;
assertTrue(e.getClassName().contains("HadoopIllegalArgumentException"));
}
assertTrue(getException);
}
-
+
+ @Test
public void testBlockKey() {
Map<Block, Long> map = new HashMap<Block, Long>();
final Random RAN = new Random();
final long seed = RAN.nextLong();
- System.out.println("seed=" + seed);
+ System.out.println("seed=" + seed);
RAN.setSeed(seed);
- long[] blkids = new long[10];
- for(int i = 0; i < blkids.length; i++) {
+ long[] blkids = new long[10];
+ for (int i = 0; i < blkids.length; i++) {
blkids[i] = 1000L + RAN.nextInt(100000);
map.put(new Block(blkids[i], 0, blkids[i]), blkids[i]);
}
System.out.println("map=" + map.toString().replace(",", "\n "));
-
- for(int i = 0; i < blkids.length; i++) {
- Block b = new Block(blkids[i], 0, GenerationStamp.GRANDFATHER_GENERATION_STAMP);
+
+ for (int i = 0; i < blkids.length; i++) {
+ Block b = new Block(blkids[i], 0,
+ GenerationStamp.GRANDFATHER_GENERATION_STAMP);
Long v = map.get(b);
System.out.println(b + " => " + v);
assertEquals(blkids[i], v.longValue());
}
}
- /**
- * @param args
- */
- public static void main(String[] args) throws Exception {
- (new TestGetBlocks()).testGetBlocks();
- }
-
}
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHDFSServerPorts.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHDFSServerPorts.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHDFSServerPorts.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHDFSServerPorts.java Fri Oct 19 02:25:55 2012
@@ -17,25 +17,26 @@
*/
package org.apache.hadoop.hdfs;
+import static org.apache.hadoop.hdfs.server.common.Util.fileAsURI;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.io.File;
import java.io.IOException;
import java.net.UnknownHostException;
-import junit.framework.TestCase;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileUtil;
-import static org.apache.hadoop.hdfs.server.common.Util.fileAsURI;
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
import org.apache.hadoop.hdfs.server.namenode.BackupNode;
import org.apache.hadoop.hdfs.server.namenode.NameNode;
-import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.apache.hadoop.net.DNS;
+import org.junit.Test;
/**
* This test checks correctness of port usage by hdfs components:
@@ -47,7 +48,7 @@ import org.apache.hadoop.net.DNS;
* - if the port = 0 (ephemeral) then the server should choose
* a free port and start on it.
*/
-public class TestHDFSServerPorts extends TestCase {
+public class TestHDFSServerPorts {
public static final Log LOG = LogFactory.getLog(TestHDFSServerPorts.class);
// reset default 0.0.0.0 addresses in order to avoid IPv6 problem
@@ -250,6 +251,7 @@ public class TestHDFSServerPorts extends
return true;
}
+ @Test
public void testNameNodePorts() throws Exception {
runTestNameNodePorts(false);
runTestNameNodePorts(true);
@@ -300,6 +302,7 @@ public class TestHDFSServerPorts extends
/**
* Verify datanode port usage.
*/
+ @Test
public void testDataNodePorts() throws Exception {
NameNode nn = null;
try {
@@ -335,6 +338,7 @@ public class TestHDFSServerPorts extends
/**
* Verify secondary namenode port usage.
*/
+ @Test
public void testSecondaryNodePorts() throws Exception {
NameNode nn = null;
try {
@@ -363,6 +367,7 @@ public class TestHDFSServerPorts extends
/**
* Verify BackupNode port usage.
*/
+ @Test
public void testBackupNodePorts() throws Exception {
NameNode nn = null;
try {
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHDFSTrash.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHDFSTrash.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHDFSTrash.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHDFSTrash.java Fri Oct 19 02:25:55 2012
@@ -23,12 +23,13 @@ import org.apache.hadoop.conf.Configurat
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.TestTrash;
+
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
/**
- * This class tests commands from Trash.
+ * Test trash using HDFS
*/
public class TestHDFSTrash {
private static MiniDFSCluster cluster = null;
@@ -44,9 +45,6 @@ public class TestHDFSTrash {
if (cluster != null) { cluster.shutdown(); }
}
- /**
- * Tests Trash on HDFS
- */
@Test
public void testTrash() throws IOException {
TestTrash.trashShell(cluster.getFileSystem(), new Path("/"));
@@ -59,5 +57,4 @@ public class TestHDFSTrash {
conf.set(DFSConfigKeys.FS_DEFAULT_NAME_KEY, fs.getUri().toString());
TestTrash.trashNonDefaultFS(conf);
}
-
}
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHFlush.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHFlush.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHFlush.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHFlush.java Fri Oct 19 02:25:55 2012
@@ -17,6 +17,13 @@
*/
package org.apache.hadoop.hdfs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+
import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
@@ -24,15 +31,8 @@ import org.apache.hadoop.fs.FSDataOutput
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
import org.apache.log4j.Level;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import java.io.InterruptedIOException;
-import java.io.IOException;
-
/** Class contains a set of tests to verify the correctness of
* newly introduced {@link FSDataOutputStream#hflush()} method */
public class TestHFlush {
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHdfsAdmin.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHdfsAdmin.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHdfsAdmin.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHdfsAdmin.java Fri Oct 19 02:25:55 2012
@@ -17,7 +17,8 @@
*/
package org.apache.hadoop.hdfs;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.net.URI;
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHftpDelegationToken.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHftpDelegationToken.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHftpDelegationToken.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHftpDelegationToken.java Fri Oct 19 02:25:55 2012
@@ -18,15 +18,14 @@
package org.apache.hadoop.hdfs;
-import static
- org.apache.hadoop.fs.CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION;
-
+import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION;
+import static org.junit.Assert.*;
import java.io.IOException;
import java.lang.reflect.Field;
+import java.net.ServerSocket;
+import java.net.Socket;
import java.net.URI;
import java.security.PrivilegedExceptionAction;
-import org.junit.Test;
-import static org.junit.Assert.*;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
@@ -36,11 +35,14 @@ import org.apache.hadoop.security.Securi
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.security.token.TokenIdentifier;
+import org.junit.Test;
public class TestHftpDelegationToken {
@Test
public void testHdfsDelegationToken() throws Exception {
+ SecurityUtilTestHelper.setTokenServiceUseIp(true);
+
final Configuration conf = new Configuration();
conf.set(HADOOP_SECURITY_AUTHENTICATION, "kerberos");
UserGroupInformation.setConfiguration(conf);
@@ -53,12 +55,13 @@ public class TestHftpDelegationToken {
new Text("127.0.0.1:8020"));
user.addToken(token);
Token<?> token2 = new Token<TokenIdentifier>
- (null, null, new Text("other token"), new Text("127.0.0.1:8020"));
+ (null, null, new Text("other token"), new Text("127.0.0.1:8021"));
user.addToken(token2);
assertEquals("wrong tokens in user", 2, user.getTokens().size());
FileSystem fs =
user.doAs(new PrivilegedExceptionAction<FileSystem>() {
- public FileSystem run() throws Exception {
+ @Override
+ public FileSystem run() throws Exception {
return FileSystem.get(new URI("hftp://localhost:50470/"), conf);
}
});
@@ -135,6 +138,53 @@ public class TestHftpDelegationToken {
conf.setInt(DFSConfigKeys.DFS_NAMENODE_HTTPS_PORT_KEY, 5);
}
+
+ @Test
+ public void testInsecureRemoteCluster() throws Exception {
+ final ServerSocket socket = new ServerSocket(0); // just reserve a port
+ socket.close();
+ Configuration conf = new Configuration();
+ URI fsUri = URI.create("hsftp://localhost:"+socket.getLocalPort());
+ assertNull(FileSystem.newInstance(fsUri, conf).getDelegationToken(null));
+ }
+
+ @Test
+ public void testSecureClusterError() throws Exception {
+ final ServerSocket socket = new ServerSocket(0);
+ Thread t = new Thread() {
+ @Override
+ public void run() {
+ while (true) { // fetching does a few retries
+ try {
+ Socket s = socket.accept();
+ s.getOutputStream().write(1234);
+ s.shutdownOutput();
+ } catch (Exception e) {
+ break;
+ }
+ }
+ }
+ };
+ t.start();
+
+ try {
+ Configuration conf = new Configuration();
+ URI fsUri = URI.create("hsftp://localhost:"+socket.getLocalPort());
+ Exception ex = null;
+ try {
+ FileSystem.newInstance(fsUri, conf).getDelegationToken(null);
+ } catch (Exception e) {
+ ex = e;
+ }
+ assertNotNull(ex);
+ assertNotNull(ex.getCause());
+ assertEquals("Unexpected end of file from server",
+ ex.getCause().getMessage());
+ } finally {
+ t.interrupt();
+ }
+ }
+
private void checkTokenSelection(HftpFileSystem fs,
int port,
Configuration conf) throws IOException {
@@ -217,4 +267,4 @@ public class TestHftpDelegationToken {
@Override
protected void initDelegationToken() throws IOException {}
}
-}
\ No newline at end of file
+}
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHftpFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHftpFileSystem.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHftpFileSystem.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHftpFileSystem.java Fri Oct 19 02:25:55 2012
@@ -18,19 +18,18 @@
package org.apache.hadoop.hdfs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.io.InputStream;
-import java.net.URISyntaxException;
+import java.net.HttpURLConnection;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
-import java.net.HttpURLConnection;
import java.util.Random;
-import org.junit.Test;
-import org.junit.BeforeClass;
-import org.junit.AfterClass;
-import static org.junit.Assert.*;
-
import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.BlockLocation;
@@ -38,12 +37,14 @@ import org.apache.hadoop.fs.FSDataInputS
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
import org.apache.hadoop.hdfs.server.datanode.DataNodeTestUtils;
import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration;
import org.apache.hadoop.util.ServletUtil;
import org.apache.log4j.Level;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
public class TestHftpFileSystem {
private static final Random RAN = new Random();
@@ -91,7 +92,6 @@ public class TestHftpFileSystem {
RAN.setSeed(seed);
config = new Configuration();
- config.set(DFSConfigKeys.DFS_DATANODE_HOST_NAME_KEY, "localhost");
cluster = new MiniDFSCluster.Builder(config).numDataNodes(2).build();
hdfs = cluster.getFileSystem();
blockPoolId = cluster.getNamesystem().getBlockPoolId();
@@ -102,9 +102,15 @@ public class TestHftpFileSystem {
@AfterClass
public static void tearDown() throws IOException {
- hdfs.close();
- hftpFs.close();
- cluster.shutdown();
+ if (hdfs != null) {
+ hdfs.close();
+ }
+ if (hftpFs != null) {
+ hftpFs.close();
+ }
+ if (cluster != null) {
+ cluster.shutdown();
+ }
}
/**
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHftpURLTimeouts.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHftpURLTimeouts.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHftpURLTimeouts.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestHftpURLTimeouts.java Fri Oct 19 02:25:55 2012
@@ -27,7 +27,6 @@ import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.SocketTimeoutException;
import java.net.URI;
-import java.net.URLConnection;
import java.util.LinkedList;
import java.util.List;
@@ -54,19 +53,23 @@ public class TestHftpURLTimeouts {
boolean timedout = false;
HftpFileSystem fs = (HftpFileSystem)FileSystem.get(uri, conf);
- HttpURLConnection conn = fs.openConnection("/", "");
- timedout = false;
try {
- // this will consume the only slot in the backlog
- conn.getInputStream();
- } catch (SocketTimeoutException ste) {
- timedout = true;
- assertEquals("Read timed out", ste.getMessage());
+ HttpURLConnection conn = fs.openConnection("/", "");
+ timedout = false;
+ try {
+ // this will consume the only slot in the backlog
+ conn.getInputStream();
+ } catch (SocketTimeoutException ste) {
+ timedout = true;
+ assertEquals("Read timed out", ste.getMessage());
+ } finally {
+ if (conn != null) conn.disconnect();
+ }
+ assertTrue("read timedout", timedout);
+ assertTrue("connect timedout", checkConnectTimeout(fs, false));
} finally {
- if (conn != null) conn.disconnect();
+ fs.close();
}
- assertTrue("read timedout", timedout);
- assertTrue("connect timedout", checkConnectTimeout(fs, false));
}
@Test
@@ -80,20 +83,24 @@ public class TestHftpURLTimeouts {
boolean timedout = false;
HsftpFileSystem fs = (HsftpFileSystem)FileSystem.get(uri, conf);
- HttpURLConnection conn = null;
- timedout = false;
try {
- // this will consume the only slot in the backlog
- conn = fs.openConnection("/", "");
- } catch (SocketTimeoutException ste) {
- // SSL expects a negotiation, so it will timeout on read, unlike hftp
- timedout = true;
- assertEquals("Read timed out", ste.getMessage());
+ HttpURLConnection conn = null;
+ timedout = false;
+ try {
+ // this will consume the only slot in the backlog
+ conn = fs.openConnection("/", "");
+ } catch (SocketTimeoutException ste) {
+ // SSL expects a negotiation, so it will timeout on read, unlike hftp
+ timedout = true;
+ assertEquals("Read timed out", ste.getMessage());
+ } finally {
+ if (conn != null) conn.disconnect();
+ }
+ assertTrue("ssl read connect timedout", timedout);
+ assertTrue("connect timedout", checkConnectTimeout(fs, true));
} finally {
- if (conn != null) conn.disconnect();
+ fs.close();
}
- assertTrue("ssl read connect timedout", timedout);
- assertTrue("connect timedout", checkConnectTimeout(fs, true));
}
private boolean checkConnectTimeout(HftpFileSystem fs, boolean ignoreReadTimeout)
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestInjectionForSimulatedStorage.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestInjectionForSimulatedStorage.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestInjectionForSimulatedStorage.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestInjectionForSimulatedStorage.java Fri Oct 19 02:25:55 2012
@@ -17,12 +17,12 @@
*/
package org.apache.hadoop.hdfs;
-import junit.framework.TestCase;
-import java.io.*;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
import java.util.HashSet;
import java.util.Set;
-import java.net.*;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,12 +36,14 @@ import org.apache.hadoop.hdfs.protocol.C
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
import org.apache.hadoop.hdfs.server.datanode.SimulatedFSDataset;
+import org.apache.hadoop.util.Time;
+import org.junit.Test;
/**
* This class tests the replication and injection of blocks of a DFS file for simulated storage.
*/
-public class TestInjectionForSimulatedStorage extends TestCase {
+public class TestInjectionForSimulatedStorage {
private int checksumSize = 16;
private int blockSize = checksumSize*2;
private int numBlocks = 4;
@@ -50,29 +52,13 @@ public class TestInjectionForSimulatedSt
private static final Log LOG = LogFactory.getLog(
"org.apache.hadoop.hdfs.TestInjectionForSimulatedStorage");
-
- private void writeFile(FileSystem fileSys, Path name, int repl)
- throws IOException {
- // create and write a file that contains three blocks of data
- FSDataOutputStream stm = fileSys.create(name, true, fileSys.getConf()
- .getInt(CommonConfigurationKeys.IO_FILE_BUFFER_SIZE_KEY, 4096),
- (short) repl, blockSize);
- byte[] buffer = new byte[filesize];
- for (int i=0; i<buffer.length; i++) {
- buffer[i] = '1';
- }
- stm.write(buffer);
- stm.close();
- }
-
- // Waits for all of the blocks to have expected replication
// Waits for all of the blocks to have expected replication
private void waitForBlockReplication(String filename,
ClientProtocol namenode,
int expected, long maxWaitSec)
throws IOException {
- long start = System.currentTimeMillis();
+ long start = Time.now();
//wait for all the blocks to be replicated;
LOG.info("Checking for block replication for " + filename);
@@ -97,7 +83,7 @@ public class TestInjectionForSimulatedSt
actual + ".");
if (maxWaitSec > 0 &&
- (System.currentTimeMillis() - start) > (maxWaitSec * 1000)) {
+ (Time.now() - start) > (maxWaitSec * 1000)) {
throw new IOException("Timedout while waiting for all blocks to " +
" be replicated for " + filename);
}
@@ -121,6 +107,7 @@ public class TestInjectionForSimulatedSt
* The blocks are then injected in one of the DNs. The expected behaviour is
* that the NN will arrange for themissing replica will be copied from a valid source.
*/
+ @Test
public void testInjection() throws IOException {
MiniDFSCluster cluster = null;
@@ -146,7 +133,8 @@ public class TestInjectionForSimulatedSt
cluster.getNameNodePort()),
conf);
- writeFile(cluster.getFileSystem(), testPath, numDataNodes);
+ DFSTestUtil.createFile(cluster.getFileSystem(), testPath, filesize,
+ filesize, blockSize, (short) numDataNodes, 0L);
waitForBlockReplication(testFile, dfsClient.getNamenode(), numDataNodes, 20);
Iterable<Block>[] blocksList = cluster.getAllBlockReports(bpid);
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestIsMethodSupported.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestIsMethodSupported.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestIsMethodSupported.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestIsMethodSupported.java Fri Oct 19 02:25:55 2012
@@ -17,11 +17,12 @@
*/
package org.apache.hadoop.hdfs;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.net.InetSocketAddress;
-import junit.framework.Assert;
-
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
import org.apache.hadoop.hdfs.protocolPB.ClientDatanodeProtocolTranslatorPB;
import org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB;
@@ -78,16 +79,16 @@ public class TestIsMethodSupported {
nnAddress, NamenodeProtocol.class, UserGroupInformation.getCurrentUser(),
true).getProxy();
boolean exists = translator.isMethodSupported("rollEditLog");
- Assert.assertTrue(exists);
+ assertTrue(exists);
exists = translator.isMethodSupported("bogusMethod");
- Assert.assertFalse(exists);
+ assertFalse(exists);
}
@Test
public void testDatanodeProtocol() throws IOException {
DatanodeProtocolClientSideTranslatorPB translator =
new DatanodeProtocolClientSideTranslatorPB(nnAddress, conf);
- Assert.assertTrue(translator.isMethodSupported("sendHeartbeat"));
+ assertTrue(translator.isMethodSupported("sendHeartbeat"));
}
@Test
@@ -97,12 +98,12 @@ public class TestIsMethodSupported {
UserGroupInformation.getCurrentUser(), conf,
NetUtils.getDefaultSocketFactory(conf));
//Namenode doesn't implement ClientDatanodeProtocol
- Assert.assertFalse(translator.isMethodSupported("refreshNamenodes"));
+ assertFalse(translator.isMethodSupported("refreshNamenodes"));
translator = new ClientDatanodeProtocolTranslatorPB(
dnAddress, UserGroupInformation.getCurrentUser(), conf,
NetUtils.getDefaultSocketFactory(conf));
- Assert.assertTrue(translator.isMethodSupported("refreshNamenodes"));
+ assertTrue(translator.isMethodSupported("refreshNamenodes"));
}
@Test
@@ -111,7 +112,7 @@ public class TestIsMethodSupported {
(ClientNamenodeProtocolTranslatorPB) NameNodeProxies.createNonHAProxy(
conf, nnAddress, ClientProtocol.class,
UserGroupInformation.getCurrentUser(), true).getProxy();
- Assert.assertTrue(translator.isMethodSupported("mkdirs"));
+ assertTrue(translator.isMethodSupported("mkdirs"));
}
@Test
@@ -120,7 +121,7 @@ public class TestIsMethodSupported {
NameNodeProxies.createNonHAProxy(conf, nnAddress, JournalProtocol.class,
UserGroupInformation.getCurrentUser(), true).getProxy();
//Nameode doesn't implement JournalProtocol
- Assert.assertFalse(translator.isMethodSupported("startLogSegment"));
+ assertFalse(translator.isMethodSupported("startLogSegment"));
}
@Test
@@ -130,12 +131,12 @@ public class TestIsMethodSupported {
nnAddress, UserGroupInformation.getCurrentUser(), conf,
NetUtils.getDefaultSocketFactory(conf), 0);
//Not supported at namenode
- Assert.assertFalse(translator.isMethodSupported("initReplicaRecovery"));
+ assertFalse(translator.isMethodSupported("initReplicaRecovery"));
translator = new InterDatanodeProtocolTranslatorPB(
dnAddress, UserGroupInformation.getCurrentUser(), conf,
NetUtils.getDefaultSocketFactory(conf), 0);
- Assert.assertTrue(translator.isMethodSupported("initReplicaRecovery"));
+ assertTrue(translator.isMethodSupported("initReplicaRecovery"));
}
@Test
@@ -145,7 +146,7 @@ public class TestIsMethodSupported {
NameNodeProxies.createNonHAProxy(conf, nnAddress,
GetUserMappingsProtocol.class, UserGroupInformation.getCurrentUser(),
true).getProxy();
- Assert.assertTrue(translator.isMethodSupported("getGroupsForUser"));
+ assertTrue(translator.isMethodSupported("getGroupsForUser"));
}
@Test
@@ -155,7 +156,7 @@ public class TestIsMethodSupported {
NameNodeProxies.createNonHAProxy(conf, nnAddress,
RefreshAuthorizationPolicyProtocol.class,
UserGroupInformation.getCurrentUser(), true).getProxy();
- Assert.assertTrue(translator.isMethodSupported("refreshServiceAcl"));
+ assertTrue(translator.isMethodSupported("refreshServiceAcl"));
}
@Test
@@ -165,7 +166,7 @@ public class TestIsMethodSupported {
NameNodeProxies.createNonHAProxy(conf, nnAddress,
RefreshUserMappingsProtocol.class,
UserGroupInformation.getCurrentUser(), true).getProxy();
- Assert.assertTrue(
+ assertTrue(
translator.isMethodSupported("refreshUserToGroupsMappings"));
}
}
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLargeBlock.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLargeBlock.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLargeBlock.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLargeBlock.java Fri Oct 19 02:25:55 2012
@@ -17,6 +17,8 @@
*/
package org.apache.hadoop.hdfs;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.util.Arrays;
@@ -30,7 +32,6 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.server.datanode.SimulatedFSDataset;
import org.junit.Test;
-import static org.junit.Assert.assertTrue;
/**
* This class tests that blocks can be larger than 2GB
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLease.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLease.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLease.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLease.java Fri Oct 19 02:25:55 2012
@@ -17,33 +17,31 @@
*/
package org.apache.hadoop.hdfs;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.spy;
+
import java.io.DataOutputStream;
import java.io.IOException;
import java.security.PrivilegedExceptionAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction;
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter;
import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols;
import org.apache.hadoop.ipc.RemoteException;
-import org.apache.hadoop.security.token.SecretManager.InvalidToken;
import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.security.token.SecretManager.InvalidToken;
+import org.apache.hadoop.util.Time;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.doNothing;
public class TestLease {
static boolean hasLease(MiniDFSCluster cluster, Path src) {
@@ -82,7 +80,8 @@ public class TestLease {
// We don't need to wait the lease renewer thread to act.
// call renewLease() manually.
// make it look like lease has already expired.
- dfs.lastLeaseRenewal = System.currentTimeMillis() - 300000;
+ LeaseRenewer originalRenewer = dfs.getLeaseRenewer();
+ dfs.lastLeaseRenewal = Time.now() - 300000;
dfs.renewLease();
// this should not work.
@@ -94,6 +93,10 @@ public class TestLease {
LOG.info("Write failed as expected. ", e);
}
+ // If aborted, the renewer should be empty. (no reference to clients)
+ Thread.sleep(1000);
+ Assert.assertTrue(originalRenewer.isEmpty());
+
// unstub
doNothing().when(spyNN).renewLease(anyString());
@@ -167,15 +170,20 @@ public class TestLease {
final Configuration conf = new Configuration();
final DFSClient c1 = createDFSClientAs(ugi[0], conf);
+ FSDataOutputStream out1 = createFsOut(c1, "/out1");
final DFSClient c2 = createDFSClientAs(ugi[0], conf);
- Assert.assertEquals(c1.leaserenewer, c2.leaserenewer);
+ FSDataOutputStream out2 = createFsOut(c2, "/out2");
+ Assert.assertEquals(c1.getLeaseRenewer(), c2.getLeaseRenewer());
final DFSClient c3 = createDFSClientAs(ugi[1], conf);
- Assert.assertTrue(c1.leaserenewer != c3.leaserenewer);
+ FSDataOutputStream out3 = createFsOut(c3, "/out3");
+ Assert.assertTrue(c1.getLeaseRenewer() != c3.getLeaseRenewer());
final DFSClient c4 = createDFSClientAs(ugi[1], conf);
- Assert.assertEquals(c3.leaserenewer, c4.leaserenewer);
+ FSDataOutputStream out4 = createFsOut(c4, "/out4");
+ Assert.assertEquals(c3.getLeaseRenewer(), c4.getLeaseRenewer());
final DFSClient c5 = createDFSClientAs(ugi[2], conf);
- Assert.assertTrue(c1.leaserenewer != c5.leaserenewer);
- Assert.assertTrue(c3.leaserenewer != c5.leaserenewer);
+ FSDataOutputStream out5 = createFsOut(c5, "/out5");
+ Assert.assertTrue(c1.getLeaseRenewer() != c5.getLeaseRenewer());
+ Assert.assertTrue(c3.getLeaseRenewer() != c5.getLeaseRenewer());
}
private FSDataOutputStream createFsOut(DFSClient dfs, String path)
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery.java Fri Oct 19 02:25:55 2012
@@ -16,6 +16,8 @@
* limitations under the License.
*/
package org.apache.hadoop.hdfs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
@@ -31,8 +33,9 @@ import org.apache.hadoop.hdfs.server.dat
import org.apache.hadoop.hdfs.server.datanode.fsdataset.impl.TestInterDatanodeProtocol;
import org.apache.hadoop.hdfs.server.namenode.LeaseManager;
import org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter;
+import org.junit.Test;
-public class TestLeaseRecovery extends junit.framework.TestCase {
+public class TestLeaseRecovery {
static final int BLOCK_SIZE = 1024;
static final short REPLICATION_NUM = (short)3;
private static final long LEASE_PERIOD = 300L;
@@ -66,6 +69,7 @@ public class TestLeaseRecovery extends j
* It randomly truncates the replica of the last block stored in each datanode.
* Finally, it triggers block synchronization to synchronize all stored block.
*/
+ @Test
public void testBlockSynchronization() throws Exception {
final int ORG_FILE_SIZE = 3000;
Configuration conf = new HdfsConfiguration();
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery2.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery2.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery2.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRecovery2.java Fri Oct 19 02:25:55 2012
@@ -171,7 +171,7 @@ public class TestLeaseRecovery2 {
if (triggerLeaseRenewerInterrupt) {
AppendTestUtil.LOG.info("leasechecker.interruptAndJoin()");
- dfs.dfs.leaserenewer.interruptAndJoin();
+ dfs.dfs.getLeaseRenewer().interruptAndJoin();
}
return filepath;
}
@@ -276,7 +276,7 @@ public class TestLeaseRecovery2 {
// kill the lease renewal thread
AppendTestUtil.LOG.info("leasechecker.interruptAndJoin()");
- dfs.dfs.leaserenewer.interruptAndJoin();
+ dfs.dfs.getLeaseRenewer().interruptAndJoin();
// set the hard limit to be 1 second
cluster.setLeasePeriod(LONG_LEASE_PERIOD, SHORT_LEASE_PERIOD);
@@ -341,7 +341,7 @@ public class TestLeaseRecovery2 {
AppendTestUtil.LOG.info("hflush");
stm.hflush();
AppendTestUtil.LOG.info("leasechecker.interruptAndJoin()");
- dfs.dfs.leaserenewer.interruptAndJoin();
+ dfs.dfs.getLeaseRenewer().interruptAndJoin();
// set the soft limit to be 1 second so that the
// namenode triggers lease recovery on next attempt to write-for-open.
@@ -463,7 +463,7 @@ public class TestLeaseRecovery2 {
// kill the lease renewal thread
AppendTestUtil.LOG.info("leasechecker.interruptAndJoin()");
- dfs.dfs.leaserenewer.interruptAndJoin();
+ dfs.dfs.getLeaseRenewer().interruptAndJoin();
// Make sure the DNs don't send a heartbeat for a while, so the blocks
// won't actually get completed during lease recovery.
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRenewer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRenewer.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRenewer.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLeaseRenewer.java Fri Oct 19 02:25:55 2012
@@ -17,14 +17,14 @@
*/
package org.apache.hadoop.hdfs;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertSame;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
-
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.test.GenericTestUtils;
+import org.apache.hadoop.util.Time;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -93,13 +93,6 @@ public class TestLeaseRenewer {
}
@Test
- public void testClientName() throws IOException {
- String clientName = renewer.getClientName("NONMAPREDUCE");
- Assert.assertTrue("bad client name: " + clientName,
- clientName.startsWith("DFSClient_NONMAPREDUCE_"));
- }
-
- @Test
public void testRenewal() throws Exception {
// Keep track of how many times the lease gets renewed
final AtomicInteger leaseRenewalCount = new AtomicInteger();
@@ -118,8 +111,8 @@ public class TestLeaseRenewer {
renewer.put(filePath, mockStream, MOCK_DFSCLIENT);
// Wait for lease to get renewed
- long failTime = System.currentTimeMillis() + 5000;
- while (System.currentTimeMillis() < failTime &&
+ long failTime = Time.now() + 5000;
+ while (Time.now() < failTime &&
leaseRenewalCount.get() == 0) {
Thread.sleep(50);
}
@@ -206,8 +199,8 @@ public class TestLeaseRenewer {
renewer.closeFile(filePath, MOCK_DFSCLIENT);
// Should stop the renewer running within a few seconds
- long failTime = System.currentTimeMillis() + 5000;
- while (renewer.isRunning() && System.currentTimeMillis() < failTime) {
+ long failTime = Time.now() + 5000;
+ while (renewer.isRunning() && Time.now() < failTime) {
Thread.sleep(50);
}
Assert.assertFalse(renewer.isRunning());
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInDFS.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInDFS.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInDFS.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInDFS.java Fri Oct 19 02:25:55 2012
@@ -22,7 +22,6 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.TestListFiles;
import org.apache.log4j.Level;
-
import org.junit.AfterClass;
import org.junit.BeforeClass;
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInFileContext.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInFileContext.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInFileContext.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestListFilesInFileContext.java Fri Oct 19 02:25:55 2012
@@ -17,6 +17,10 @@
*/
package org.apache.hadoop.hdfs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.util.EnumSet;
import java.util.Random;
@@ -33,13 +37,10 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.RemoteIterator;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.log4j.Level;
-
-import static org.junit.Assert.*;
-
import org.junit.After;
import org.junit.AfterClass;
-import org.junit.Test;
import org.junit.BeforeClass;
+import org.junit.Test;
/**
* This class tests the FileStatus API.
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLocalDFS.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLocalDFS.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLocalDFS.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestLocalDFS.java Fri Oct 19 02:25:55 2012
@@ -17,12 +17,17 @@
*/
package org.apache.hadoop.hdfs;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import java.io.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import org.junit.Test;
/**
* This class tests the DFS class via the FileSystem interface in a single node
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMiniDFSCluster.java Fri Oct 19 02:25:55 2012
@@ -18,15 +18,18 @@
package org.apache.hadoop.hdfs;
-import junit.framework.Assert;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
+
+import java.io.File;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.protocol.FSConstants;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.io.File;
-
/**
* Tests MiniDFS cluster setup/teardown and isolation.
* Every instance is brought up with a new data dir, to ensure that
@@ -39,6 +42,7 @@ public class TestMiniDFSCluster {
private static final String CLUSTER_2 = "cluster2";
private static final String CLUSTER_3 = "cluster3";
private static final String CLUSTER_4 = "cluster4";
+ private static final String CLUSTER_5 = "cluster5";
protected String testDataPath;
protected File testDataDir;
@Before
@@ -70,7 +74,7 @@ public class TestMiniDFSCluster {
conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c1Path);
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
try {
- Assert.assertEquals(c1Path+"/data", cluster.getDataDirectory());
+ assertEquals(c1Path+"/data", cluster.getDataDirectory());
} finally {
cluster.shutdown();
}
@@ -91,14 +95,14 @@ public class TestMiniDFSCluster {
MiniDFSCluster cluster3 = null;
try {
String dataDir2 = cluster2.getDataDirectory();
- Assert.assertEquals(c2Path + "/data", dataDir2);
+ assertEquals(c2Path + "/data", dataDir2);
//change the data dir
conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR,
testDataCluster3.getAbsolutePath());
MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf);
cluster3 = builder.build();
String dataDir3 = cluster3.getDataDirectory();
- Assert.assertTrue("Clusters are bound to the same directory: " + dataDir2,
+ assertTrue("Clusters are bound to the same directory: " + dataDir2,
!dataDir2.equals(dataDir3));
} finally {
MiniDFSCluster.shutdownCluster(cluster3);
@@ -123,4 +127,25 @@ public class TestMiniDFSCluster {
}
}
}
+
+ /** MiniDFSCluster should not clobber dfs.datanode.hostname if requested */
+ @Test(timeout=100000)
+ public void testClusterSetDatanodeHostname() throws Throwable {
+ assumeTrue(System.getProperty("os.name").startsWith("Linux"));
+ Configuration conf = new HdfsConfiguration();
+ conf.set(DFSConfigKeys.DFS_DATANODE_HOST_NAME_KEY, "MYHOST");
+ File testDataCluster5 = new File(testDataPath, CLUSTER_5);
+ String c5Path = testDataCluster5.getAbsolutePath();
+ conf.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, c5Path);
+ MiniDFSCluster cluster5 = new MiniDFSCluster.Builder(conf)
+ .numDataNodes(1)
+ .checkDataNodeHostConfig(true)
+ .build();
+ try {
+ assertEquals("DataNode hostname config not respected", "MYHOST",
+ cluster5.getDataNodes().get(0).getDatanodeId().getHostName());
+ } finally {
+ MiniDFSCluster.shutdownCluster(cluster5);
+ }
+ }
}
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMissingBlocksAlert.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMissingBlocksAlert.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMissingBlocksAlert.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMissingBlocksAlert.java Fri Oct 19 02:25:55 2012
@@ -17,11 +17,13 @@
*/
package org.apache.hadoop.hdfs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.net.URL;
-import junit.framework.TestCase;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
@@ -30,17 +32,19 @@ import org.apache.hadoop.fs.FSDataInputS
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager;
+import org.junit.Test;
/**
* The test makes sure that NameNode detects presense blocks that do not have
* any valid replicas. In addition, it verifies that HDFS front page displays
* a warning in such a case.
*/
-public class TestMissingBlocksAlert extends TestCase {
+public class TestMissingBlocksAlert {
private static final Log LOG =
LogFactory.getLog(TestMissingBlocksAlert.class);
+ @Test
public void testMissingBlocksAlert() throws IOException,
InterruptedException {
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestModTime.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestModTime.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestModTime.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestModTime.java Fri Oct 19 02:25:55 2012
@@ -17,23 +17,30 @@
*/
package org.apache.hadoop.hdfs;
-import junit.framework.TestCase;
-import java.io.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
import java.util.Random;
-import java.net.*;
+
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
-import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
+import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
+import org.apache.hadoop.util.ThreadUtil;
+import org.junit.Test;
/**
* This class tests the decommissioning of nodes.
*/
-public class TestModTime extends TestCase {
+public class TestModTime {
+
static final long seed = 0xDEADBEEFL;
static final int blockSize = 8192;
static final int fileSize = 16384;
@@ -43,19 +50,6 @@ public class TestModTime extends TestCas
Random myrand = new Random();
Path hostsFile;
Path excludeFile;
-
- private void writeFile(FileSystem fileSys, Path name, int repl)
- throws IOException {
- // create and write a file that contains three blocks of data
- FSDataOutputStream stm = fileSys.create(name, true, fileSys.getConf()
- .getInt(CommonConfigurationKeys.IO_FILE_BUFFER_SIZE_KEY, 4096),
- (short) repl, blockSize);
- byte[] buffer = new byte[fileSize];
- Random rand = new Random(seed);
- rand.nextBytes(buffer);
- stm.write(buffer);
- stm.close();
- }
private void cleanupFile(FileSystem fileSys, Path name) throws IOException {
assertTrue(fileSys.exists(name));
@@ -74,6 +68,7 @@ public class TestModTime extends TestCas
/**
* Tests modification time in DFS.
*/
+ @Test
public void testModTime() throws IOException {
Configuration conf = new HdfsConfiguration();
@@ -97,7 +92,8 @@ public class TestModTime extends TestCas
System.out.println("Creating testdir1 and testdir1/test1.dat.");
Path dir1 = new Path("testdir1");
Path file1 = new Path(dir1, "test1.dat");
- writeFile(fileSys, file1, replicas);
+ DFSTestUtil.createFile(fileSys, file1, fileSize, fileSize, blockSize,
+ (short) replicas, seed);
FileStatus stat = fileSys.getFileStatus(file1);
long mtime1 = stat.getModificationTime();
assertTrue(mtime1 != 0);
@@ -112,7 +108,8 @@ public class TestModTime extends TestCas
//
System.out.println("Creating testdir1/test2.dat.");
Path file2 = new Path(dir1, "test2.dat");
- writeFile(fileSys, file2, replicas);
+ DFSTestUtil.createFile(fileSys, file2, fileSize, fileSize, blockSize,
+ (short) replicas, seed);
stat = fileSys.getFileStatus(file2);
//
@@ -181,6 +178,46 @@ public class TestModTime extends TestCas
cluster.shutdown();
}
}
+
+ /**
+ * Regression test for HDFS-3864 - NN does not update internal file mtime for
+ * OP_CLOSE when reading from the edit log.
+ */
+ @Test
+ public void testModTimePersistsAfterRestart() throws IOException {
+ final long sleepTime = 10; // 10 milliseconds
+ MiniDFSCluster cluster = null;
+ FileSystem fs = null;
+ Configuration conf = new HdfsConfiguration();
+ try {
+ cluster = new MiniDFSCluster.Builder(conf).build();
+ fs = cluster.getFileSystem();
+ Path testPath = new Path("/test");
+
+ // Open a file, and get its initial modification time.
+ OutputStream out = fs.create(testPath);
+ long initialModTime = fs.getFileStatus(testPath).getModificationTime();
+ assertTrue(initialModTime > 0);
+
+ // Wait and then close the file. Ensure that the mod time goes up.
+ ThreadUtil.sleepAtLeastIgnoreInterrupts(sleepTime);
+ out.close();
+ long modTimeAfterClose = fs.getFileStatus(testPath).getModificationTime();
+ assertTrue(modTimeAfterClose >= initialModTime + sleepTime);
+
+ // Restart the NN, and make sure that the later mod time is still used.
+ cluster.restartNameNode();
+ long modTimeAfterRestart = fs.getFileStatus(testPath).getModificationTime();
+ assertEquals(modTimeAfterClose, modTimeAfterRestart);
+ } finally {
+ if (fs != null) {
+ fs.close();
+ }
+ if (cluster != null) {
+ cluster.shutdown();
+ }
+ }
+ }
public static void main(String[] args) throws Exception {
new TestModTime().testModTime();
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMultiThreadedHflush.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMultiThreadedHflush.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMultiThreadedHflush.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMultiThreadedHflush.java Fri Oct 19 02:25:55 2012
@@ -17,49 +17,43 @@
*/
package org.apache.hadoop.hdfs;
-import org.junit.Test;
-
-import java.io.*;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.CommonConfigurationKeys;
+import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.FSDataOutputStream;
-import org.apache.hadoop.hdfs.server.datanode.DataNode;
-import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
-import org.apache.hadoop.hdfs.server.namenode.LeaseManager;
-import org.apache.hadoop.hdfs.server.namenode.NameNode;
-import org.apache.hadoop.hdfs.server.protocol.InterDatanodeProtocol;
-import org.apache.log4j.Level;
+import org.apache.hadoop.metrics2.util.Quantile;
+import org.apache.hadoop.metrics2.util.SampleQuantiles;
+import org.apache.hadoop.util.Tool;
+import org.apache.hadoop.util.ToolRunner;
+import org.junit.Test;
+
+import com.google.common.base.Stopwatch;
/**
* This class tests hflushing concurrently from many threads.
*/
public class TestMultiThreadedHflush {
static final int blockSize = 1024*1024;
- static final int numBlocks = 10;
- static final int fileSize = numBlocks * blockSize + 1;
private static final int NUM_THREADS = 10;
private static final int WRITE_SIZE = 517;
private static final int NUM_WRITES_PER_THREAD = 1000;
private byte[] toWrite = null;
-
- {
- ((Log4JLogger)NameNode.stateChangeLog).getLogger().setLevel(Level.ALL);
- ((Log4JLogger)LeaseManager.LOG).getLogger().setLevel(Level.ALL);
- ((Log4JLogger)LogFactory.getLog(FSNamesystem.class)).getLogger().setLevel(Level.ALL);
- ((Log4JLogger)DataNode.LOG).getLogger().setLevel(Level.ALL);
- ((Log4JLogger)DFSClient.LOG).getLogger().setLevel(Level.ALL);
- ((Log4JLogger)InterDatanodeProtocol.LOG).getLogger().setLevel(Level.ALL);
- }
+
+ private final SampleQuantiles quantiles = new SampleQuantiles(
+ new Quantile[] {
+ new Quantile(0.50, 0.050),
+ new Quantile(0.75, 0.025), new Quantile(0.90, 0.010),
+ new Quantile(0.95, 0.005), new Quantile(0.99, 0.001) });
/*
* creates a file but does not close it
@@ -92,6 +86,7 @@ public class TestMultiThreadedHflush {
this.countdown = countdown;
}
+ @Override
public void run() {
try {
countdown.await();
@@ -104,8 +99,11 @@ public class TestMultiThreadedHflush {
}
private void doAWrite() throws IOException {
+ Stopwatch sw = new Stopwatch().start();
stm.write(toWrite);
stm.hflush();
+ long micros = sw.elapsedTime(TimeUnit.MICROSECONDS);
+ quantiles.insert(micros);
}
}
@@ -115,14 +113,28 @@ public class TestMultiThreadedHflush {
* They all finish before the file is closed.
*/
@Test
- public void testMultipleHflushers() throws Exception {
+ public void testMultipleHflushersRepl1() throws Exception {
+ doTestMultipleHflushers(1);
+ }
+
+ @Test
+ public void testMultipleHflushersRepl3() throws Exception {
+ doTestMultipleHflushers(3);
+ }
+
+ private void doTestMultipleHflushers(int repl) throws Exception {
Configuration conf = new Configuration();
- MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
+ MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
+ .numDataNodes(repl)
+ .build();
FileSystem fs = cluster.getFileSystem();
Path p = new Path("/multiple-hflushers.dat");
try {
- doMultithreadedWrites(conf, p, NUM_THREADS, WRITE_SIZE, NUM_WRITES_PER_THREAD);
+ doMultithreadedWrites(conf, p, NUM_THREADS, WRITE_SIZE,
+ NUM_WRITES_PER_THREAD, repl);
+ System.out.println("Latency quantiles (in microseconds):\n" +
+ quantiles);
} finally {
fs.close();
cluster.shutdown();
@@ -151,6 +163,7 @@ public class TestMultiThreadedHflush {
try {
for (int i = 0; i < 10; i++) {
Thread flusher = new Thread() {
+ @Override
public void run() {
try {
while (true) {
@@ -199,13 +212,13 @@ public class TestMultiThreadedHflush {
}
public void doMultithreadedWrites(
- Configuration conf, Path p, int numThreads, int bufferSize, int numWrites)
- throws Exception {
+ Configuration conf, Path p, int numThreads, int bufferSize, int numWrites,
+ int replication) throws Exception {
initBuffer(bufferSize);
// create a new file.
FileSystem fs = p.getFileSystem(conf);
- FSDataOutputStream stm = createFile(fs, p, 1);
+ FSDataOutputStream stm = createFile(fs, p, replication);
System.out.println("Created file simpleFlush.dat");
// There have been a couple issues with flushing empty buffers, so do
@@ -239,20 +252,41 @@ public class TestMultiThreadedHflush {
}
public static void main(String args[]) throws Exception {
- if (args.length != 1) {
- System.err.println(
- "usage: " + TestMultiThreadedHflush.class.getSimpleName() +
- " <path to test file> ");
- System.exit(1);
+ System.exit(ToolRunner.run(new CLIBenchmark(), args));
+ }
+
+ private static class CLIBenchmark extends Configured implements Tool {
+ public int run(String args[]) throws Exception {
+ if (args.length != 1) {
+ System.err.println(
+ "usage: " + TestMultiThreadedHflush.class.getSimpleName() +
+ " <path to test file> ");
+ System.err.println(
+ "Configurations settable by -D options:\n" +
+ " num.threads [default 10] - how many threads to run\n" +
+ " write.size [default 511] - bytes per write\n" +
+ " num.writes [default 50000] - how many writes to perform");
+ System.exit(1);
+ }
+ TestMultiThreadedHflush test = new TestMultiThreadedHflush();
+ Configuration conf = getConf();
+ Path p = new Path(args[0]);
+
+ int numThreads = conf.getInt("num.threads", 10);
+ int writeSize = conf.getInt("write.size", 511);
+ int numWrites = conf.getInt("num.writes", 50000);
+ int replication = conf.getInt(DFSConfigKeys.DFS_REPLICATION_KEY,
+ DFSConfigKeys.DFS_REPLICATION_DEFAULT);
+
+ Stopwatch sw = new Stopwatch().start();
+ test.doMultithreadedWrites(conf, p, numThreads, writeSize, numWrites,
+ replication);
+ sw.stop();
+
+ System.out.println("Finished in " + sw.elapsedMillis() + "ms");
+ System.out.println("Latency quantiles (in microseconds):\n" +
+ test.quantiles);
+ return 0;
}
- TestMultiThreadedHflush test = new TestMultiThreadedHflush();
- Configuration conf = new Configuration();
- Path p = new Path(args[0]);
- long st = System.nanoTime();
- test.doMultithreadedWrites(conf, p, 10, 511, 50000);
- long et = System.nanoTime();
-
- System.out.println("Finished in " + ((et - st) / 1000000) + "ms");
}
-
}
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestParallelReadUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestParallelReadUtil.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestParallelReadUtil.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestParallelReadUtil.java Fri Oct 19 02:25:55 2012
@@ -17,20 +17,22 @@
*/
package org.apache.hadoop.hdfs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Random;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdfs.server.datanode.DataNode;
+import org.apache.hadoop.util.Time;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
-import static org.junit.Assert.*;
-
/**
* Driver class for testing the use of DFSInputStream by multiple concurrent
* readers, using the different read APIs. See subclasses for the actual test
@@ -61,7 +63,7 @@ public class TestParallelReadUtil {
public static void setupCluster(int replicationFactor, HdfsConfiguration conf) throws Exception {
util = new BlockReaderTestUtil(replicationFactor, conf);
dfsClient = util.getDFSClient();
- long seed = System.currentTimeMillis();
+ long seed = Time.now();
LOG.info("Random seed: " + seed);
rand = new Random(seed);
}
@@ -81,7 +83,7 @@ public class TestParallelReadUtil {
static class DirectReadWorkerHelper implements ReadWorkerHelper {
@Override
public int read(DFSInputStream dis, byte[] target, int startOff, int len) throws IOException {
- ByteBuffer bb = ByteBuffer.wrap(target);
+ ByteBuffer bb = ByteBuffer.allocateDirect(target.length);
int cnt = 0;
synchronized(dis) {
dis.seek(startOff);
@@ -93,6 +95,8 @@ public class TestParallelReadUtil {
cnt += read;
}
}
+ bb.clear();
+ bb.get(target);
return cnt;
}
@@ -321,7 +325,7 @@ public class TestParallelReadUtil {
}
// Start the workers and wait
- long starttime = System.currentTimeMillis();
+ long starttime = Time.now();
for (ReadWorker worker : workers) {
worker.start();
}
@@ -331,7 +335,7 @@ public class TestParallelReadUtil {
worker.join();
} catch (InterruptedException ignored) { }
}
- long endtime = System.currentTimeMillis();
+ long endtime = Time.now();
// Cleanup
for (TestFileInfo testInfo : testInfoArr) {
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPersistBlocks.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPersistBlocks.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPersistBlocks.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPersistBlocks.java Fri Oct 19 02:25:55 2012
@@ -72,10 +72,25 @@ public class TestPersistBlocks {
rand.nextBytes(DATA_BEFORE_RESTART);
rand.nextBytes(DATA_AFTER_RESTART);
}
+
+ /** check if DFS remains in proper condition after a restart
+ **/
+ @Test
+ public void TestRestartDfsWithFlush() throws Exception {
+ testRestartDfs(true);
+ }
- /** check if DFS remains in proper condition after a restart */
- @Test
- public void testRestartDfs() throws Exception {
+
+ /** check if DFS remains in proper condition after a restart
+ **/
+ public void TestRestartDfsWithSync() throws Exception {
+ testRestartDfs(false);
+ }
+
+ /** check if DFS remains in proper condition after a restart
+ * @param useFlush - if true then flush is used instead of sync (ie hflush)
+ */
+ void testRestartDfs(boolean useFlush) throws Exception {
final Configuration conf = new HdfsConfiguration();
// Turn off persistent IPC, so that the DFSClient can survive NN restart
conf.setInt(
@@ -92,7 +107,10 @@ public class TestPersistBlocks {
// Creating a file with 4096 blockSize to write multiple blocks
stream = fs.create(FILE_PATH, true, BLOCK_SIZE, (short) 1, BLOCK_SIZE);
stream.write(DATA_BEFORE_RESTART);
- stream.hflush();
+ if (useFlush)
+ stream.flush();
+ else
+ stream.hflush();
// Wait for at least a few blocks to get through
while (len <= BLOCK_SIZE) {
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPread.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPread.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPread.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestPread.java Fri Oct 19 02:25:55 2012
@@ -17,34 +17,33 @@
*/
package org.apache.hadoop.hdfs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Random;
-import junit.framework.TestCase;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.server.datanode.SimulatedFSDataset;
+import org.junit.Test;
/**
* This class tests the DFS positional read functionality in a single node
* mini-cluster.
*/
-public class TestPread extends TestCase {
+public class TestPread {
static final long seed = 0xDEADBEEFL;
static final int blockSize = 4096;
boolean simulatedStorage = false;
private void writeFile(FileSystem fileSys, Path name) throws IOException {
- // create and write a file that contains three blocks of data
- DataOutputStream stm = fileSys.create(name, true, 4096, (short)1,
- blockSize);
// test empty file open and read
- stm.close();
+ DFSTestUtil.createFile(fileSys, name, 12 * blockSize, 0,
+ blockSize, (short) 1, seed);
FSDataInputStream in = fileSys.open(name);
byte[] buffer = new byte[12 * blockSize];
in.readFully(0, buffer, 0, 0);
@@ -61,11 +60,8 @@ public class TestPread extends TestCase
assertTrue("Cannot delete file", false);
// now create the real file
- stm = fileSys.create(name, true, 4096, (short)1, blockSize);
- Random rand = new Random(seed);
- rand.nextBytes(buffer);
- stm.write(buffer);
- stm.close();
+ DFSTestUtil.createFile(fileSys, name, 12 * blockSize, 12 * blockSize,
+ blockSize, (short) 1, seed);
}
private void checkAndEraseData(byte[] actual, int from, byte[] expected, String message) {
@@ -196,6 +192,7 @@ public class TestPread extends TestCase
/**
* Tests positional read in DFS.
*/
+ @Test
public void testPreadDFS() throws IOException {
dfsPreadTest(false); //normal pread
dfsPreadTest(true); //trigger read code path without transferTo.
@@ -225,6 +222,7 @@ public class TestPread extends TestCase
}
}
+ @Test
public void testPreadDFSSimulated() throws IOException {
simulatedStorage = true;
testPreadDFS();
@@ -234,6 +232,7 @@ public class TestPread extends TestCase
/**
* Tests positional read in LocalFS.
*/
+ @Test
public void testPreadLocalFS() throws IOException {
Configuration conf = new HdfsConfiguration();
FileSystem fileSys = FileSystem.getLocal(conf);
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestQuota.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestQuota.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestQuota.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestQuota.java Fri Oct 19 02:25:55 2012
@@ -17,7 +17,10 @@
*/
package org.apache.hadoop.hdfs;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.OutputStream;
import java.security.PrivilegedExceptionAction;
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestReadWhileWriting.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestReadWhileWriting.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestReadWhileWriting.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestReadWhileWriting.java Fri Oct 19 02:25:55 2012
@@ -88,7 +88,7 @@ public class TestReadWhileWriting {
// of data can be read successfully.
checkFile(p, half, conf);
AppendTestUtil.LOG.info("leasechecker.interruptAndJoin()");
- ((DistributedFileSystem)fs).dfs.leaserenewer.interruptAndJoin();
+ ((DistributedFileSystem)fs).dfs.getLeaseRenewer().interruptAndJoin();
//c. On M1, append another half block of data. Close file on M1.
{
Modified: hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRenameWhileOpen.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRenameWhileOpen.java?rev=1399950&r1=1399949&r2=1399950&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRenameWhileOpen.java (original)
+++ hadoop/common/branches/HDFS-2802/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRenameWhileOpen.java Fri Oct 19 02:25:55 2012
@@ -16,6 +16,7 @@
* limitations under the License.
*/
package org.apache.hadoop.hdfs;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
@@ -29,8 +30,9 @@ import org.apache.hadoop.hdfs.server.nam
import org.apache.hadoop.hdfs.server.namenode.LeaseManager;
import org.apache.hadoop.hdfs.server.namenode.NameNode;
import org.apache.log4j.Level;
+import org.junit.Test;
-public class TestRenameWhileOpen extends junit.framework.TestCase {
+public class TestRenameWhileOpen {
{
((Log4JLogger)NameNode.stateChangeLog).getLogger().setLevel(Level.ALL);
((Log4JLogger)LeaseManager.LOG).getLogger().setLevel(Level.ALL);
@@ -47,6 +49,7 @@ public class TestRenameWhileOpen extends
* mkdir /user/dir3
* move /user/dir1 /user/dir3
*/
+ @Test
public void testWhileOpenRenameParent() throws IOException {
Configuration conf = new HdfsConfiguration();
final int MAX_IDLE_TIME = 2000; // 2s
@@ -132,6 +135,7 @@ public class TestRenameWhileOpen extends
* open /user/dir1/file1 /user/dir2/file2
* move /user/dir1 /user/dir3
*/
+ @Test
public void testWhileOpenRenameParentToNonexistentDir() throws IOException {
Configuration conf = new HdfsConfiguration();
final int MAX_IDLE_TIME = 2000; // 2s
@@ -206,6 +210,7 @@ public class TestRenameWhileOpen extends
* mkdir /user/dir2
* move /user/dir1/file1 /user/dir2/
*/
+ @Test
public void testWhileOpenRenameToExistentDirectory() throws IOException {
Configuration conf = new HdfsConfiguration();
final int MAX_IDLE_TIME = 2000; // 2s
@@ -270,6 +275,7 @@ public class TestRenameWhileOpen extends
* open /user/dir1/file1
* move /user/dir1/file1 /user/dir2/
*/
+ @Test
public void testWhileOpenRenameToNonExistentDirectory() throws IOException {
Configuration conf = new HdfsConfiguration();
final int MAX_IDLE_TIME = 2000; // 2s