Author: szetszwo
Date: Thu Apr 5 20:16:15 2012
New Revision: 1310048
URL: http://svn.apache.org/viewvc?rev=1310048&view=rev
Log:
Merge r1308633 through r1310044 from trunk.
Modified:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/CHANGES.txt
(contents, props changed)
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/pom.xml
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/docs/
(props changed)
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/
(props changed)
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ByteBufferReadable.java
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/FailoverController.java
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceTarget.java
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ShellCommandFencer.java
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/test/core/
(props changed)
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestShellCommandFencer.java
Modified:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1310048&r1=1310047&r2=1310048&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/CHANGES.txt
(original)
+++
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/CHANGES.txt
Thu Apr 5 20:16:15 2012
@@ -52,6 +52,11 @@ Trunk (unreleased changes)
HADOOP-7994. Remove getProtocolVersion and getProtocolSignature from the
client side translator and server side implementation. (jitendra)
+ HADOOP-8244. Improve comments on ByteBufferReadable.read. (Henry Robinson
+ via atm)
+
+ HADOOP-7757. Test file reference count is at least 3x actual value (Jon
+ Eagles via bobby)
BUG FIXES
@@ -245,6 +250,8 @@ Release 2.0.0 - UNRELEASED
HADOOP-8242. AbstractDelegationTokenIdentifier: add getter methods
for owner and realuser. (Colin Patrick McCabe via eli)
+ HADOOP-8007. Use substitution tokens for fencing argument (todd)
+
OPTIMIZATIONS
BUG FIXES
@@ -314,6 +321,9 @@ Release 2.0.0 - UNRELEASED
HADOOP-8238. NetUtils#getHostNameOfIP blows up if given ip:port
string w/o port. (eli)
+ HADOOP-8243. Security support broken in CLI (manual) failover controller
+ (todd)
+
BREAKDOWN OF HADOOP-7454 SUBTASKS
HADOOP-7455. HA: Introduce HA Service Protocol Interface. (suresh)
@@ -378,6 +388,18 @@ Release 0.23.3 - UNRELEASED
BUG FIXES
+ HADOOP-8088. User-group mapping cache incorrectly does negative caching on
+ transient failures (Khiwal Lee via bobby)
+
+ HADOOP-8179. risk of NPE in CopyCommands processArguments() (Daryn Sharp
+ via bobby)
+
+ HADOOP-6963. In FileUtil.getDU(..), neither include the size of directories
+ nor follow symbolic links. (Ravi Prakash via szetszwo)
+
+ HADOOP-8180. Remove hsqldb since its not needed from pom.xml (Ravi Prakash
+ via tgraves)
+
Release 0.23.2 - UNRELEASED
INCOMPATIBLE CHANGES
@@ -473,9 +495,6 @@ Release 0.23.2 - UNRELEASED
HADOOP-8176. Disambiguate the destination of FsShell copies (Daryn Sharp
via bobby)
- HADOOP-8088. User-group mapping cache incorrectly does negative caching on
- transient failures (Khiwal Lee via bobby)
-
HADOOP-8208. Disallow self failover. (eli)
Release 0.23.1 - 2012-02-17
Propchange:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/CHANGES.txt
------------------------------------------------------------------------------
Merged
/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt:r1308633-1310044
Modified:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/pom.xml
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/pom.xml?rev=1310048&r1=1310047&r2=1310048&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/pom.xml
(original)
+++
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/pom.xml
Thu Apr 5 20:16:15 2012
@@ -79,6 +79,11 @@
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>compile</scope>
@@ -194,11 +199,6 @@
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>compile</scope>
Propchange:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/docs/
------------------------------------------------------------------------------
Merged
/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/docs:r1308633-1310044
Propchange:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/
------------------------------------------------------------------------------
Merged
/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java:r1308633-1310044
Modified:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ByteBufferReadable.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ByteBufferReadable.java?rev=1310048&r1=1310047&r2=1310048&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ByteBufferReadable.java
(original)
+++
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ByteBufferReadable.java
Thu Apr 5 20:16:15 2012
@@ -28,18 +28,28 @@ public interface ByteBufferReadable {
/**
* Reads up to buf.remaining() bytes into buf. Callers should use
* buf.limit(..) to control the size of the desired read.
- *
- * After the call, buf.position() should be unchanged, and therefore any data
- * can be immediately read from buf.
- *
+ * <p/>
+ * After a successful call, buf.position() and buf.limit() should be
+ * unchanged, and therefore any data can be immediately read from buf.
+ * buf.mark() may be cleared or updated.
+ * <p/>
+ * In the case of an exception, the values of buf.position() and buf.limit()
+ * are undefined, and callers should be prepared to recover from this
+ * eventuality.
+ * <p/>
* Many implementations will throw {@link UnsupportedOperationException}, so
* callers that are not confident in support for this method from the
* underlying filesystem should be prepared to handle that exception.
+ * <p/>
+ * Implementations should treat 0-length requests as legitimate, and must not
+ * signal an error upon their receipt.
*
* @param buf
- * the ByteBuffer to receive the results of the read operation
+ * the ByteBuffer to receive the results of the read operation. Up
to
+ * buf.limit() - buf.position() bytes may be read.
* @return the number of bytes available to read from buf
- * @throws IOException if there is some error performing the read
+ * @throws IOException
+ * if there is some error performing the read
*/
public int read(ByteBuffer buf) throws IOException;
}
Modified:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java?rev=1310048&r1=1310047&r2=1310048&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
(original)
+++
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
Thu Apr 5 20:16:15 2012
@@ -483,11 +483,18 @@ public class FileUtil {
if (!dir.isDirectory()) {
return dir.length();
} else {
- size = dir.length();
File[] allFiles = dir.listFiles();
if(allFiles != null) {
for (int i = 0; i < allFiles.length; i++) {
- size = size + getDU(allFiles[i]);
+ boolean isSymLink;
+ try {
+ isSymLink =
org.apache.commons.io.FileUtils.isSymlink(allFiles[i]);
+ } catch(IOException ioe) {
+ isSymLink = true;
+ }
+ if(!isSymLink) {
+ size += getDU(allFiles[i]);
+ }
}
}
return size;
Modified:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java?rev=1310048&r1=1310047&r2=1310048&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java
(original)
+++
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/CopyCommands.java
Thu Apr 5 20:16:15 2012
@@ -81,10 +81,9 @@ class CopyCommands {
}
FSDataOutputStream out = dst.fs.create(dst.path);
try {
- FSDataInputStream in = null;
for (PathData src : srcs) {
+ FSDataInputStream in = src.fs.open(src.path);
try {
- in = src.fs.open(src.path);
IOUtils.copyBytes(in, out, getConf(), false);
if (delimiter != null) {
out.write(delimiter.getBytes("UTF-8"));
Modified:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/FailoverController.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/FailoverController.java?rev=1310048&r1=1310047&r2=1310048&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/FailoverController.java
(original)
+++
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/FailoverController.java
Thu Apr 5 20:16:15 2012
@@ -52,14 +52,22 @@ public class FailoverController {
public FailoverController(Configuration conf) {
this.conf = conf;
- this.gracefulFenceTimeout = conf.getInt(
+ this.gracefulFenceTimeout = getGracefulFenceTimeout(conf);
+ this.rpcTimeoutToNewActive = getRpcTimeoutToNewActive(conf);
+ }
+
+ static int getGracefulFenceTimeout(Configuration conf) {
+ return conf.getInt(
CommonConfigurationKeys.HA_FC_GRACEFUL_FENCE_TIMEOUT_KEY,
CommonConfigurationKeys.HA_FC_GRACEFUL_FENCE_TIMEOUT_DEFAULT);
- this.rpcTimeoutToNewActive = conf.getInt(
+ }
+
+ static int getRpcTimeoutToNewActive(Configuration conf) {
+ return conf.getInt(
CommonConfigurationKeys.HA_FC_NEW_ACTIVE_TIMEOUT_KEY,
CommonConfigurationKeys.HA_FC_NEW_ACTIVE_TIMEOUT_DEFAULT);
}
-
+
/**
* Perform pre-failover checks on the given service we plan to
* failover to, eg to prevent failing over to a service (eg due
Modified:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java?rev=1310048&r1=1310047&r2=1310048&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java
(original)
+++
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java
Thu Apr 5 20:16:15 2012
@@ -114,7 +114,8 @@ public abstract class HAAdmin extends Co
return -1;
}
- HAServiceProtocol proto = resolveTarget(argv[1]).getProxy();
+ HAServiceProtocol proto = resolveTarget(argv[1]).getProxy(
+ getConf(), 0);
HAServiceProtocolHelper.transitionToActive(proto);
return 0;
}
@@ -127,7 +128,8 @@ public abstract class HAAdmin extends Co
return -1;
}
- HAServiceProtocol proto = resolveTarget(argv[1]).getProxy();
+ HAServiceProtocol proto = resolveTarget(argv[1]).getProxy(
+ getConf(), 0);
HAServiceProtocolHelper.transitionToStandby(proto);
return 0;
}
Modified:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceTarget.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceTarget.java?rev=1310048&r1=1310047&r2=1310048&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceTarget.java
(original)
+++
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceTarget.java
Thu Apr 5 20:16:15 2012
@@ -19,6 +19,7 @@ package org.apache.hadoop.ha;
import java.io.IOException;
import java.net.InetSocketAddress;
+import java.util.Map;
import javax.net.SocketFactory;
@@ -29,6 +30,8 @@ import org.apache.hadoop.fs.CommonConfig
import org.apache.hadoop.ha.protocolPB.HAServiceProtocolClientSideTranslatorPB;
import org.apache.hadoop.net.NetUtils;
+import com.google.common.collect.Maps;
+
/**
* Represents a target of the client side HA administration commands.
*/
@@ -36,6 +39,10 @@ import org.apache.hadoop.net.NetUtils;
@InterfaceStability.Evolving
public abstract class HAServiceTarget {
+ private static final String HOST_SUBST_KEY = "host";
+ private static final String PORT_SUBST_KEY = "port";
+ private static final String ADDRESS_SUBST_KEY = "address";
+
/**
* @return the IPC address of the target node.
*/
@@ -68,11 +75,28 @@ public abstract class HAServiceTarget {
getAddress(),
confCopy, factory, timeoutMs);
}
-
+
+ public final Map<String, String> getFencingParameters() {
+ Map<String, String> ret = Maps.newHashMap();
+ addFencingParameters(ret);
+ return ret;
+ }
+
/**
- * @return a proxy to connect to the target HA Service.
+ * Hook to allow subclasses to add any parameters they would like to
+ * expose to fencing implementations/scripts. Fencing methods are free
+ * to use this map as they see fit -- notably, the shell script
+ * implementation takes each entry, prepends 'target_', substitutes
+ * '_' for '.', and adds it to the environment of the script.
+ *
+ * Subclass implementations should be sure to delegate to the superclass
+ * implementation as well as adding their own keys.
+ *
+ * @param ret map which can be mutated to pass parameters to the fencer
*/
- public final HAServiceProtocol getProxy() throws IOException {
- return getProxy(new Configuration(), 0); // default conf, timeout
+ protected void addFencingParameters(Map<String, String> ret) {
+ ret.put(ADDRESS_SUBST_KEY, String.valueOf(getAddress()));
+ ret.put(HOST_SUBST_KEY, getAddress().getHostName());
+ ret.put(PORT_SUBST_KEY, String.valueOf(getAddress().getPort()));
}
}
Modified:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ShellCommandFencer.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ShellCommandFencer.java?rev=1310048&r1=1310047&r2=1310048&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ShellCommandFencer.java
(original)
+++
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ShellCommandFencer.java
Thu Apr 5 20:16:15 2012
@@ -19,16 +19,11 @@ package org.apache.hadoop.ha;
import java.io.IOException;
import java.lang.reflect.Field;
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configured;
-import org.apache.hadoop.util.StringUtils;
import com.google.common.annotations.VisibleForTesting;
@@ -60,6 +55,9 @@ public class ShellCommandFencer
/** Length at which to abbreviate command in long messages */
private static final int ABBREV_LENGTH = 20;
+
+ /** Prefix for target parameters added to the environment */
+ private static final String TARGET_PREFIX = "target_";
@VisibleForTesting
static Log LOG = LogFactory.getLog(
@@ -76,19 +74,10 @@ public class ShellCommandFencer
@Override
public boolean tryFence(HAServiceTarget target, String cmd) {
- InetSocketAddress serviceAddr = target.getAddress();
- List<String> cmdList = Arrays.asList(cmd.split("\\s+"));
-
- // Create arg list with service as the first argument
- List<String> argList = new ArrayList<String>();
- argList.add(cmdList.get(0));
- argList.add(serviceAddr.getHostName() + ":" + serviceAddr.getPort());
- argList.addAll(cmdList.subList(1, cmdList.size()));
- String cmdWithSvc = StringUtils.join(" ", argList);
-
ProcessBuilder builder = new ProcessBuilder(
- "bash", "-e", "-c", cmdWithSvc);
+ "bash", "-e", "-c", cmd);
setConfAsEnvVars(builder.environment());
+ addTargetInfoAsEnvVars(target, builder.environment());
Process p;
try {
@@ -185,4 +174,21 @@ public class ShellCommandFencer
env.put(pair.getKey().replace('.', '_'), pair.getValue());
}
}
-}
+
+ /**
+ * Add information about the target to the the environment of the
+ * subprocess.
+ *
+ * @param target
+ * @param environment
+ */
+ private void addTargetInfoAsEnvVars(HAServiceTarget target,
+ Map<String, String> environment) {
+ for (Map.Entry<String, String> e :
+ target.getFencingParameters().entrySet()) {
+ String key = TARGET_PREFIX + e.getKey();
+ key = key.replace('.', '_');
+ environment.put(key, e.getValue());
+ }
+ }
+}
\ No newline at end of file
Modified:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java?rev=1310048&r1=1310047&r2=1310048&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java
(original)
+++
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java
Thu Apr 5 20:16:15 2012
@@ -245,7 +245,8 @@ public abstract class ZKFailoverControll
private synchronized void becomeActive() {
LOG.info("Trying to make " + localTarget + " active...");
try {
- localTarget.getProxy().transitionToActive();
+ HAServiceProtocolHelper.transitionToActive(localTarget.getProxy(
+ conf, FailoverController.getRpcTimeoutToNewActive(conf)));
LOG.info("Successfully transitioned " + localTarget +
" to active state");
} catch (Throwable t) {
@@ -267,7 +268,8 @@ public abstract class ZKFailoverControll
LOG.info("ZK Election indicated that " + localTarget +
" should become standby");
try {
- localTarget.getProxy().transitionToStandby();
+ int timeout = FailoverController.getGracefulFenceTimeout(conf);
+ localTarget.getProxy(conf, timeout).transitionToStandby();
LOG.info("Successfully transitioned " + localTarget +
" to standby state");
} catch (Exception e) {
Propchange:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/test/core/
------------------------------------------------------------------------------
Merged
/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/core:r1308633-1310044
Modified:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java?rev=1310048&r1=1310047&r2=1310048&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java
(original)
+++
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java
Thu Apr 5 20:16:15 2012
@@ -93,6 +93,9 @@ public class TestFileUtil {
// create files in partitioned directories
createFile(partitioned, "part-r-00000", "foo");
createFile(partitioned, "part-r-00001", "bar");
+
+ // create a cycle using symlinks. Cycles should be handled
+ FileUtil.symLink(del.toString(), dir1.toString() + "/cycle");
}
/**
@@ -458,4 +461,18 @@ public class TestFileUtil {
return result;
}
+
+ /**
+ * Test that getDU is able to handle cycles caused due to symbolic links
+ * and that directory sizes are not added to the final calculated size
+ * @throws IOException
+ */
+ @Test
+ public void testGetDU() throws IOException {
+ setupDirs();
+
+ long du = FileUtil.getDU(TEST_DIR);
+ //Only two files (in partitioned) have 4 bytes each
+ Assert.assertEquals(du, 8);
+ }
}
Modified:
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestShellCommandFencer.java
URL:
http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestShellCommandFencer.java?rev=1310048&r1=1310047&r2=1310048&view=diff
==============================================================================
---
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestShellCommandFencer.java
(original)
+++
hadoop/common/branches/HDFS-3092/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/TestShellCommandFencer.java
Thu Apr 5 20:16:15 2012
@@ -103,7 +103,7 @@ public class TestShellCommandFencer {
public void testStdoutLogging() {
assertTrue(fencer.tryFence(TEST_TARGET, "echo hello"));
Mockito.verify(ShellCommandFencer.LOG).info(
- Mockito.endsWith("echo hello: host:1234 hello"));
+ Mockito.endsWith("echo hello: hello"));
}
/**
@@ -114,7 +114,7 @@ public class TestShellCommandFencer {
public void testStderrLogging() {
assertTrue(fencer.tryFence(TEST_TARGET, "echo hello >&2"));
Mockito.verify(ShellCommandFencer.LOG).warn(
- Mockito.endsWith("echo hello >&2: host:1234 hello"));
+ Mockito.endsWith("echo hello >&2: hello"));
}
/**
@@ -125,8 +125,20 @@ public class TestShellCommandFencer {
public void testConfAsEnvironment() {
fencer.tryFence(TEST_TARGET, "echo $in_fencing_tests");
Mockito.verify(ShellCommandFencer.LOG).info(
- Mockito.endsWith("echo $in...ing_tests: host:1234 yessir"));
+ Mockito.endsWith("echo $in...ing_tests: yessir"));
}
+
+ /**
+ * Verify that information about the fencing target gets passed as
+ * environment variables to the fencer.
+ */
+ @Test
+ public void testTargetAsEnvironment() {
+ fencer.tryFence(TEST_TARGET, "echo $target_host $target_port
$target_address");
+ Mockito.verify(ShellCommandFencer.LOG).info(
+ Mockito.endsWith("echo $ta...t_address: host 1234 host:1234"));
+ }
+
/**
* Test that we properly close off our input to the subprocess