You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whirr.apache.org by to...@apache.org on 2011/06/08 06:54:43 UTC
svn commit: r1133249 - in /incubator/whirr/trunk: ./ cli/ recipes/
services/hama/ services/hama/src/ services/hama/src/main/
services/hama/src/main/java/ services/hama/src/main/java/org/
services/hama/src/main/java/org/apache/ services/hama/src/main/ja...
Author: tomwhite
Date: Wed Jun 8 04:54:42 2011
New Revision: 1133249
URL: http://svn.apache.org/viewvc?rev=1133249&view=rev
Log:
WHIRR-313. Add Hama as a Service. Contributed by Edward J. Yoon.
Added:
incubator/whirr/trunk/recipes/hama-ec2.properties (with props)
incubator/whirr/trunk/services/hama/ (with props)
incubator/whirr/trunk/services/hama/pom.xml (with props)
incubator/whirr/trunk/services/hama/src/
incubator/whirr/trunk/services/hama/src/main/
incubator/whirr/trunk/services/hama/src/main/java/
incubator/whirr/trunk/services/hama/src/main/java/org/
incubator/whirr/trunk/services/hama/src/main/java/org/apache/
incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/
incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/
incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/
incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaCluster.java (with props)
incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaClusterActionHandler.java (with props)
incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaConstants.java (with props)
incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaGroomServerClusterActionHandler.java (with props)
incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaMasterClusterActionHandler.java (with props)
incubator/whirr/trunk/services/hama/src/main/resources/
incubator/whirr/trunk/services/hama/src/main/resources/META-INF/
incubator/whirr/trunk/services/hama/src/main/resources/META-INF/services/
incubator/whirr/trunk/services/hama/src/main/resources/META-INF/services/org.apache.whirr.service.ClusterActionHandler
incubator/whirr/trunk/services/hama/src/main/resources/functions/
incubator/whirr/trunk/services/hama/src/main/resources/functions/configure_hama.sh (with props)
incubator/whirr/trunk/services/hama/src/main/resources/functions/install_hama.sh (with props)
incubator/whirr/trunk/services/hama/src/main/resources/functions/start_hama.sh (with props)
incubator/whirr/trunk/services/hama/src/main/resources/whirr-hama-default.properties (with props)
incubator/whirr/trunk/services/hama/src/test/
incubator/whirr/trunk/services/hama/src/test/java/
incubator/whirr/trunk/services/hama/src/test/java/org/
incubator/whirr/trunk/services/hama/src/test/java/org/apache/
incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/
incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/
incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/
incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/integration/
incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/integration/HamaServiceController.java (with props)
incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/integration/HamaServiceTest.java (with props)
incubator/whirr/trunk/services/hama/src/test/resources/
incubator/whirr/trunk/services/hama/src/test/resources/whirr-hama-test.properties (with props)
Modified:
incubator/whirr/trunk/CHANGES.txt
incubator/whirr/trunk/cli/pom.xml
incubator/whirr/trunk/pom.xml
Modified: incubator/whirr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/CHANGES.txt?rev=1133249&r1=1133248&r2=1133249&view=diff
==============================================================================
--- incubator/whirr/trunk/CHANGES.txt (original)
+++ incubator/whirr/trunk/CHANGES.txt Wed Jun 8 04:54:42 2011
@@ -2,6 +2,10 @@ Apache Whirr Change Log
Trunk (unreleased changes)
+ NEW FEATURES
+
+ WHIRR-313. Add Hama as a Service. (Edward J. Yoon via tomwhite)
+
IMPROVEMENTS
WHIRR-28. Add examples module (asavu)
Modified: incubator/whirr/trunk/cli/pom.xml
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/cli/pom.xml?rev=1133249&r1=1133248&r2=1133249&view=diff
==============================================================================
--- incubator/whirr/trunk/cli/pom.xml (original)
+++ incubator/whirr/trunk/cli/pom.xml Wed Jun 8 04:54:42 2011
@@ -70,6 +70,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>whirr-hama</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-compute</artifactId>
</dependency>
Modified: incubator/whirr/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/pom.xml?rev=1133249&r1=1133248&r2=1133249&view=diff
==============================================================================
--- incubator/whirr/trunk/pom.xml (original)
+++ incubator/whirr/trunk/pom.xml Wed Jun 8 04:54:42 2011
@@ -47,6 +47,7 @@
<module>services/hbase</module>
<module>services/voldemort</module>
<module>services/elasticsearch</module>
+ <module>services/hama</module>
</modules>
<properties>
Added: incubator/whirr/trunk/recipes/hama-ec2.properties
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/recipes/hama-ec2.properties?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/recipes/hama-ec2.properties (added)
+++ incubator/whirr/trunk/recipes/hama-ec2.properties Wed Jun 8 04:54:42 2011
@@ -0,0 +1,48 @@
+#
+# 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.
+#
+
+#
+# Hama Cluster on AWS EC2
+#
+
+# Read the Configuration Guide for more info:
+# http://incubator.apache.org/whirr/configuration-guide.html
+
+# Change the cluster name here
+whirr.cluster-name=hama
+
+# Change the number of machines in the cluster here
+whirr.instance-templates=1 zookeeper+hadoop-namenode+hadoop-jobtracker+hama-master,5 hadoop-datanode+hadoop-tasktracker+hama-groomserver
+
+# For EC2 set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.
+whirr.provider=aws-ec2
+whirr.identity=${env:AWS_ACCESS_KEY_ID}
+whirr.credential=${env:AWS_SECRET_ACCESS_KEY}
+
+# The size of the instance to use. See http://aws.amazon.com/ec2/instance-types/
+whirr.hardware-id=c1.xlarge
+# Ubuntu 10.04 LTS Lucid. See http://alestic.com/
+whirr.image-id=us-east-1/ami-da0cf8b3
+# If you choose a different location, make sure whirr.image-id is updated too
+whirr.location-id=us-east-1
+
+# By default use the user system SSH keys. Override them here.
+# whirr.private-key-file=${sys:user.home}/.ssh/id_rsa
+# whirr.public-key-file=${whirr.private-key-file}.pub
+
+# Expert: specify the version of Hama to install.
+#whirr.hama.tarball.url=http://archive.apache.org/dist/incubator/hama/0.2-incubating/hama-0.2.0.tar.gz
Propchange: incubator/whirr/trunk/recipes/hama-ec2.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/whirr/trunk/services/hama/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jun 8 04:54:42 2011
@@ -0,0 +1,4 @@
+.project
+.classpath
+.settings
+target
Added: incubator/whirr/trunk/services/hama/pom.xml
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/pom.xml?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/pom.xml (added)
+++ incubator/whirr/trunk/services/hama/pom.xml Wed Jun 8 04:54:42 2011
@@ -0,0 +1,129 @@
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.whirr</groupId>
+ <artifactId>whirr</artifactId>
+ <version>0.6.0-incubating-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <groupId>org.apache.whirr</groupId>
+ <artifactId>whirr-hama</artifactId>
+ <packaging>jar</packaging>
+ <version>0.6.0-incubating-SNAPSHOT</version>
+ <name>Apache Whirr Hama</name>
+ <properties>
+ <hadoop.version>0.20.2</hadoop.version>
+ <hama.version>0.2.0-incubating</hama.version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>whirr-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>whirr-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hama</groupId>
+ <artifactId>hama</artifactId>
+ <version>${hama.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hama</groupId>
+ <artifactId>hama-examples</artifactId>
+ <version>${hama.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>whirr-hadoop</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>whirr-zookeeper</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jclouds</groupId>
+ <artifactId>jclouds-compute</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jclouds</groupId>
+ <artifactId>jclouds-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jclouds.driver</groupId>
+ <artifactId>jclouds-jsch</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jclouds.driver</groupId>
+ <artifactId>jclouds-log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-all</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-core</artifactId>
+ <version>${hadoop.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>zookeeper</artifactId>
+ <version>3.3.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Propchange: incubator/whirr/trunk/services/hama/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaCluster.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaCluster.java?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaCluster.java (added)
+++ incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaCluster.java Wed Jun 8 04:54:42 2011
@@ -0,0 +1,33 @@
+/**
+ * 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.whirr.service.hama;
+
+import java.io.IOException;
+import java.net.InetAddress;
+
+import org.apache.whirr.Cluster;
+import org.apache.whirr.RolePredicates;
+
+public class HamaCluster {
+ public static InetAddress getMasterPublicAddress(Cluster cluster)
+ throws IOException {
+ return cluster.getInstanceMatching(
+ RolePredicates.role(HamaMasterClusterActionHandler.ROLE))
+ .getPublicAddress();
+ }
+}
Propchange: incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaCluster.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaClusterActionHandler.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaClusterActionHandler.java?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaClusterActionHandler.java (added)
+++ incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaClusterActionHandler.java Wed Jun 8 04:54:42 2011
@@ -0,0 +1,61 @@
+/**
+ * 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.whirr.service.hama;
+
+import static org.jclouds.scriptbuilder.domain.Statements.call;
+
+import java.io.IOException;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.whirr.ClusterSpec;
+import org.apache.whirr.service.ClusterActionEvent;
+import org.apache.whirr.service.ClusterActionHandlerSupport;
+
+/**
+ * Base class for Hama service handlers.
+ */
+public abstract class HamaClusterActionHandler extends
+ ClusterActionHandlerSupport {
+
+ /**
+ * Returns a composite configuration that is made up from the global
+ * configuration coming from the Whirr core with a hama defaults properties.
+ */
+ protected synchronized Configuration getConfiguration(ClusterSpec clusterSpec)
+ throws IOException {
+ return getConfiguration(clusterSpec, HamaConstants.HAMA_DEFAULT_PROPERTIES);
+ }
+
+ protected void beforeBootstrap(ClusterActionEvent event) throws IOException {
+ ClusterSpec clusterSpec = event.getClusterSpec();
+
+ addStatement(event, call("configure_hostnames",
+ HamaConstants.PARAM_PROVIDER, clusterSpec.getProvider()));
+ addStatement(event, call("install_java"));
+ addStatement(event, call("install_tarball"));
+
+ String hamaInstallFunction = getConfiguration(clusterSpec).getString(
+ HamaConstants.KEY_INSTALL_FUNCTION, HamaConstants.FUNCTION_INSTALL);
+
+ String tarurl = prepareRemoteFileUrl(event, getConfiguration(clusterSpec)
+ .getString(HamaConstants.KEY_TARBALL_URL));
+
+ addStatement(event, call(hamaInstallFunction, HamaConstants.PARAM_PROVIDER,
+ clusterSpec.getProvider(), HamaConstants.PARAM_TARBALL_URL, tarurl));
+ }
+}
Propchange: incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaClusterActionHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaConstants.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaConstants.java?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaConstants.java (added)
+++ incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaConstants.java Wed Jun 8 04:54:42 2011
@@ -0,0 +1,40 @@
+/**
+ * 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.whirr.service.hama;
+
+public class HamaConstants {
+ public static final String FILE_HAMA_SITE_XML = "hama-site.xml";
+ public static final String HAMA_DEFAULT_PROPERTIES = "whirr-hama-default.properties";
+
+ public static final String KEY_INSTALL_FUNCTION = "whirr.hama.install-function";
+ public static final String KEY_CONFIGURE_FUNCTION = "whirr.hama.configure-function";
+ public static final String KEY_TARBALL_URL = "whirr.hama.tarball.url";
+ public static final String KEY_START_FUNCTION = "whirr.hama.start-function";
+
+ public static final String FUNCTION_INSTALL = "install_hama";
+ public static final String FUNCTION_POST_CONFIGURE = "configure_hama";
+ public static final String FUNCTION_START = "start_hama";
+
+ public static final String PARAM_PROVIDER = "-c";
+ public static final String PARAM_MASTER = "-m";
+ public static final String PARAM_QUORUM = "-q";
+ public static final String PARAM_TARBALL_URL = "-u";
+
+ public static final String PROP_HAMA_ZOOKEEPER_QUORUM = "hama.zookeeper.quorum";
+ public static final String PROP_HAMA_ZOOKEEPER_CLIENTPORT = "zookeeper.client.port";
+}
Propchange: incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaGroomServerClusterActionHandler.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaGroomServerClusterActionHandler.java?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaGroomServerClusterActionHandler.java (added)
+++ incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaGroomServerClusterActionHandler.java Wed Jun 8 04:54:42 2011
@@ -0,0 +1,78 @@
+/**
+ * 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.whirr.service.hama;
+
+import static org.apache.whirr.RolePredicates.role;
+import static org.jclouds.scriptbuilder.domain.Statements.call;
+
+import java.io.IOException;
+import java.net.InetAddress;
+
+import org.apache.whirr.Cluster;
+import org.apache.whirr.Cluster.Instance;
+import org.apache.whirr.ClusterSpec;
+import org.apache.whirr.service.ClusterActionEvent;
+import org.apache.whirr.service.FirewallManager.Rule;
+import org.apache.whirr.service.zookeeper.ZooKeeperCluster;
+
+public class HamaGroomServerClusterActionHandler extends
+ HamaClusterActionHandler {
+ public static final String ROLE = "hama-groomserver";
+ public static final int GROOMSERVER_PORT = 50000;
+
+ @Override
+ public String getRole() {
+ return ROLE;
+ }
+
+ @Override
+ protected void beforeConfigure(ClusterActionEvent event) throws IOException,
+ InterruptedException {
+ ClusterSpec clusterSpec = event.getClusterSpec();
+ Cluster cluster = event.getCluster();
+
+ Instance instance = cluster
+ .getInstanceMatching(role(HamaMasterClusterActionHandler.ROLE));
+ InetAddress masterPublicAddress = instance.getPublicAddress();
+
+ event.getFirewallManager().addRules(
+ Rule.create().destination(instance).ports(61000, GROOMSERVER_PORT));
+
+ String hamaConfigureFunction = getConfiguration(clusterSpec).getString(
+ HamaConstants.KEY_CONFIGURE_FUNCTION,
+ HamaConstants.FUNCTION_POST_CONFIGURE);
+
+ String master = masterPublicAddress.getHostName();
+ String quorum = ZooKeeperCluster.getHosts(cluster);
+ quorum = quorum.split(":")[0];
+
+ String tarurl = prepareRemoteFileUrl(event, getConfiguration(clusterSpec)
+ .getString(HamaConstants.KEY_TARBALL_URL));
+
+ addStatement(event, call(hamaConfigureFunction, ROLE,
+ HamaConstants.PARAM_MASTER, master, HamaConstants.PARAM_QUORUM, quorum,
+ HamaConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
+ HamaConstants.PARAM_TARBALL_URL, tarurl));
+
+ String hamaStartFunction = getConfiguration(clusterSpec).getString(
+ HamaConstants.KEY_START_FUNCTION, HamaConstants.FUNCTION_START);
+
+ addStatement(event, call(hamaStartFunction, ROLE,
+ HamaConstants.PARAM_TARBALL_URL, tarurl));
+ }
+}
Propchange: incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaGroomServerClusterActionHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaMasterClusterActionHandler.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaMasterClusterActionHandler.java?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaMasterClusterActionHandler.java (added)
+++ incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaMasterClusterActionHandler.java Wed Jun 8 04:54:42 2011
@@ -0,0 +1,178 @@
+/**
+ * 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.whirr.service.hama;
+
+import static org.apache.whirr.RolePredicates.role;
+import static org.jclouds.scriptbuilder.domain.Statements.call;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.Properties;
+import java.util.Map.Entry;
+
+import org.apache.whirr.Cluster;
+import org.apache.whirr.ClusterSpec;
+import org.apache.whirr.Cluster.Instance;
+import org.apache.whirr.service.ClusterActionEvent;
+import org.apache.whirr.service.FirewallManager.Rule;
+import org.apache.whirr.service.hadoop.HadoopProxy;
+import org.apache.whirr.service.zookeeper.ZooKeeperCluster;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Joiner;
+import com.google.common.io.Files;
+
+public class HamaMasterClusterActionHandler extends HamaClusterActionHandler {
+ private static final Logger LOG = LoggerFactory
+ .getLogger(HamaMasterClusterActionHandler.class);
+
+ public static final String ROLE = "hama-master";
+ public static final int MASTER_PORT = 40000;
+
+ @Override
+ public String getRole() {
+ return ROLE;
+ }
+
+ @Override
+ protected void beforeConfigure(ClusterActionEvent event) throws IOException,
+ InterruptedException {
+ ClusterSpec clusterSpec = event.getClusterSpec();
+ Cluster cluster = event.getCluster();
+
+ LOG.info("Authorizing firewall");
+ Instance instance = cluster.getInstanceMatching(role(ROLE));
+ InetAddress masterPublicAddress = instance.getPublicAddress();
+
+ event.getFirewallManager().addRules(
+ Rule.create().destination(instance).ports(MASTER_PORT));
+
+ String hamaConfigureFunction = getConfiguration(clusterSpec).getString(
+ HamaConstants.KEY_CONFIGURE_FUNCTION,
+ HamaConstants.FUNCTION_POST_CONFIGURE);
+
+ String master = masterPublicAddress.getHostName();
+ String quorum = ZooKeeperCluster.getHosts(cluster);
+ quorum = quorum.split(":")[0];
+
+ String tarurl = prepareRemoteFileUrl(event, getConfiguration(clusterSpec)
+ .getString(HamaConstants.KEY_TARBALL_URL));
+
+ addStatement(event, call(hamaConfigureFunction, ROLE,
+ HamaConstants.PARAM_MASTER, master, HamaConstants.PARAM_QUORUM, quorum,
+ HamaConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
+ HamaConstants.PARAM_TARBALL_URL, tarurl));
+
+ String hamaStartFunction = getConfiguration(clusterSpec).getString(
+ HamaConstants.KEY_START_FUNCTION, HamaConstants.FUNCTION_START);
+
+ addStatement(event, call(hamaStartFunction, ROLE,
+ HamaConstants.PARAM_TARBALL_URL, tarurl));
+ }
+
+ @Override
+ protected void afterConfigure(ClusterActionEvent event) throws IOException {
+ ClusterSpec clusterSpec = event.getClusterSpec();
+ Cluster cluster = event.getCluster();
+
+ LOG.info("Completed configuration of {}", clusterSpec.getClusterName());
+ Instance instance = cluster.getInstanceMatching(role(ROLE));
+ InetAddress masterPublicAddress = instance.getPublicAddress();
+
+ String quorum = ZooKeeperCluster.getHosts(cluster);
+ quorum = quorum.split(":")[0];
+ Properties config = createClientSideProperties(masterPublicAddress, quorum);
+ createClientSideHadoopSiteFile(clusterSpec, config);
+ createProxyScript(clusterSpec, cluster);
+ event.setCluster(new Cluster(cluster.getInstances(), config));
+ }
+
+ private Properties createClientSideProperties(InetAddress master,
+ String quorum) throws IOException {
+ Properties config = new Properties();
+ config.setProperty(HamaConstants.PROP_HAMA_ZOOKEEPER_QUORUM, quorum);
+ config.setProperty(HamaConstants.PROP_HAMA_ZOOKEEPER_CLIENTPORT, "2181");
+
+ config.setProperty("bsp.master.address", master.getHostName() + ":"
+ + MASTER_PORT);
+ config.setProperty("hadoop.socks.server", "localhost:6666");
+ config.setProperty("hadoop.rpc.socket.factory.class.default",
+ "org.apache.hadoop.net.SocksSocketFactory");
+ config.setProperty("hadoop.rpc.socket.factory.class.JobSubmissionProtocol",
+ "org.apache.hadoop.net.StandardSocketFactory");
+
+ return config;
+ }
+
+ private void createClientSideHadoopSiteFile(ClusterSpec clusterSpec,
+ Properties config) {
+ File configDir = getConfigDir(clusterSpec);
+ File hamaSiteFile = new File(configDir, HamaConstants.FILE_HAMA_SITE_XML);
+ try {
+ Files.write(generateHamaConfigurationFile(config), hamaSiteFile,
+ Charsets.UTF_8);
+ LOG.info("Wrote Hama site file {}", hamaSiteFile);
+ } catch (IOException e) {
+ LOG.error("Problem writing Hama site file {}", hamaSiteFile, e);
+ }
+ }
+
+ private File getConfigDir(ClusterSpec clusterSpec) {
+ File configDir = new File(new File(System.getProperty("user.home")),
+ ".whirr");
+ configDir = new File(configDir, clusterSpec.getClusterName());
+ configDir.mkdirs();
+ return configDir;
+ }
+
+ private CharSequence generateHamaConfigurationFile(Properties config) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("<?xml version=\"1.0\"?>\n");
+ sb
+ .append("<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>\n");
+ sb.append("<configuration>\n");
+ for (Entry<Object, Object> entry : config.entrySet()) {
+ sb.append(" <property>\n");
+ sb.append(" <name>").append(entry.getKey()).append("</name>\n");
+ sb.append(" <value>").append(entry.getValue()).append("</value>\n");
+ sb.append(" </property>\n");
+ }
+ sb.append("</configuration>\n");
+ return sb;
+ }
+
+ private void createProxyScript(ClusterSpec clusterSpec, Cluster cluster) {
+ File configDir = getConfigDir(clusterSpec);
+ File hamaProxyFile = new File(configDir, "hama-proxy.sh");
+ try {
+ HadoopProxy proxy = new HadoopProxy(clusterSpec, cluster);
+ InetAddress master = HamaCluster.getMasterPublicAddress(cluster);
+ String script = String.format(
+ "echo 'Running proxy to Hama cluster at %s. "
+ + "Use Ctrl-c to quit.'\n", master.getHostName())
+ + Joiner.on(" ").join(proxy.getProxyCommand());
+ Files.write(script, hamaProxyFile, Charsets.UTF_8);
+ LOG.info("Wrote Hama proxy script {}", hamaProxyFile);
+ } catch (IOException e) {
+ LOG.error("Problem writing Hama proxy script {}", hamaProxyFile, e);
+ }
+ }
+}
Propchange: incubator/whirr/trunk/services/hama/src/main/java/org/apache/whirr/service/hama/HamaMasterClusterActionHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/whirr/trunk/services/hama/src/main/resources/META-INF/services/org.apache.whirr.service.ClusterActionHandler
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/src/main/resources/META-INF/services/org.apache.whirr.service.ClusterActionHandler?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/src/main/resources/META-INF/services/org.apache.whirr.service.ClusterActionHandler (added)
+++ incubator/whirr/trunk/services/hama/src/main/resources/META-INF/services/org.apache.whirr.service.ClusterActionHandler Wed Jun 8 04:54:42 2011
@@ -0,0 +1,13 @@
+# Licensed 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.
+org.apache.whirr.service.hama.HamaMasterClusterActionHandler
+org.apache.whirr.service.hama.HamaGroomServerClusterActionHandler
\ No newline at end of file
Added: incubator/whirr/trunk/services/hama/src/main/resources/functions/configure_hama.sh
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/src/main/resources/functions/configure_hama.sh?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/src/main/resources/functions/configure_hama.sh (added)
+++ incubator/whirr/trunk/services/hama/src/main/resources/functions/configure_hama.sh Wed Jun 8 04:54:42 2011
@@ -0,0 +1,140 @@
+#
+# 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.
+#
+function configure_hama() {
+ local OPTIND
+ local OPTARG
+
+ ROLES=$1
+ shift
+
+ # get parameters
+ MASTER_HOST=
+ ZOOKEEKER_QUORUM=
+ PORT=
+ CLOUD_PROVIDER=
+ HAMA_TAR_URL=
+ while getopts "m:q:c:u:" OPTION; do
+ case $OPTION in
+ m)
+ MASTER_HOST="$OPTARG"
+ ;;
+ q)
+ ZOOKEEPER_QUORUM="$OPTARG"
+ ;;
+ c)
+ CLOUD_PROVIDER="$OPTARG"
+ ;;
+ u)
+ HAMA_TAR_URL="$OPTARG"
+ ;;
+ esac
+ done
+
+ # determine machine name
+ case $CLOUD_PROVIDER in
+ ec2 | aws-ec2 )
+ # Use public hostname for EC2
+ SELF_HOST=`wget -q -O - http://169.254.169.254/latest/meta-data/public-hostname`
+ ;;
+ *)
+ SELF_HOST=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
+ ;;
+ esac
+
+ # assign default URL if no other given (optional)
+ HAMA_TAR_URL=${HAMA_TAR_URL:-http://archive.apache.org/dist/incubator/hama/0.2-incubating/hama-0.2.0.tar.gz}
+ # derive details from the URL
+ HAMA_TAR_FILE=${HAMA_TAR_URL##*/}
+
+ HAMA_VERSION=${HAMA_TAR_FILE%.tar.gz}
+
+ HAMA_HOME=/usr/local/$HAMA_VERSION
+ HAMA_CONF_DIR=$HAMA_HOME/conf
+
+ case $CLOUD_PROVIDER in
+ ec2 | aws-ec2 )
+ MOUNT=/mnt
+ ;;
+ *)
+ MOUNT=/data
+ ;;
+ esac
+
+ mkdir -p $MOUNT/hama
+ chown hadoop:hadoop $MOUNT/hama
+ if [ ! -e $MOUNT/tmp ]; then
+ mkdir $MOUNT/tmp
+ chmod a+rwxt $MOUNT/tmp
+ fi
+ mkdir /etc/hama
+ ln -s $HAMA_CONF_DIR /etc/hama/conf
+
+ ##############################################################################
+ # Modify this section to customize your Hama cluster.
+ ##############################################################################
+ cat > $HAMA_CONF_DIR/hama-site.xml <<EOF
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<configuration>
+<property>
+ <name>bsp.master.address</name>
+ <value>$MASTER_HOST:40000</value>
+</property>
+<property>
+ <name>fs.default.name</name>
+ <value>hdfs://$MASTER_HOST:8020/</value>
+</property>
+<property>
+ <name>hama.zookeeper.quorum</name>
+ <value>$ZOOKEEPER_QUORUM</value>
+</property>
+<property>
+ <name>zookeeper.client.port</name>
+ <value>2181</value>
+</property>
+</configuration>
+EOF
+
+ # override JVM options
+ cat >> $HAMA_CONF_DIR/hama-env.sh <<EOF
+export HAMA_MASTER_OPTS="-Xms1000m -Xmx1000m -Xmn256m -XX:+UseConcMarkSweepGC -XX:+AggressiveOpts -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:/mnt/hama/logs/hama-master-gc.log"
+export HAMA_GROOMSERVER_OPTS="-Xms2000m -Xmx2000m -Xmn256m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=88 -XX:+AggressiveOpts -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:/mnt/hama/logs/hama-groomserver-gc.log"
+EOF
+
+ # keep PID files in a non-temporary directory
+ sed -i -e "s|# export HAMA_PID_DIR=.*|export HAMA_PID_DIR=/var/run/hama|" \
+ $HAMA_CONF_DIR/hama-env.sh
+ mkdir -p /var/run/hama
+ chown -R hadoop:hadoop /var/run/hama
+
+ # set SSH options within the cluster
+ sed -i -e 's|# export HAMA_SSH_OPTS=.*|export HAMA_SSH_OPTS="-o StrictHostKeyChecking=no"|' \
+ $HAMA_CONF_DIR/hama-env.sh
+
+ # disable IPv6
+ sed -i -e 's|# export HAMA_OPTS=.*|export HAMA_OPTS="-Djava.net.preferIPv4Stack=true"|' \
+ $HAMA_CONF_DIR/hama-env.sh
+
+ # hama logs should be on the /mnt partition
+ sed -i -e 's|# export HAMA_LOG_DIR=.*|export HAMA_LOG_DIR=/var/log/hama/logs|' \
+ $HAMA_CONF_DIR/hama-env.sh
+ rm -rf /var/log/hama
+ mkdir $MOUNT/hama/logs
+ chown hadoop:hadoop $MOUNT/hama/logs
+ ln -s $MOUNT/hama/logs /var/log/hama
+ chown -R hadoop:hadoop /var/log/hama
+}
Propchange: incubator/whirr/trunk/services/hama/src/main/resources/functions/configure_hama.sh
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/whirr/trunk/services/hama/src/main/resources/functions/install_hama.sh
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/src/main/resources/functions/install_hama.sh?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/src/main/resources/functions/install_hama.sh (added)
+++ incubator/whirr/trunk/services/hama/src/main/resources/functions/install_hama.sh Wed Jun 8 04:54:42 2011
@@ -0,0 +1,67 @@
+#
+# 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.
+#
+function update_repo() {
+ if which dpkg &> /dev/null; then
+ sudo apt-get update
+ elif which rpm &> /dev/null; then
+ yum update -y yum
+ fi
+}
+
+function install_hama() {
+ local OPTIND
+ local OPTARG
+
+ CLOUD_PROVIDER=
+ HAMA_TAR_URL=
+ while getopts "c:u:" OPTION; do
+ case $OPTION in
+ c)
+ CLOUD_PROVIDER="$OPTARG"
+ ;;
+ u)
+ HAMA_TAR_URL="$OPTARG"
+ ;;
+ esac
+ done
+
+ # assign default URL if no other given (optional)
+ HAMA_TAR_URL=${HAMA_TAR_URL:-http://archive.apache.org/dist/incubator/hama/0.2-incubating/hama-0.2.0.tar.gz}
+ # derive details from the URL
+ HAMA_TAR_FILE=${HAMA_TAR_URL##*/}
+ HAMA_TAR_MD5_FILE=$HAMA_TAR_FILE.md5
+
+ HAMA_VERSION=${HAMA_TAR_FILE%.tar.gz}
+
+ HAMA_HOME=/usr/local/$HAMA_VERSION
+ HAMA_CONF_DIR=$HAMA_HOME/conf
+
+ update_repo
+
+ if ! id hadoop &> /dev/null; then
+ useradd hadoop
+ fi
+
+ # if there is no hosts file then provide a minimal one
+ [ ! -f /etc/hosts ] && echo "127.0.0.1 localhost" > /etc/hosts
+
+ install_tarball $HAMA_TAR_URL
+
+ echo "export HAMA_HOME=$HAMA_HOME" >> ~root/.bashrc
+ echo 'export PATH=$JAVA_HOME/bin:$HAMA_HOME/bin:$PATH' >> ~root/.bashrc
+}
+
Propchange: incubator/whirr/trunk/services/hama/src/main/resources/functions/install_hama.sh
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/whirr/trunk/services/hama/src/main/resources/functions/start_hama.sh
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/src/main/resources/functions/start_hama.sh?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/src/main/resources/functions/start_hama.sh (added)
+++ incubator/whirr/trunk/services/hama/src/main/resources/functions/start_hama.sh Wed Jun 8 04:54:42 2011
@@ -0,0 +1,65 @@
+#
+# 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.
+#
+set -x
+function start_hama() {
+ local OPTIND
+ local OPTARG
+
+ ROLES=$1
+ shift
+
+ # get parameters
+ PORT=
+ HAMA_TAR_URL=
+ while getopts "u:" OPTION; do
+ case $OPTION in
+ u)
+ HAMA_TAR_URL="$OPTARG"
+ ;;
+ esac
+ done
+
+ # assign default URL if no other given (optional)
+ HAMA_TAR_URL=${HAMA_TAR_URL:-http://archive.apache.org/dist/incubator/hama/0.2-incubating/hama-0.2.0.tar.gz}
+ # derive details from the URL
+ HAMA_TAR_FILE=${HAMA_TAR_URL##*/}
+
+ HAMA_VERSION=${HAMA_TAR_FILE%.tar.gz}
+
+ HAMA_HOME=/usr/local/$HAMA_VERSION
+ HAMA_CONF_DIR=$HAMA_HOME/conf
+
+ for role in $(echo "$ROLES" | tr "," "\n"); do
+ case $role in
+ hama-master)
+ start_hama_daemon bspmaster
+ ;;
+ hama-groomserver)
+ start_hama_daemon groom
+ ;;
+ esac
+ done
+}
+
+function start_hama_daemon() {
+ if which dpkg &> /dev/null; then
+ AS_HADOOP="su -s /bin/bash - hadoop -c"
+ elif which rpm &> /dev/null; then
+ AS_HADOOP="/sbin/runuser -s /bin/bash - hadoop -c"
+ fi
+ $AS_HADOOP "$HAMA_HOME/bin/hama-daemon.sh start $1"
+}
Propchange: incubator/whirr/trunk/services/hama/src/main/resources/functions/start_hama.sh
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/whirr/trunk/services/hama/src/main/resources/whirr-hama-default.properties
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/src/main/resources/whirr-hama-default.properties?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/src/main/resources/whirr-hama-default.properties (added)
+++ incubator/whirr/trunk/services/hama/src/main/resources/whirr-hama-default.properties Wed Jun 8 04:54:42 2011
@@ -0,0 +1,13 @@
+# Licensed 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.
+
+whirr.hama.tarball.url=http://archive.apache.org/dist/incubator/hama/0.2-incubating/hama-0.2.0.tar.gz
\ No newline at end of file
Propchange: incubator/whirr/trunk/services/hama/src/main/resources/whirr-hama-default.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/integration/HamaServiceController.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/integration/HamaServiceController.java?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/integration/HamaServiceController.java (added)
+++ incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/integration/HamaServiceController.java Wed Jun 8 04:54:42 2011
@@ -0,0 +1,122 @@
+/**
+ * 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.whirr.service.hama.integration;
+
+import java.io.IOException;
+import java.util.Map.Entry;
+
+import org.apache.commons.configuration.CompositeConfiguration;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.hama.HamaConfiguration;
+import org.apache.whirr.Cluster;
+import org.apache.whirr.ClusterController;
+import org.apache.whirr.ClusterSpec;
+import org.apache.whirr.service.hadoop.HadoopProxy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.hama.bsp.BSPJobClient;
+import org.apache.hama.bsp.ClusterStatus;
+
+public class HamaServiceController {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(HamaServiceController.class);
+
+ private static final HamaServiceController INSTANCE = new HamaServiceController();
+
+ public static HamaServiceController getInstance() {
+ return INSTANCE;
+ }
+
+ private boolean running;
+ private ClusterSpec clusterSpec;
+ private ClusterController controller;
+ private HadoopProxy proxy;
+ private Cluster cluster;
+
+ private HamaServiceController() {
+ }
+
+ public synchronized boolean ensureClusterRunning() throws Exception {
+ if (running) {
+ LOG.info("Cluster already running.");
+ return false;
+ } else {
+ startup();
+ return true;
+ }
+ }
+
+ public synchronized void startup() throws Exception {
+ LOG.info("Starting up cluster...");
+ CompositeConfiguration config = new CompositeConfiguration();
+ if (System.getProperty("config") != null) {
+ config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
+ }
+ config.addConfiguration(new PropertiesConfiguration("whirr-hama-test.properties"));
+ clusterSpec = ClusterSpec.withTemporaryKeys(config);
+ controller = new ClusterController();
+
+ cluster = controller.launchCluster(clusterSpec);
+ proxy = new HadoopProxy(clusterSpec, cluster);
+ proxy.start();
+
+ HamaConfiguration conf = getConfiguration();
+ BSPJobClient client = new BSPJobClient(conf);
+ waitForGroomServers(client);
+
+ running = true;
+ }
+
+ private static void waitForGroomServers(BSPJobClient client) throws IOException {
+ while (true) {
+ ClusterStatus clusterStatus = client.getClusterStatus(true);
+ int grooms = clusterStatus.getGroomServers();
+ if (grooms > 0) {
+ LOG.info("{} groomservers reported in. Continuing.", grooms);
+ break;
+ }
+ try {
+ System.out.print(".");
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ break;
+ }
+ }
+ }
+
+ public HamaConfiguration getConfiguration() {
+ HamaConfiguration conf = new HamaConfiguration();
+ for (Entry<Object, Object> entry : cluster.getConfiguration().entrySet()) {
+ conf.set(entry.getKey().toString(), entry.getValue().toString());
+ }
+ return conf;
+ }
+
+ public synchronized void shutdown() throws IOException, InterruptedException {
+ LOG.info("Shutting down cluster...");
+ if (proxy != null) {
+ proxy.stop();
+ }
+ if (controller != null) {
+ controller.destroyCluster(clusterSpec);
+ }
+ running = false;
+ }
+}
Propchange: incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/integration/HamaServiceController.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/integration/HamaServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/integration/HamaServiceTest.java?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/integration/HamaServiceTest.java (added)
+++ incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/integration/HamaServiceTest.java Wed Jun 8 04:54:42 2011
@@ -0,0 +1,74 @@
+/**
+ * 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.whirr.service.hama.integration;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.hama.HamaConfiguration;
+import org.apache.hama.bsp.BSPJob;
+import org.apache.hama.bsp.BSPJobClient;
+import org.apache.hama.bsp.ClusterStatus;
+import org.apache.hama.examples.PiEstimator;
+import org.apache.hama.examples.PiEstimator.MyEstimator;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class HamaServiceTest {
+ private static HamaServiceController controller = HamaServiceController
+ .getInstance();
+ private static String masterTask = "master.task.";
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ controller.ensureClusterRunning();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ controller.shutdown();
+ }
+
+ @Test
+ public void test() throws Exception {
+ HamaConfiguration conf = controller.getConfiguration();
+
+ BSPJobClient jobClient = new BSPJobClient(conf);
+ ClusterStatus cluster = jobClient.getClusterStatus(true);
+ assertNotNull(cluster);
+ assertTrue(cluster.getGroomServers() > 0);
+
+ BSPJob bsp = new BSPJob(conf, PiEstimator.class);
+ // Set the job name
+ bsp.setJobName("Pi Estimation Example");
+ bsp.setBspClass(MyEstimator.class);
+ bsp.setNumBspTask(cluster.getGroomServers());
+
+ for (String peerName : cluster.getActiveGroomNames().values()) {
+ conf.set(masterTask, peerName);
+ break;
+ }
+
+ if (bsp.waitForCompletion(true)) {
+ assertEquals(jobClient.getAllJobs().length, 1);
+ }
+ }
+
+}
Propchange: incubator/whirr/trunk/services/hama/src/test/java/org/apache/whirr/service/hama/integration/HamaServiceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/whirr/trunk/services/hama/src/test/resources/whirr-hama-test.properties
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/hama/src/test/resources/whirr-hama-test.properties?rev=1133249&view=auto
==============================================================================
--- incubator/whirr/trunk/services/hama/src/test/resources/whirr-hama-test.properties (added)
+++ incubator/whirr/trunk/services/hama/src/test/resources/whirr-hama-test.properties Wed Jun 8 04:54:42 2011
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+whirr.cluster-name=hamaclustertest
+whirr.instance-templates=1 zookeeper,1 hadoop-namenode+hadoop-jobtracker+hama-master,1 hadoop-datanode+hadoop-tasktracker+hama-groomserver
+whirr.provider=${sys:whirr.test.provider}
+whirr.identity=${sys:whirr.test.identity}
+whirr.credential=${sys:whirr.test.credential}
+whirr.hama.tarball.url=http://archive.apache.org/dist/incubator/hama/0.2-incubating/hama-0.2.0.tar.gz
Propchange: incubator/whirr/trunk/services/hama/src/test/resources/whirr-hama-test.properties
------------------------------------------------------------------------------
svn:eol-style = native