HDFS-1386. TestJMXGet fails in jdk7 (jeagles)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1543612 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Turner Eagles 2013-11-19 22:44:13 +00:00
parent c78c0e277f
commit 587f68b160
6 changed files with 52 additions and 11 deletions

View File

@ -506,6 +506,8 @@ Release 2.3.0 - UNRELEASED
HDFS-5073. TestListCorruptFileBlocks fails intermittently. (Arpit Agarwal) HDFS-5073. TestListCorruptFileBlocks fails intermittently. (Arpit Agarwal)
HDFS-1386. TestJMXGet fails in jdk7 (jeagles)
OPTIMIZATIONS OPTIMIZATIONS
HDFS-5239. Allow FSNamesystem lock fairness to be configurable (daryn) HDFS-5239. Allow FSNamesystem lock fairness to be configurable (daryn)

View File

@ -24,6 +24,8 @@
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.management.ObjectName;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
@ -61,6 +63,7 @@ public class JournalNode implements Tool, Configurable, JournalNodeMXBean {
private JournalNodeRpcServer rpcServer; private JournalNodeRpcServer rpcServer;
private JournalNodeHttpServer httpServer; private JournalNodeHttpServer httpServer;
private Map<String, Journal> journalsById = Maps.newHashMap(); private Map<String, Journal> journalsById = Maps.newHashMap();
private ObjectName journalNodeInfoBeanName;
private File localDir; private File localDir;
@ -181,6 +184,11 @@ public void stop(int rc) {
for (Journal j : journalsById.values()) { for (Journal j : journalsById.values()) {
IOUtils.cleanup(LOG, j); IOUtils.cleanup(LOG, j);
} }
if (journalNodeInfoBeanName != null) {
MBeans.unregister(journalNodeInfoBeanName);
journalNodeInfoBeanName = null;
}
} }
/** /**
@ -256,7 +264,7 @@ public boolean accept(File file) {
* Register JournalNodeMXBean * Register JournalNodeMXBean
*/ */
private void registerJNMXBean() { private void registerJNMXBean() {
MBeans.register("JournalNode", "JournalNodeInfo", this); journalNodeInfoBeanName = MBeans.register("JournalNode", "JournalNodeInfo", this);
} }
private class ErrorReporter implements StorageErrorReporter { private class ErrorReporter implements StorageErrorReporter {

View File

@ -96,6 +96,8 @@
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import javax.management.ObjectName;
import static org.apache.hadoop.hdfs.DFSConfigKeys.*; import static org.apache.hadoop.hdfs.DFSConfigKeys.*;
import static org.apache.hadoop.util.ExitUtil.terminate; import static org.apache.hadoop.util.ExitUtil.terminate;
@ -210,6 +212,7 @@ public static InetSocketAddress createSocketAddr(String target) {
private boolean connectToDnViaHostname; private boolean connectToDnViaHostname;
ReadaheadPool readaheadPool; ReadaheadPool readaheadPool;
private final boolean getHdfsBlockLocationsEnabled; private final boolean getHdfsBlockLocationsEnabled;
private ObjectName dataNodeInfoBeanName;
/** /**
* Create the DataNode given a configuration and an array of dataDirs. * Create the DataNode given a configuration and an array of dataDirs.
@ -879,7 +882,7 @@ public static InetSocketAddress getInfoAddr(Configuration conf) {
} }
private void registerMXBean() { private void registerMXBean() {
MBeans.register("DataNode", "DataNodeInfo", this); dataNodeInfoBeanName = MBeans.register("DataNode", "DataNodeInfo", this);
} }
@VisibleForTesting @VisibleForTesting
@ -1236,6 +1239,10 @@ public void shutdown() {
if (metrics != null) { if (metrics != null) {
metrics.shutdown(); metrics.shutdown();
} }
if (dataNodeInfoBeanName != null) {
MBeans.unregister(dataNodeInfoBeanName);
dataNodeInfoBeanName = null;
}
} }

View File

@ -5517,6 +5517,7 @@ public String getFSState() {
} }
private ObjectName mbeanName; private ObjectName mbeanName;
private ObjectName mxbeanName;
/** /**
* Register the FSNamesystem MBean using the name * Register the FSNamesystem MBean using the name
@ -5540,6 +5541,11 @@ private void registerMBean() {
void shutdown() { void shutdown() {
if (mbeanName != null) { if (mbeanName != null) {
MBeans.unregister(mbeanName); MBeans.unregister(mbeanName);
mbeanName = null;
}
if (mxbeanName != null) {
MBeans.unregister(mxbeanName);
mxbeanName = null;
} }
if (dir != null) { if (dir != null) {
dir.shutdown(); dir.shutdown();
@ -6353,7 +6359,7 @@ void logFsckEvent(String src, InetAddress remoteAddress) throws IOException {
* Register NameNodeMXBean * Register NameNodeMXBean
*/ */
private void registerMXBean() { private void registerMXBean() {
MBeans.register("NameNode", "NameNodeInfo", this); mxbeanName = MBeans.register("NameNode", "NameNodeInfo", this);
} }
/** /**

View File

@ -26,6 +26,9 @@
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import javax.management.ObjectName;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.HadoopIllegalArgumentException; import org.apache.hadoop.HadoopIllegalArgumentException;
@ -261,6 +264,7 @@ public long getProtocolVersion(String protocol,
private NameNodeRpcServer rpcServer; private NameNodeRpcServer rpcServer;
private JvmPauseMonitor pauseMonitor; private JvmPauseMonitor pauseMonitor;
private ObjectName nameNodeStatusBeanName;
/** Format a new filesystem. Destroys any filesystem that may already /** Format a new filesystem. Destroys any filesystem that may already
* exist at this location. **/ * exist at this location. **/
@ -745,6 +749,10 @@ public void stop() {
if (namesystem != null) { if (namesystem != null) {
namesystem.shutdown(); namesystem.shutdown();
} }
if (nameNodeStatusBeanName != null) {
MBeans.unregister(nameNodeStatusBeanName);
nameNodeStatusBeanName = null;
}
} }
} }
@ -1414,7 +1422,7 @@ synchronized HAServiceState getServiceState() {
* Register NameNodeStatusMXBean * Register NameNodeStatusMXBean
*/ */
private void registerNNSMXBean() { private void registerNNSMXBean() {
MBeans.register("NameNode", "NameNodeStatus", this); nameNodeStatusBeanName = MBeans.register("NameNode", "NameNodeStatus", this);
} }
@Override // NameNodeStatusMXBean @Override // NameNodeStatusMXBean

View File

@ -28,7 +28,12 @@
import java.io.PipedInputStream; import java.io.PipedInputStream;
import java.io.PipedOutputStream; import java.io.PipedOutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import java.lang.management.ManagementFactory;
import java.util.Random; import java.util.Random;
import java.util.Set;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys; import org.apache.hadoop.fs.CommonConfigurationKeys;
@ -92,9 +97,8 @@ public void testNameNode() throws Exception {
fileSize, fileSize, blockSize, (short) 2, seed); fileSize, fileSize, blockSize, (short) 2, seed);
JMXGet jmx = new JMXGet(); JMXGet jmx = new JMXGet();
//jmx.setService("*"); // list all hadoop services String serviceName = "NameNode";
//jmx.init(); jmx.setService(serviceName);
//jmx = new JMXGet();
jmx.init(); // default lists namenode mbeans only jmx.init(); // default lists namenode mbeans only
assertTrue("error printAllValues", checkPrintAllValues(jmx)); assertTrue("error printAllValues", checkPrintAllValues(jmx));
@ -107,6 +111,10 @@ public void testNameNode() throws Exception {
jmx.getValue("NumOpenConnections"))); jmx.getValue("NumOpenConnections")));
cluster.shutdown(); cluster.shutdown();
MBeanServerConnection mbsc = ManagementFactory.getPlatformMBeanServer();
ObjectName query = new ObjectName("Hadoop:service=" + serviceName + ",*");
Set<ObjectName> names = mbsc.queryNames(query, null);
assertTrue("No beans should be registered for " + serviceName, names.isEmpty());
} }
private static boolean checkPrintAllValues(JMXGet jmx) throws Exception { private static boolean checkPrintAllValues(JMXGet jmx) throws Exception {
@ -140,13 +148,15 @@ public void testDataNode() throws Exception {
fileSize, fileSize, blockSize, (short) 2, seed); fileSize, fileSize, blockSize, (short) 2, seed);
JMXGet jmx = new JMXGet(); JMXGet jmx = new JMXGet();
//jmx.setService("*"); // list all hadoop services String serviceName = "DataNode";
//jmx.init(); jmx.setService(serviceName);
//jmx = new JMXGet();
jmx.setService("DataNode");
jmx.init(); jmx.init();
assertEquals(fileSize, Integer.parseInt(jmx.getValue("BytesWritten"))); assertEquals(fileSize, Integer.parseInt(jmx.getValue("BytesWritten")));
cluster.shutdown(); cluster.shutdown();
MBeanServerConnection mbsc = ManagementFactory.getPlatformMBeanServer();
ObjectName query = new ObjectName("Hadoop:service=" + serviceName + ",*");
Set<ObjectName> names = mbsc.queryNames(query, null);
assertTrue("No beans should be registered for " + serviceName, names.isEmpty());
} }
} }