Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 01DA717B57 for ; Mon, 6 Oct 2014 18:53:29 +0000 (UTC) Received: (qmail 19507 invoked by uid 500); 6 Oct 2014 18:53:28 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 19479 invoked by uid 500); 6 Oct 2014 18:53:28 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 19470 invoked by uid 99); 6 Oct 2014 18:53:28 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Oct 2014 18:53:28 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 571D3320FE5; Mon, 6 Oct 2014 18:53:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jaoki@apache.org To: commits@ambari.apache.org Message-Id: <3347bbf2f66a4f0c9df4c6ae1c8f91cc@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: AMBARI-7442 ServiceCheck cannot be run if there is only one stack definition (adenisso via jaoki) Date: Mon, 6 Oct 2014 18:53:28 +0000 (UTC) Repository: ambari Updated Branches: refs/heads/branch-1.7.0 5fbaece3d -> df0f496a7 AMBARI-7442 ServiceCheck cannot be run if there is only one stack definition (adenisso via jaoki) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/df0f496a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/df0f496a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/df0f496a Branch: refs/heads/branch-1.7.0 Commit: df0f496a71e5cc47d0e550eb027d5e3c0191d768 Parents: 5fbaece Author: Jun Aoki Authored: Mon Oct 6 11:52:59 2014 -0700 Committer: Jun Aoki Committed: Mon Oct 6 11:52:59 2014 -0700 ---------------------------------------------------------------------- .../server/api/util/StackExtensionHelper.java | 14 +- .../api/util/StackExtensionHelperTest.java | 27 +++ .../single_stack/ABC/1.0.0/metainfo.xml | 22 +++ .../ABC/1.0.0/services/HDFS/metainfo.xml | 193 +++++++++++++++++++ 4 files changed, 251 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/df0f496a/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java index 1c3f9a7..35ae9a7 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java @@ -490,11 +490,6 @@ public class StackExtensionHelper { } } - // add action for service check - if(serviceInfo.getCommandScript() != null) { - actionMetadata.addServiceCheckAction(serviceInfo.getName()); - } - } parentStack = currentStackInfo; } @@ -536,6 +531,7 @@ public class StackExtensionHelper { ParserConfigurationException, SAXException, XPathExpressionException, IOException, JAXBException { List services = new ArrayList(); + File servicesFolder = new File(stackRoot.getAbsolutePath() + File .separator + stackInfo.getName() + File.separator + stackInfo.getVersion() + File.separator + AmbariMetaInfo.SERVICES_FOLDER_NAME); @@ -602,6 +598,14 @@ public class StackExtensionHelper { } stackInfo.getServices().addAll(services); + + // add service check actions from the target stack + for(ServiceInfo serviceInfo : stackInfo.getServices()) { + if(serviceInfo.getCommandScript() != null) { + actionMetadata.addServiceCheckAction(serviceInfo.getName()); + } + } + } http://git-wip-us.apache.org/repos/asf/ambari/blob/df0f496a/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java index 7262dfb..84ba6aa 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java @@ -21,6 +21,7 @@ package org.apache.ambari.server.api.util; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; + import org.apache.ambari.server.api.services.AmbariMetaInfo; import org.apache.ambari.server.metadata.ActionMetadata; import org.apache.ambari.server.state.*; @@ -32,6 +33,7 @@ import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPathExpressionException; + import java.io.File; import java.io.IOException; import java.util.*; @@ -353,6 +355,31 @@ public class StackExtensionHelperTest { Map supports = config.get(keyword); supports.put(attributeName, value); } + + /** + * This test ensures the service status check is added into the action metadata when + * the stack has no parent and is the only stack in the stack family + * @throws Exception + */ + @Test + public void testGetServiceInfoFromSingleStack() throws Exception { + File stackRoot = new File("./src/test/resources/single_stack".replace("/", File.separator)); + StackExtensionHelper helper = new StackExtensionHelper(injector, stackRoot); + helper.fillInfo(); + List stackInfoList = helper.getAllAvailableStacks(); + assertEquals(1, stackInfoList.size()); + + List serviceInfoList = helper.getAllApplicableServices(stackInfoList.get(0)); + for(ServiceInfo serviceInfo: serviceInfoList) { + if ("HDFS".equalsIgnoreCase(serviceInfo.getName())) { + ActionMetadata actionMetadata = injector.getInstance(ActionMetadata.class); + String hdfsStatusCheckCmd = actionMetadata.getServiceCheckAction("HDFS"); + assertEquals("HDFS_SERVICE_CHECK", hdfsStatusCheckCmd); + break; + } + } + } + @Test public void testPopulateConfigTypes() throws XPathExpressionException, ParserConfigurationException, SAXException, IOException, JAXBException { StackExtensionHelper helper = getStackExtensionHelper(); http://git-wip-us.apache.org/repos/asf/ambari/blob/df0f496a/ambari-server/src/test/resources/single_stack/ABC/1.0.0/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/resources/single_stack/ABC/1.0.0/metainfo.xml b/ambari-server/src/test/resources/single_stack/ABC/1.0.0/metainfo.xml new file mode 100644 index 0000000..c00cf4d --- /dev/null +++ b/ambari-server/src/test/resources/single_stack/ABC/1.0.0/metainfo.xml @@ -0,0 +1,22 @@ + + + + + true + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/df0f496a/ambari-server/src/test/resources/single_stack/ABC/1.0.0/services/HDFS/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/resources/single_stack/ABC/1.0.0/services/HDFS/metainfo.xml b/ambari-server/src/test/resources/single_stack/ABC/1.0.0/services/HDFS/metainfo.xml new file mode 100644 index 0000000..c4aa8fb --- /dev/null +++ b/ambari-server/src/test/resources/single_stack/ABC/1.0.0/services/HDFS/metainfo.xml @@ -0,0 +1,193 @@ + + + + 2.0 + + + HDFS + Apache Hadoop Distributed File System + 2.1.0.2.0.5.0 + + + + NAMENODE + MASTER + 1 + + + PYTHON + 600 + + + + DECOMMISSION + + + PYTHON + 600 + + + + REBALANCEHDFS + true + + + PYTHON + + + + + + + + DATANODE + SLAVE + 1+ + + + PYTHON + 600 + + + + + SECONDARY_NAMENODE + + 1 + MASTER + + + PYTHON + 600 + + + + + HDFS_CLIENT + CLIENT + 0+ + + + PYTHON + 600 + + + + + JOURNALNODE + SLAVE + 0+ + + + PYTHON + 600 + + + + + ZKFC + SLAVE + + 0+ + + + PYTHON + 600 + + + + + + + any + + + hadoop + + + hadoop-lzo + + + + + + redhat5,redhat6,suse11 + + + snappy + + + snappy-devel + + + lzo + + + hadoop-lzo-native + + + hadoop-libhdfs + + + ambari-log4j + + + + + + ubuntu12 + + + libsnappy1 + + + libsnappy-dev + + + liblzo2-2 + + + hadoop-hdfs + + + libhdfs0 + + + libhdfs0-dev + + + + + + + + + PYTHON + 300 + + + + core-site + global + hdfs-site + hadoop-policy + hdfs-log4j + + + + \ No newline at end of file