Yingyi Bu has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1482

Change subject: Change "samples" to "opt" in the distribution package.
......................................................................

Change "samples" to "opt" in the distribution package.

This change also does the following things:
- make AWS script more robust: (1) can be run from anywhere,
  (2) eliminate the need of customize_deployment.yml.
- cleanup documentation to reflect the directory structure
  change.

Change-Id: Ie7876376d089b9ebebba3d37ac90ac346a741be3
---
M README.md
M asterixdb/asterix-server/src/main/assembly/binary-assembly.xml
D asterixdb/asterix-server/src/main/aws/ansible/customize_deployment.yml
R asterixdb/asterix-server/src/main/opt/aws/README
R asterixdb/asterix-server/src/main/opt/aws/ansible/aws_start.yml
R asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
R asterixdb/asterix-server/src/main/opt/aws/ansible/instance_start.yml
R asterixdb/asterix-server/src/main/opt/aws/bin/start.sh
R asterixdb/asterix-server/src/main/opt/aws/bin/stop.sh
R asterixdb/asterix-server/src/main/opt/aws/conf/aws_settings.yml
R asterixdb/asterix-server/src/main/opt/aws/conf/instance_settings.yml
R asterixdb/asterix-server/src/main/opt/local/bin/start.bat
R asterixdb/asterix-server/src/main/opt/local/bin/start.sh
R asterixdb/asterix-server/src/main/opt/local/bin/stop.bat
R asterixdb/asterix-server/src/main/opt/local/bin/stop.sh
R asterixdb/asterix-server/src/main/opt/local/conf/blue.conf
R asterixdb/asterix-server/src/main/opt/local/conf/cc.conf
M 
asterixdb/asterix-server/src/test/java/org/apache/asterix/server/test/SampleLocalClusterIT.java
18 files changed, 36 insertions(+), 72 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/82/1482/1

diff --git a/README.md b/README.md
index f6a1c2b..46de2cf 100644
--- a/README.md
+++ b/README.md
@@ -76,7 +76,7 @@
 * Start a single-machine AsterixDB instance:
 
         $cd asterixdb/asterix-server/target/asterix-server-*-binary-assembly/
-        $./samples/local/bin/start-sample-cluster.sh
+        $./opt/local/bin/start.sh
 
 * Good to go and run queries in your browser at:
 
diff --git a/asterixdb/asterix-server/src/main/assembly/binary-assembly.xml 
b/asterixdb/asterix-server/src/main/assembly/binary-assembly.xml
index 32a0180..48aa168 100644
--- a/asterixdb/asterix-server/src/main/assembly/binary-assembly.xml
+++ b/asterixdb/asterix-server/src/main/assembly/binary-assembly.xml
@@ -35,33 +35,16 @@
       </includes>
     </fileSet>
     <fileSet>
-      <directory>src/main/samples</directory>
-      <outputDirectory>samples</outputDirectory>
+      <directory>src/main/opt</directory>
+      <outputDirectory>opt</outputDirectory>
       <excludes>
         <exclude>**/*.sh</exclude>
       </excludes>
       <filtered>true</filtered>
     </fileSet>
     <fileSet>
-      <directory>src/main/samples</directory>
-      <outputDirectory>samples</outputDirectory>
-      <includes>
-        <include>**/*.sh</include>
-      </includes>
-      <filtered>true</filtered>
-      <fileMode>0755</fileMode>
-    </fileSet>
-    <fileSet>
-      <directory>src/main/aws</directory>
-      <outputDirectory>aws</outputDirectory>
-      <excludes>
-        <exclude>**/*.sh</exclude>
-      </excludes>
-      <filtered>true</filtered>
-    </fileSet>
-    <fileSet>
-      <directory>src/main/aws</directory>
-      <outputDirectory>aws</outputDirectory>
+      <directory>src/main/opt</directory>
+      <outputDirectory>opt</outputDirectory>
       <includes>
         <include>**/*.sh</include>
       </includes>
diff --git 
a/asterixdb/asterix-server/src/main/aws/ansible/customize_deployment.yml 
b/asterixdb/asterix-server/src/main/aws/ansible/customize_deployment.yml
deleted file mode 100644
index bb69b68..0000000
--- a/asterixdb/asterix-server/src/main/aws/ansible/customize_deployment.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-# ------------------------------------------------------------
-# 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.
-# ------------------------------------------------------------
-
-- name: Ensure the working directory exists
-  file:
-      path: "{{ binarydir }}"
-      state: directory
-
-- name: Unzip binary
-  unarchive:
-      src: "{{ lookup('pipe', 'ls -1 ' + srcpattern) }}"
-      dest: "{{ binarydir }}"
diff --git a/asterixdb/asterix-server/src/main/aws/README 
b/asterixdb/asterix-server/src/main/opt/aws/README
similarity index 100%
rename from asterixdb/asterix-server/src/main/aws/README
rename to asterixdb/asterix-server/src/main/opt/aws/README
diff --git a/asterixdb/asterix-server/src/main/aws/ansible/aws_start.yml 
b/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_start.yml
similarity index 100%
rename from asterixdb/asterix-server/src/main/aws/ansible/aws_start.yml
rename to asterixdb/asterix-server/src/main/opt/aws/ansible/aws_start.yml
diff --git a/asterixdb/asterix-server/src/main/aws/ansible/aws_stop.yml 
b/asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
similarity index 100%
rename from asterixdb/asterix-server/src/main/aws/ansible/aws_stop.yml
rename to asterixdb/asterix-server/src/main/opt/aws/ansible/aws_stop.yml
diff --git a/asterixdb/asterix-server/src/main/aws/ansible/instance_start.yml 
b/asterixdb/asterix-server/src/main/opt/aws/ansible/instance_start.yml
similarity index 94%
rename from asterixdb/asterix-server/src/main/aws/ansible/instance_start.yml
rename to asterixdb/asterix-server/src/main/opt/aws/ansible/instance_start.yml
index 743b70e..27554a9 100644
--- a/asterixdb/asterix-server/src/main/aws/ansible/instance_start.yml
+++ b/asterixdb/asterix-server/src/main/opt/aws/ansible/instance_start.yml
@@ -28,7 +28,10 @@
     - name: Install JDK
       shell: sudo yum -y localinstall jdk-8u121-linux-x64.rpm
 
-    - include: customize_deployment.yml
+    - name: Deploy binaries
+      synchronize:
+          src: "{{ dist }}"
+          dest: "{{ binarydir }}"
 
     - name: Ensure the log directory exists
       file:
@@ -49,7 +52,7 @@
   tasks:
     - include_vars: ../conf/instance_settings.yml
     - name: Copy cluster config to CC
-      copy:
+      synchronize:
         src: /tmp/asterixdb/cc.conf
         dest: "{{ basedir }}/cc.conf"
 
@@ -60,4 +63,3 @@
       shell: nohup "{{ cc }}" -config-file "{{ basedir }}/cc.conf" &> "{{ 
binarydir }}/logs/cc.log" &
       async: 10
       poll: 0
-
diff --git a/asterixdb/asterix-server/src/main/aws/bin/start.sh 
b/asterixdb/asterix-server/src/main/opt/aws/bin/start.sh
similarity index 75%
rename from asterixdb/asterix-server/src/main/aws/bin/start.sh
rename to asterixdb/asterix-server/src/main/opt/aws/bin/start.sh
index 3779952..b1a3809 100755
--- a/asterixdb/asterix-server/src/main/aws/bin/start.sh
+++ b/asterixdb/asterix-server/src/main/opt/aws/bin/start.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -x
+#!/bin/bash
 # ------------------------------------------------------------
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,15 +18,21 @@
 # under the License.
 # ------------------------------------------------------------
 
+pushd `dirname $0` > /dev/null
+SCRIPT_PATH=`pwd -P`
+popd > /dev/null
+AWS_PATH=`dirname "${SCRIPT_PATH}"`
+OPT_PATH=`dirname "${AWS_PATH}"`
+DIST_PATH=`dirname "${OPT_PATH}"`
 
 # Starts an AWS cluster.
-ansible-playbook -i "localhost," ansible/aws_start.yml
+ansible-playbook -i "localhost," $AWS_PATH/ansible/aws_start.yml
 
 # Generates an Ansible inventory file and an AsterixDB configuration file.
 temp=/tmp/asterixdb
 inventory=$temp/inventory
 conf=$temp/cc.conf
-java -cp "../repo/*" org.apache.asterixdb.aws.ConfigGenerator $temp/nodes 
$inventory $conf
+java -cp "${DIST_PATH}/repo/*" org.apache.asterixdb.aws.ConfigGenerator 
$temp/nodes $inventory $conf
 
 # Waits a while so that all instances are up and running.
 # TODO(yingyi) pull the "status check" field of each instance.
@@ -34,5 +40,5 @@
 
 # Installs asterixdb on all AWS instances.
 export ANSIBLE_HOST_KEY_CHECKING=false
-ansible-playbook -i $inventory ansible/instance_start.yml
+ansible-playbook -i $inventory $AWS_PATH/ansible/instance_start.yml
 
diff --git a/asterixdb/asterix-server/src/main/aws/bin/stop.sh 
b/asterixdb/asterix-server/src/main/opt/aws/bin/stop.sh
similarity index 83%
rename from asterixdb/asterix-server/src/main/aws/bin/stop.sh
rename to asterixdb/asterix-server/src/main/opt/aws/bin/stop.sh
index fd2c85b..25521d2 100755
--- a/asterixdb/asterix-server/src/main/aws/bin/stop.sh
+++ b/asterixdb/asterix-server/src/main/opt/aws/bin/stop.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -x
+#!/bin/bash
 # ------------------------------------------------------------
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -18,6 +18,10 @@
 # under the License.
 # ------------------------------------------------------------
 
+pushd `dirname $0` > /dev/null
+SCRIPT_PATH=`pwd -P`
+popd > /dev/null
+AWS_PATH=`dirname "${SCRIPT_PATH}"`
 
 # Terminates an AWS cluster
-ansible-playbook -i "localhost," ansible/aws_stop.yml
+ansible-playbook -i "localhost," $AWS_PATH/ansible/aws_stop.yml
diff --git a/asterixdb/asterix-server/src/main/aws/conf/aws_settings.yml 
b/asterixdb/asterix-server/src/main/opt/aws/conf/aws_settings.yml
similarity index 100%
rename from asterixdb/asterix-server/src/main/aws/conf/aws_settings.yml
rename to asterixdb/asterix-server/src/main/opt/aws/conf/aws_settings.yml
diff --git a/asterixdb/asterix-server/src/main/aws/conf/instance_settings.yml 
b/asterixdb/asterix-server/src/main/opt/aws/conf/instance_settings.yml
similarity index 88%
rename from asterixdb/asterix-server/src/main/aws/conf/instance_settings.yml
rename to asterixdb/asterix-server/src/main/opt/aws/conf/instance_settings.yml
index de83b7c..d2a9ace 100644
--- a/asterixdb/asterix-server/src/main/aws/conf/instance_settings.yml
+++ b/asterixdb/asterix-server/src/main/opt/aws/conf/instance_settings.yml
@@ -20,9 +20,6 @@
 # The name of the product (or extension) being used.
 product: asterixdb
 
-# The server binary zip.
-binary: asterix-server-*-binary-assembly.zip
-
 # The script that starts a nc service.
 ncsbin: "asterixncservice"
 
@@ -38,8 +35,8 @@
 # The working directory.
 binarydir: "{{ basedir }}/{{ product }}"
 
-# The pattern for retrieving the sever binary zip from the current build.
-srcpattern: "../../../{{ binary }}"
+# The full binary distribution directory.
+dist: "../../../"
 
 # The nc service command (script).
 ncservice: "{{ binarydir}}/bin/{{ ncsbin }}"
diff --git 
a/asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.bat 
b/asterixdb/asterix-server/src/main/opt/local/bin/start.bat
similarity index 95%
rename from 
asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.bat
rename to asterixdb/asterix-server/src/main/opt/local/bin/start.bat
index 580e1e0..2fff45c 100644
--- 
a/asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.bat
+++ b/asterixdb/asterix-server/src/main/opt/local/bin/start.bat
@@ -88,7 +88,7 @@
   echo ERROR: sample cluster address [localhost:${LISTEN_PORT}] already in use
   goto :ERROR
 )
-set tempfile="%TEMP%\start-sample-cluster-%random%"
+set tempfile="%TEMP%\start-%random%"
 
 wmic process where ^
   "name='java.exe' and CommandLine like 
'%%org.codehaus.mojo.appassembler.booter.AppassemblerBooter%%' and (CommandLine 
like '%%app.name=\"%%[cn]c\"%%' or CommandLine like 
'%%app.name=\"%%ncservice\"%%')" ^
@@ -106,7 +106,7 @@
  ) else (
     echo %severity%: ${PRODUCT} processes are already running; aborting"
     echo.
-    echo Re-run with -f to ignore, or run stop-sample-cluster.bat -f to 
forcibly terminate all running ${PRODUCT} processes:
+    echo Re-run with -f to ignore, or run stop.bat -f to forcibly terminate 
all running ${PRODUCT} processes:
     for /F "skip=1" %%P in ('type %tempfile%') DO @echo     - %%P
     del %tempfile%
     exit /B 1
diff --git 
a/asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh 
b/asterixdb/asterix-server/src/main/opt/local/bin/start.sh
similarity index 95%
rename from 
asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh
rename to asterixdb/asterix-server/src/main/opt/local/bin/start.sh
index d702e8a..66db660 100755
--- 
a/asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh
+++ b/asterixdb/asterix-server/src/main/opt/local/bin/start.sh
@@ -79,7 +79,7 @@
   else
     echo "aborting"
     echo
-    echo "Re-run with -f to ignore, or run stop-sample-cluster.sh -f to 
forcibly terminate all running ${PRODUCT} processes:"
+    echo "Re-run with -f to ignore, or run stop.sh -f to forcibly terminate 
all running ${PRODUCT} processes:"
     cat /tmp/$$_jps | sed 's/^/  - /'
     rm /tmp/$$_jps
     exit 1
diff --git 
a/asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.bat 
b/asterixdb/asterix-server/src/main/opt/local/bin/stop.bat
similarity index 97%
rename from 
asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.bat
rename to asterixdb/asterix-server/src/main/opt/local/bin/stop.bat
index 7ac9483..2a32d07 100644
--- 
a/asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.bat
+++ b/asterixdb/asterix-server/src/main/opt/local/bin/stop.bat
@@ -76,7 +76,7 @@
 cd %CLUSTERDIR%\..\..
 set INSTALLDIR=%cd%
 
-set tempfile="%TEMP%\stop-sample-cluster-%random%"
+set tempfile="%TEMP%\stop-%random%"
 
 call %INSTALLDIR%\bin\${HELPER_COMMAND} get_cluster_state -quiet
 if %ERRORLEVEL% EQU 1 (
diff --git 
a/asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh 
b/asterixdb/asterix-server/src/main/opt/local/bin/stop.sh
similarity index 100%
rename from 
asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh
rename to asterixdb/asterix-server/src/main/opt/local/bin/stop.sh
diff --git a/asterixdb/asterix-server/src/main/samples/local/conf/blue.conf 
b/asterixdb/asterix-server/src/main/opt/local/conf/blue.conf
similarity index 100%
rename from asterixdb/asterix-server/src/main/samples/local/conf/blue.conf
rename to asterixdb/asterix-server/src/main/opt/local/conf/blue.conf
diff --git a/asterixdb/asterix-server/src/main/samples/local/conf/cc.conf 
b/asterixdb/asterix-server/src/main/opt/local/conf/cc.conf
similarity index 100%
rename from asterixdb/asterix-server/src/main/samples/local/conf/cc.conf
rename to asterixdb/asterix-server/src/main/opt/local/conf/cc.conf
diff --git 
a/asterixdb/asterix-server/src/test/java/org/apache/asterix/server/test/SampleLocalClusterIT.java
 
b/asterixdb/asterix-server/src/test/java/org/apache/asterix/server/test/SampleLocalClusterIT.java
index 0991d4f..5d462a8 100644
--- 
a/asterixdb/asterix-server/src/test/java/org/apache/asterix/server/test/SampleLocalClusterIT.java
+++ 
b/asterixdb/asterix-server/src/test/java/org/apache/asterix/server/test/SampleLocalClusterIT.java
@@ -54,7 +54,7 @@
     // src/test/resources/NCServiceExecutionIT/cc.conf.
     private static final String OUTPUT_DIR = joinPath(TARGET_DIR, 
"sample-local-cluster");
 
-    private static final String LOCAL_SAMPLES_DIR = joinPath(OUTPUT_DIR, 
"samples", "local");
+    private static final String LOCAL_SAMPLES_DIR = joinPath(OUTPUT_DIR, 
"opt", "local");
 
     @Rule
     public TestRule watcher = new TestMethodTracer();
@@ -78,10 +78,10 @@
 
     @Test
     public void test0_startCluster() throws Exception {
-        Process process = new ProcessBuilder(joinPath(LOCAL_SAMPLES_DIR, 
"bin/stop-sample-cluster.sh"), "-f")
+        Process process = new ProcessBuilder(joinPath(LOCAL_SAMPLES_DIR, 
"bin/stop.sh"), "-f")
                 .inheritIO().start();
         Assert.assertEquals(0, process.waitFor());
-        process = new ProcessBuilder(joinPath(LOCAL_SAMPLES_DIR, 
"bin/start-sample-cluster.sh")).inheritIO().start();
+        process = new ProcessBuilder(joinPath(LOCAL_SAMPLES_DIR, 
"bin/start.sh")).inheritIO().start();
         Assert.assertEquals(0, process.waitFor());
     }
 
@@ -97,7 +97,7 @@
 
     @Test
     public void test2_stopCluster() throws Exception {
-        Process process = new ProcessBuilder(joinPath(LOCAL_SAMPLES_DIR, 
"bin/stop-sample-cluster.sh"))
+        Process process = new ProcessBuilder(joinPath(LOCAL_SAMPLES_DIR, 
"bin/stop.sh"))
                 .inheritIO().start();
         Assert.assertEquals(0, process.waitFor());
         try {

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1482
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie7876376d089b9ebebba3d37ac90ac346a741be3
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Yingyi Bu <[email protected]>

Reply via email to