Add Non-Managix Sample Local Cluster Scripts
Change-Id: I036fd27141721012d5c6486a73400678d824c741
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1023
Reviewed-by: Till Westmann <tillw@apache.org>
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-server/src/main/assembly/binary-assembly.xml b/asterixdb/asterix-server/src/main/assembly/binary-assembly.xml
index 85acd62..379a6f2 100644
--- a/asterixdb/asterix-server/src/main/assembly/binary-assembly.xml
+++ b/asterixdb/asterix-server/src/main/assembly/binary-assembly.xml
@@ -44,6 +44,7 @@
<outputDirectory>.</outputDirectory>
<includes>
<include>LICENSE*</include>
+ <include>samples/**</include>
</includes>
</fileSet>
<fileSet>
diff --git a/asterixdb/asterix-server/src/main/resources/samples/local/bin/start-sample-cluster.sh b/asterixdb/asterix-server/src/main/resources/samples/local/bin/start-sample-cluster.sh
new file mode 100755
index 0000000..eb26384
--- /dev/null
+++ b/asterixdb/asterix-server/src/main/resources/samples/local/bin/start-sample-cluster.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+# ----------------------------------------------------------------------------
+# Copyright 2001-2006 The Apache Software Foundation.
+#
+# 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.
+# ----------------------------------------------------------------------------
+#
+# Copyright (c) 2001-2006 The Apache Software Foundation. All rights
+# reserved.
+
+if [ -z "$JAVA_HOME" -a -x /usr/libexec/java_home ]; then
+ JAVA_HOME=$(/usr/libexec/java_home)
+ export JAVA_HOME
+fi
+
+[ -z "$JAVA_HOME" ] && {
+ echo "JAVA_HOME not set"
+ exit 1
+}
+"$JAVA_HOME/bin/java" -version || {
+ echo "JAVA_HOME not valid"
+ exit 2
+}
+
+DIRNAME=$(dirname $0)
+[ $(echo $DIRNAME | wc -l) -ne 1 ] && {
+ echo "Paths with spaces are not supported"
+ exit 3
+}
+
+CLUSTERDIR=$(cd $DIRNAME/..; echo $PWD)
+CBASDIR=$(cd $CLUSTERDIR/../..; echo $PWD)
+LOGSDIR=$CLUSTERDIR/logs
+
+echo "CLUSTERDIR=$CLUSTERDIR"
+echo "CBASDIR=$CBASDIR"
+
+cd $CLUSTERDIR
+mkdir -p $LOGSDIR
+
+(
+ echo "--------------------------"
+ date
+ echo "--------------------------"
+) | tee -a $LOGSDIR/blue-service.log | tee -a $LOGSDIR/red-service.log >> $LOGSDIR/cc.log
+
+$CBASDIR/bin/asterixncservice -logdir - -config-file $CLUSTERDIR/conf/blue.conf >> $LOGSDIR/blue-service.log 2>&1 &
+$CBASDIR/bin/asterixncservice -logdir - >> $LOGSDIR/red-service.log 2>&1 &
+$CBASDIR/bin/asterixcc -config-file $CLUSTERDIR/conf/cc.conf >> $LOGSDIR/cc.log 2>&1 &
+
+echo -n "Waiting for cluster to start."
+while [ 1 ]; do
+ curl -s -o /dev/null http://localhost:19002 && break
+ echo -n "."
+ sleep 1s
+done
+echo ".done"
+echo
+echo "See output in $LOGSDIR/"
diff --git a/asterixdb/asterix-server/src/main/resources/samples/local/bin/stop-sample-cluster.sh b/asterixdb/asterix-server/src/main/resources/samples/local/bin/stop-sample-cluster.sh
new file mode 100755
index 0000000..4a64553
--- /dev/null
+++ b/asterixdb/asterix-server/src/main/resources/samples/local/bin/stop-sample-cluster.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+# ----------------------------------------------------------------------------
+# Copyright 2001-2006 The Apache Software Foundation.
+#
+# 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.
+# ----------------------------------------------------------------------------
+#
+# Copyright (c) 2001-2006 The Apache Software Foundation. All rights
+# reserved.
+
+if [ -z "$JAVA_HOME" -a -x /usr/libexec/java_home ]; then
+ JAVA_HOME=$(/usr/libexec/java_home)
+ export JAVA_HOME
+fi
+
+[ -z "$JAVA_HOME" ] && {
+ echo "JAVA_HOME not set"
+ exit 1
+}
+"$JAVA_HOME/bin/java" -version || {
+ echo "JAVA_HOME not valid"
+ exit 2
+}
+
+curl -X POST http://localhost:19002/admin/shutdown
+$JAVA_HOME/bin/jps | awk '/NCService/ { print $1 }' | xargs kill
+echo
+echo -n "Waiting for CCDriver to terminate."
+while [ -n "$($JAVA_HOME/bin/jps | awk '/CCDriver/')" ]; do
+ sleep 2s
+ echo -n .
+done
+echo ".done."
diff --git a/asterixdb/asterix-server/src/main/resources/samples/local/conf/blue.conf b/asterixdb/asterix-server/src/main/resources/samples/local/conf/blue.conf
new file mode 100644
index 0000000..1dcedc8
--- /dev/null
+++ b/asterixdb/asterix-server/src/main/resources/samples/local/conf/blue.conf
@@ -0,0 +1,2 @@
+[ncservice]
+port=9091
diff --git a/asterixdb/asterix-server/src/main/resources/samples/local/conf/cc.conf b/asterixdb/asterix-server/src/main/resources/samples/local/conf/cc.conf
new file mode 100644
index 0000000..9fadb37
--- /dev/null
+++ b/asterixdb/asterix-server/src/main/resources/samples/local/conf/cc.conf
@@ -0,0 +1,18 @@
+[nc/red]
+txnlogdir=data/red/txnlog
+coredumpdir=data/red/coredump
+iodevices=data/red
+
+[nc/blue]
+port=9091
+txnlogdir=data/blue/txnlog
+coredumpdir=data/blue/coredump
+iodevices=data/blue
+
+[nc]
+storagedir=storage
+address=127.0.0.1
+command=asterixnc
+
+[cc]
+cluster.address = 127.0.0.1