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/05/13 06:46:40 UTC

svn commit: r1102561 - in /incubator/whirr/trunk: ./ services/voldemort/src/main/java/org/apache/whirr/service/voldemort/ services/voldemort/src/main/resources/functions/

Author: tomwhite
Date: Fri May 13 04:46:40 2011
New Revision: 1102561

URL: http://svn.apache.org/viewvc?rev=1102561&view=rev
Log:
WHIRR-296. Separate Voldemort install and configuration scripts into more generic functions. Contributed by asavu

Added:
    incubator/whirr/trunk/services/voldemort/src/main/resources/functions/cleanup_voldemort.sh   (with props)
    incubator/whirr/trunk/services/voldemort/src/main/resources/functions/start_voldemort.sh   (with props)
    incubator/whirr/trunk/services/voldemort/src/main/resources/functions/stop_voldemort.sh   (with props)
Modified:
    incubator/whirr/trunk/CHANGES.txt
    incubator/whirr/trunk/services/voldemort/src/main/java/org/apache/whirr/service/voldemort/VoldemortClusterActionHandler.java
    incubator/whirr/trunk/services/voldemort/src/main/resources/functions/configure_voldemort.sh
    incubator/whirr/trunk/services/voldemort/src/main/resources/functions/install_voldemort.sh

Modified: incubator/whirr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/CHANGES.txt?rev=1102561&r1=1102560&r2=1102561&view=diff
==============================================================================
--- incubator/whirr/trunk/CHANGES.txt (original)
+++ incubator/whirr/trunk/CHANGES.txt Fri May 13 04:46:40 2011
@@ -76,6 +76,9 @@ Trunk (unreleased changes)
     WHIRR-292. Separate Cassandra install and configuration scripts 
     into more generic functions (asavu)
 
+    WHIRR-296. Separate Voldemort install and configuration scripts into more
+    generic functions. (asavu via tomwhite)
+
   BUG FIXES
 
     WHIRR-253. ZooKeeper service should only authorize ingress to ZooKeeper 

Modified: incubator/whirr/trunk/services/voldemort/src/main/java/org/apache/whirr/service/voldemort/VoldemortClusterActionHandler.java
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/voldemort/src/main/java/org/apache/whirr/service/voldemort/VoldemortClusterActionHandler.java?rev=1102561&r1=1102560&r2=1102561&view=diff
==============================================================================
--- incubator/whirr/trunk/services/voldemort/src/main/java/org/apache/whirr/service/voldemort/VoldemortClusterActionHandler.java (original)
+++ incubator/whirr/trunk/services/voldemort/src/main/java/org/apache/whirr/service/voldemort/VoldemortClusterActionHandler.java Fri May 13 04:46:40 2011
@@ -82,6 +82,8 @@ public class VoldemortClusterActionHandl
     }
 
     addStatement(event, call("install_java"));
+    addStatement(event, call("install_service"));
+
     addStatement(event, call(FUNCTION_INSTALL, optArgs.toArray(new String[optArgs.size()])));
   }
 
@@ -109,6 +111,7 @@ public class VoldemortClusterActionHandl
                              PARAM_CLUSTER_NAME,
                              clusterSpec.getClusterName(),
                              servers));
+    addStatement(event, call("start_voldemort"));
   }
 
   @Override

Added: incubator/whirr/trunk/services/voldemort/src/main/resources/functions/cleanup_voldemort.sh
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/voldemort/src/main/resources/functions/cleanup_voldemort.sh?rev=1102561&view=auto
==============================================================================
--- incubator/whirr/trunk/services/voldemort/src/main/resources/functions/cleanup_voldemort.sh (added)
+++ incubator/whirr/trunk/services/voldemort/src/main/resources/functions/cleanup_voldemort.sh Fri May 13 04:46:40 2011
@@ -0,0 +1,26 @@
+#
+# 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 cleanup_voldemort() {
+    /etc/init.d/voldemort stop
+    remove_service voldemort
+
+    rm -rf /usr/local/voldemort
+    rm -rf /etc/voldemort
+    rm -f /var/log/voldemort.log
+}
+

Propchange: incubator/whirr/trunk/services/voldemort/src/main/resources/functions/cleanup_voldemort.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/whirr/trunk/services/voldemort/src/main/resources/functions/configure_voldemort.sh
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/voldemort/src/main/resources/functions/configure_voldemort.sh?rev=1102561&r1=1102560&r2=1102561&view=diff
==============================================================================
--- incubator/whirr/trunk/services/voldemort/src/main/resources/functions/configure_voldemort.sh (original)
+++ incubator/whirr/trunk/services/voldemort/src/main/resources/functions/configure_voldemort.sh Fri May 13 04:46:40 2011
@@ -39,10 +39,13 @@ function configure_voldemort() {
   # Use public IPs for all Voldemort nodes                                                                    
   case $CLOUD_PROVIDER in
     ec2)
-    SELF_HOST=`wget -q -O - http://169.254.169.254/latest/meta-data/local-ipv4`
+      SELF_HOST=`wget -q -O - http://169.254.169.254/latest/meta-data/local-ipv4`
+    ;;
+    cloudservers-uk | cloudservers-us)
+      SELF_HOST=`/sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
     ;;
     *)
-    SELF_HOST=`/sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
+      SELF_HOST=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
     ;;
   esac
   
@@ -79,13 +82,10 @@ function configure_voldemort() {
     echo "Missing server names"
     exit 1
   fi
-  
-  
+
   # Set up the cluster metadata
   chmod +x $VOLDEMORT_ROOT/contrib/ec2-testing/bin/run-class.sh
   chmod +x $VOLDEMORT_ROOT/contrib/ec2-testing/bin/voldemort-clustergenerator.sh
   $VOLDEMORT_ROOT/contrib/ec2-testing/bin/voldemort-clustergenerator.sh --useinternal true --clustername $CLUSTER_NAME --partitions $PARTITIONS_PER_NODE --hostnames $hostname_file > $VOLDEMORT_HOME/config/cluster.xml
   
-  # Start Voldemort
-  nohup /etc/rc.local &
 }

Modified: incubator/whirr/trunk/services/voldemort/src/main/resources/functions/install_voldemort.sh
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/voldemort/src/main/resources/functions/install_voldemort.sh?rev=1102561&r1=1102560&r2=1102561&view=diff
==============================================================================
--- incubator/whirr/trunk/services/voldemort/src/main/resources/functions/install_voldemort.sh (original)
+++ incubator/whirr/trunk/services/voldemort/src/main/resources/functions/install_voldemort.sh Fri May 13 04:46:40 2011
@@ -72,14 +72,49 @@ function install_voldemort() {
   # Set Voldemort vars
   echo "export VOLDEMORT_ROOT=$VOLDEMORT_ROOT" >> /etc/profile
   echo "export VOLDEMORT_HOME=$VOLDEMORT_HOME" >> /etc/profile
-    
-  # Start
-  sed -i -e "s/exit 0//" /etc/rc.local
-  sed -i -e "s/voldemort//" /etc/rc.local
-    
-  cat >> /etc/rc.local <<RC_LOCAL
-cd \$VOLDEMORT_ROOT
-./bin/voldemort-server.sh > /var/log/voldemort.log 2>&1 &
-cd -
-RC_LOCAL
+
+  cat >/etc/init.d/voldemort <<END_OF_FILE
+#!/bin/sh
+# description: Voldemort distributed database server
+
+. /etc/profile
+
+prog="voldemort-server.sh"
+
+start() {
+      echo "Starting Voldemort"
+      \${VOLDEMORT_ROOT}/bin/voldemort-server.sh >/var/log/voldemort.log 2>&1 &
+}
+
+stop() {
+      echo "Stopping Voldemort"
+      \${VOLDEMORT_ROOT}/bin/voldemort-stop.sh
+}
+
+restart(){
+      stop
+      start
+}
+
+case "\$1" in
+    start)
+          start
+          ;;
+    stop)
+          stop
+          ;;
+    restart)
+          restart
+          ;;
+    *)
+          echo "Usage: voldemort {start|stop|restart}"
+          exit 1
+esac
+
+exit 0
+END_OF_FILE
+
+    chmod +x /etc/init.d/voldemort
+    install_service voldemort
+
 }

Added: incubator/whirr/trunk/services/voldemort/src/main/resources/functions/start_voldemort.sh
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/voldemort/src/main/resources/functions/start_voldemort.sh?rev=1102561&view=auto
==============================================================================
--- incubator/whirr/trunk/services/voldemort/src/main/resources/functions/start_voldemort.sh (added)
+++ incubator/whirr/trunk/services/voldemort/src/main/resources/functions/start_voldemort.sh Fri May 13 04:46:40 2011
@@ -0,0 +1,21 @@
+#
+# 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 start_voldemort() {
+    /etc/init.d/voldemort start
+}
+

Propchange: incubator/whirr/trunk/services/voldemort/src/main/resources/functions/start_voldemort.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/whirr/trunk/services/voldemort/src/main/resources/functions/stop_voldemort.sh
URL: http://svn.apache.org/viewvc/incubator/whirr/trunk/services/voldemort/src/main/resources/functions/stop_voldemort.sh?rev=1102561&view=auto
==============================================================================
--- incubator/whirr/trunk/services/voldemort/src/main/resources/functions/stop_voldemort.sh (added)
+++ incubator/whirr/trunk/services/voldemort/src/main/resources/functions/stop_voldemort.sh Fri May 13 04:46:40 2011
@@ -0,0 +1,21 @@
+#
+# 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 stop_voldemort() {
+    /etc/init.d/voldemort stop
+}
+

Propchange: incubator/whirr/trunk/services/voldemort/src/main/resources/functions/stop_voldemort.sh
------------------------------------------------------------------------------
    svn:eol-style = native