Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E1BE2200C68 for ; Wed, 29 Mar 2017 05:53:54 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E09D7160B9B; Wed, 29 Mar 2017 03:53:54 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3DF78160B9F for ; Wed, 29 Mar 2017 05:53:54 +0200 (CEST) Received: (qmail 45381 invoked by uid 500); 29 Mar 2017 03:53:40 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 43025 invoked by uid 99); 29 Mar 2017 03:53:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Mar 2017 03:53:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6EE47EF7C4; Wed, 29 Mar 2017 03:53:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cdouglas@apache.org To: common-commits@hadoop.apache.org Date: Wed, 29 Mar 2017 03:53:54 -0000 Message-Id: In-Reply-To: <35af17e78deb4cb8acca65b96ebd1a38@git.apache.org> References: <35af17e78deb4cb8acca65b96ebd1a38@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [17/50] [abbrv] hadoop git commit: HDFS-11570. Unit test for NameNodeStatusMXBean. Contributed by Hanisha Koneru. archived-at: Wed, 29 Mar 2017 03:53:55 -0000 HDFS-11570. Unit test for NameNodeStatusMXBean. Contributed by Hanisha Koneru. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/1f665244 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1f665244 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1f665244 Branch: refs/heads/HDFS-9806 Commit: 1f66524432edf37e28ec03aba8d12b22ce0ef60c Parents: 1168ece Author: Hanisha Koneru Authored: Fri Mar 24 14:44:25 2017 -0700 Committer: Arpit Agarwal Committed: Fri Mar 24 14:44:25 2017 -0700 ---------------------------------------------------------------------- .../namenode/TestNameNodeStatusMXBean.java | 93 ++++++++++++++++++++ 1 file changed, 93 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/1f665244/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeStatusMXBean.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeStatusMXBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeStatusMXBean.java new file mode 100644 index 0000000..c03dc20 --- /dev/null +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeStatusMXBean.java @@ -0,0 +1,93 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hdfs.server.namenode; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hdfs.MiniDFSCluster; +import org.apache.hadoop.hdfs.server.datanode.TestDataNodeMXBean; +import org.junit.Assert; +import org.junit.Test; + +import javax.management.MBeanServer; +import javax.management.ObjectName; +import java.lang.management.ManagementFactory; + +/** + * Class for testing {@link NameNodeStatusMXBean} implementation. + */ +public class TestNameNodeStatusMXBean { + + public static final Log LOG = LogFactory.getLog( + TestNameNodeStatusMXBean.class); + + @Test(timeout = 120000L) + public void testDataNodeMXBean() throws Exception { + Configuration conf = new Configuration(); + MiniDFSCluster cluster = null; + + try { + cluster = new MiniDFSCluster.Builder(conf).build(); + cluster.waitActive(); + + NameNode nn = cluster.getNameNode(); + + MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); + ObjectName mxbeanName = new ObjectName( + "Hadoop:service=NameNode,name=NameNodeStatus"); + + // Get attribute "NNRole" + String nnRole = (String)mbs.getAttribute(mxbeanName, "NNRole"); + Assert.assertEquals(nn.getNNRole(), nnRole); + + // Get attribute "State" + String state = (String)mbs.getAttribute(mxbeanName, "State"); + Assert.assertEquals(nn.getState(), state); + + // Get attribute "HostAndPort" + String hostAndPort = (String)mbs.getAttribute(mxbeanName, "HostAndPort"); + Assert.assertEquals(nn.getHostAndPort(), hostAndPort); + + // Get attribute "SecurityEnabled" + boolean securityEnabled = (boolean)mbs.getAttribute(mxbeanName, + "SecurityEnabled"); + Assert.assertEquals(nn.isSecurityEnabled(), securityEnabled); + + // Get attribute "LastHATransitionTime" + long lastHATransitionTime = (long)mbs.getAttribute(mxbeanName, + "LastHATransitionTime"); + Assert.assertEquals(nn.getLastHATransitionTime(), lastHATransitionTime); + + // Get attribute "BytesWithFutureGenerationStamps" + long bytesWithFutureGenerationStamps = (long)mbs.getAttribute( + mxbeanName, "BytesWithFutureGenerationStamps"); + Assert.assertEquals(nn.getBytesWithFutureGenerationStamps(), + bytesWithFutureGenerationStamps); + + // Get attribute "SlowPeersReport" + String slowPeersReport = (String)mbs.getAttribute(mxbeanName, + "SlowPeersReport"); + Assert.assertEquals(nn.getSlowPeersReport(), slowPeersReport); + } finally { + if (cluster != null) { + cluster.shutdown(); + } + } + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org