You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by "Michael Blow (Code Review)" <do...@asterixdb.incubator.apache.org> on 2016/10/28 01:06:05 UTC

Change in asterixdb[master]: Detect, Option to Forcibly Terminate AsterixDB Processes

Michael Blow has uploaded a new change for review.

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

Change subject: Detect, Option to Forcibly Terminate AsterixDB Processes
......................................................................

Detect, Option to Forcibly Terminate AsterixDB Processes

Usability changes for sample local cluster:
1. Before start, check if there are any AsterixDB proceses running.  If so,
   error out.  This can be overridden with -f, which will proceed to start
   the cluster anyway.  This is useful in case where the other processes
   are operating on non-conflicting ports.
2. After stop, check if there are any AsterixDB processes running.  If
   so, emit a warning, and if -f is supplied to stop, kill any
   straggling processes.

Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
---
M asterixdb/asterix-server/src/main/assembly/filter.properties
M asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh
M asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh
3 files changed, 75 insertions(+), 13 deletions(-)


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

diff --git a/asterixdb/asterix-server/src/main/assembly/filter.properties b/asterixdb/asterix-server/src/main/assembly/filter.properties
index f7a53b3..34d86df 100644
--- a/asterixdb/asterix-server/src/main/assembly/filter.properties
+++ b/asterixdb/asterix-server/src/main/assembly/filter.properties
@@ -3,3 +3,4 @@
 NC_COMMAND=asterixnc
 HELPER_COMMAND=asterixhelper
 LISTEN_PORT=19002
+PRODUCT=AsterixDB
\ No newline at end of file
diff --git a/asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh b/asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh
index 53ceff8..d702e8a 100755
--- a/asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh
+++ b/asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh
@@ -18,6 +18,22 @@
 # under the License.
 # ------------------------------------------------------------
 
+function usage() {
+  echo
+  echo Usage: $(basename $0) [-f[orce]]
+  echo
+  echo "  -f[orce]  : Forces a start attempt when ${PRODUCT} processes are found to be running"
+}
+
+while [ -n "$1" ]; do
+  case $1 in
+    -f|-force) force=1;;
+    -help|--help|-usage|--usage) usage; exit 0;;
+    *) echo "ERROR: unknown argument '$1'"; usage; exit 1;;
+  esac
+  shift
+done
+
 if [ -z "$JAVA_HOME" -a -x /usr/libexec/java_home ]; then
   JAVA_HOME=$(/usr/libexec/java_home)
   export JAVA_HOME
@@ -51,12 +67,32 @@
 $INSTALLDIR/bin/${HELPER_COMMAND} get_cluster_state -quiet \
     && echo "ERROR: sample cluster address (localhost:${LISTEN_PORT}) already in use" && exit 1
 
+if $JAVA_HOME/bin/jps | grep ' \(CCDriver\|NCDriver\|NCService\)$' > /tmp/$$_jps; then
+  if [ $force ]; then
+    severity=WARNING
+  else
+    severity=ERROR
+  fi
+  echo -n "${severity}: ${PRODUCT} processes are already running; "
+  if [ $force ]; then
+    echo "-f[orce] specified, ignoring"
+  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:"
+    cat /tmp/$$_jps | sed 's/^/  - /'
+    rm /tmp/$$_jps
+    exit 1
+  fi
+fi
+
+rm /tmp/$$_jps
 (
   echo "--------------------------"
   date
   echo "--------------------------"
 ) | tee -a $LOGSDIR/blue-service.log | tee -a $LOGSDIR/red-service.log >> $LOGSDIR/cc.log
-echo "Starting sample cluster..."
+echo "INFO: Starting sample cluster..."
 $INSTALLDIR/bin/${NC_SERVICE_COMMAND} -logdir - -config-file $CLUSTERDIR/conf/blue.conf >> $LOGSDIR/blue-service.log 2>&1 &
 $INSTALLDIR/bin/${NC_SERVICE_COMMAND} -logdir - >> $LOGSDIR/red-service.log 2>&1 &
 $INSTALLDIR/bin/${CC_COMMAND} -config-file $CLUSTERDIR/conf/cc.conf >> $LOGSDIR/cc.log 2>&1 &
diff --git a/asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh b/asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh
index b69ee53..d2aba75 100755
--- a/asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh
+++ b/asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh
@@ -18,6 +18,15 @@
 # under the License.
 # ------------------------------------------------------------
 
+while [ -n "$1" ]; do
+  case $1 in
+    -f|-force) force=1;;
+      -help|--help) echo $(basename $0) [-f[orce]]; echo "  -f[orce]  : Forcibly terminates any running ${PRODUCT} processes after shutting down cluster, if running"; exit 0;;
+  *) echo "ERROR: unknown argument '$1'"; exit 1;;
+  esac
+  shift
+done
+
 if [ -z "$JAVA_HOME" -a -x /usr/libexec/java_home ]; then
   JAVA_HOME=$(/usr/libexec/java_home)
   export JAVA_HOME
@@ -43,19 +52,35 @@
 $INSTALLDIR/bin/${HELPER_COMMAND} get_cluster_state -quiet
 if [ $? -ne 1 ]; then
   $INSTALLDIR/bin/${HELPER_COMMAND} shutdown_cluster_all
+  first=1
+  tries=0
+  while [ -n "$($JAVA_HOME/bin/jps | awk '/CCDriver/')" -a tries -lt 60 ]; do
+    if [ $first ]; then
+      echo
+      echo -n "Waiting for CCDriver to terminate."
+      unset first
+    fi
+    sleep 1s
+    echo -n .
+    tries=$(expr $tries + 1)
+  done
+  [ ! $first ] && echo ".done." || true
 else
-  echo "WARNING: sample cluster does not appear to be running, will attempt to wait for"
-  echo "         CCDriver to terminate if running."
+  echo "WARNING: sample cluster does not appear to be running"
 fi
 
-first=1
-while [ -n "$($JAVA_HOME/bin/jps | awk '/CCDriver/')" ]; do
-  if [ $first ]; then
-    echo
-    echo -n "Waiting for CCDriver to terminate."
-    unset first
+if $JAVA_HOME/bin/jps | grep ' \(CCDriver\|NCDriver\|NCService\)$' > /tmp/$$_jps; then
+  echo -n "WARNING: ${PRODUCT} processes remain after cluster shutdown; "
+  if [ $force ]; then
+    echo "-f[orce] specified, forcibly terminating ${PRODUCT} processes:"
+    cat /tmp/$$_jps | while read line; do
+      echo -n "   - $line..."
+      echo $line | awk '{ print $1 }' | xargs -n1 kill -9
+      echo "killed"
+    done
+  else
+    echo "re-run with -f|-force to forcibly terminate all ${PRODUCT} processes:"
+    cat /tmp/$$_jps | sed 's/^/  - /'
   fi
-  sleep 2s
-  echo -n .
-done
-[ ! $first ] && echo ".done." || true
+fi
+rm /tmp/$$_jps

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>

Change in asterixdb[master]: Detect, Option to Forcibly Terminate AsterixDB Processes

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: Detect, Option to Forcibly Terminate AsterixDB Processes
......................................................................


Patch Set 3:

Integration Tests Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-integration-tests/1028/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: No

Change in asterixdb[master]: Detect, Option to Forcibly Terminate AsterixDB Processes

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: Detect, Option to Forcibly Terminate AsterixDB Processes
......................................................................


Patch Set 3: Integration-Tests+1

Integration Tests Successful

https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-integration-tests/1028/ : SUCCESS

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: No

Change in asterixdb[master]: Detect, Option to Forcibly Terminate AsterixDB Processes

Posted by "Michael Blow (Code Review)" <do...@asterixdb.incubator.apache.org>.
Michael Blow has posted comments on this change.

Change subject: Detect, Option to Forcibly Terminate AsterixDB Processes
......................................................................


Patch Set 3: Verified+1

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: No

Change in asterixdb[master]: Detect, Option to Forcibly Terminate AsterixDB Processes

Posted by "Michael Blow (Code Review)" <do...@asterixdb.incubator.apache.org>.
Michael Blow has uploaded a new patch set (#2).

Change subject: Detect, Option to Forcibly Terminate AsterixDB Processes
......................................................................

Detect, Option to Forcibly Terminate AsterixDB Processes

Usability changes for sample local cluster:
1. Before start, check if there are any AsterixDB proceses running.  If so,
   error out.  This can be overridden with -f, which will proceed to start
   the cluster anyway.  This is useful in case where the other processes
   are operating on non-conflicting ports.
2. After stop, check if there are any AsterixDB processes running.  If
   so, emit a warning, and if -f is supplied to stop, kill any
   straggling processes.

Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
---
M asterixdb/asterix-server/src/main/assembly/filter.properties
M asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh
M asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh
3 files changed, 82 insertions(+), 13 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/16/1316/2
-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1316
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>

Change in asterixdb[master]: Detect, Option to Forcibly Terminate AsterixDB Processes

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: Detect, Option to Forcibly Terminate AsterixDB Processes
......................................................................


Patch Set 2:

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-notopic/3161/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Gerrit-PatchSet: 2
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: No

Change in asterixdb[master]: Detect, Option to Forcibly Terminate AsterixDB Processes

Posted by "Till Westmann (Code Review)" <do...@asterixdb.incubator.apache.org>.
Till Westmann has posted comments on this change.

Change subject: Detect, Option to Forcibly Terminate AsterixDB Processes
......................................................................


Patch Set 3: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: No

Change in asterixdb[master]: Detect, Option to Forcibly Terminate AsterixDB Processes

Posted by "Michael Blow (Code Review)" <do...@asterixdb.incubator.apache.org>.
Hello Jenkins,

I'd like you to reexamine a change.  Please visit

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

to look at the new patch set (#3).

Change subject: Detect, Option to Forcibly Terminate AsterixDB Processes
......................................................................

Detect, Option to Forcibly Terminate AsterixDB Processes

Usability changes for sample local cluster:
1. Before start, check if there are any AsterixDB proceses running.  If so,
   error out.  This can be overridden with -f, which will proceed to start
   the cluster anyway.  This is useful in case where the other processes
   are operating on non-conflicting ports.
2. After stop, check if there are any AsterixDB processes running.  If
   so, emit a warning, and if -f is supplied to stop, kill any
   straggling processes.

Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
---
M asterixdb/asterix-server/src/main/assembly/filter.properties
M asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh
M asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh
3 files changed, 78 insertions(+), 13 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/16/1316/3
-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1316
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>

Change in asterixdb[master]: Detect, Option to Forcibly Terminate AsterixDB Processes

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: Detect, Option to Forcibly Terminate AsterixDB Processes
......................................................................


Patch Set 3:

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-notopic/3162/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: No

Change in asterixdb[master]: Detect, Option to Forcibly Terminate AsterixDB Processes

Posted by "Michael Blow (Code Review)" <do...@asterixdb.incubator.apache.org>.
Michael Blow has submitted this change and it was merged.

Change subject: Detect, Option to Forcibly Terminate AsterixDB Processes
......................................................................


Detect, Option to Forcibly Terminate AsterixDB Processes

Usability changes for sample local cluster:
1. Before start, check if there are any AsterixDB proceses running.  If so,
   error out.  This can be overridden with -f, which will proceed to start
   the cluster anyway.  This is useful in case where the other processes
   are operating on non-conflicting ports.
2. After stop, check if there are any AsterixDB processes running.  If
   so, emit a warning, and if -f is supplied to stop, kill any
   straggling processes.

Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1316
Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Tested-by: Michael Blow <mb...@apache.org>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <ti...@apache.org>
---
M asterixdb/asterix-server/src/main/assembly/filter.properties
M asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh
M asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh
3 files changed, 78 insertions(+), 13 deletions(-)

Approvals:
  Michael Blow: Verified
  Till Westmann: Looks good to me, approved
  Jenkins: Verified; No violations found; Verified



diff --git a/asterixdb/asterix-server/src/main/assembly/filter.properties b/asterixdb/asterix-server/src/main/assembly/filter.properties
index f7a53b3..34d86df 100644
--- a/asterixdb/asterix-server/src/main/assembly/filter.properties
+++ b/asterixdb/asterix-server/src/main/assembly/filter.properties
@@ -3,3 +3,4 @@
 NC_COMMAND=asterixnc
 HELPER_COMMAND=asterixhelper
 LISTEN_PORT=19002
+PRODUCT=AsterixDB
\ No newline at end of file
diff --git a/asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh b/asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh
index 53ceff8..d702e8a 100755
--- a/asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh
+++ b/asterixdb/asterix-server/src/main/samples/local/bin/start-sample-cluster.sh
@@ -18,6 +18,22 @@
 # under the License.
 # ------------------------------------------------------------
 
+function usage() {
+  echo
+  echo Usage: $(basename $0) [-f[orce]]
+  echo
+  echo "  -f[orce]  : Forces a start attempt when ${PRODUCT} processes are found to be running"
+}
+
+while [ -n "$1" ]; do
+  case $1 in
+    -f|-force) force=1;;
+    -help|--help|-usage|--usage) usage; exit 0;;
+    *) echo "ERROR: unknown argument '$1'"; usage; exit 1;;
+  esac
+  shift
+done
+
 if [ -z "$JAVA_HOME" -a -x /usr/libexec/java_home ]; then
   JAVA_HOME=$(/usr/libexec/java_home)
   export JAVA_HOME
@@ -51,12 +67,32 @@
 $INSTALLDIR/bin/${HELPER_COMMAND} get_cluster_state -quiet \
     && echo "ERROR: sample cluster address (localhost:${LISTEN_PORT}) already in use" && exit 1
 
+if $JAVA_HOME/bin/jps | grep ' \(CCDriver\|NCDriver\|NCService\)$' > /tmp/$$_jps; then
+  if [ $force ]; then
+    severity=WARNING
+  else
+    severity=ERROR
+  fi
+  echo -n "${severity}: ${PRODUCT} processes are already running; "
+  if [ $force ]; then
+    echo "-f[orce] specified, ignoring"
+  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:"
+    cat /tmp/$$_jps | sed 's/^/  - /'
+    rm /tmp/$$_jps
+    exit 1
+  fi
+fi
+
+rm /tmp/$$_jps
 (
   echo "--------------------------"
   date
   echo "--------------------------"
 ) | tee -a $LOGSDIR/blue-service.log | tee -a $LOGSDIR/red-service.log >> $LOGSDIR/cc.log
-echo "Starting sample cluster..."
+echo "INFO: Starting sample cluster..."
 $INSTALLDIR/bin/${NC_SERVICE_COMMAND} -logdir - -config-file $CLUSTERDIR/conf/blue.conf >> $LOGSDIR/blue-service.log 2>&1 &
 $INSTALLDIR/bin/${NC_SERVICE_COMMAND} -logdir - >> $LOGSDIR/red-service.log 2>&1 &
 $INSTALLDIR/bin/${CC_COMMAND} -config-file $CLUSTERDIR/conf/cc.conf >> $LOGSDIR/cc.log 2>&1 &
diff --git a/asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh b/asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh
index b69ee53..f6824c8 100755
--- a/asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh
+++ b/asterixdb/asterix-server/src/main/samples/local/bin/stop-sample-cluster.sh
@@ -18,6 +18,22 @@
 # under the License.
 # ------------------------------------------------------------
 
+function usage() {
+  echo
+  echo Usage: $(basename $0) [-f[orce]]
+  echo
+  echo "  -f[orce]  : Forcibly terminates any running ${PRODUCT} processes (after shutting down cluster, if running)"
+}
+
+while [ -n "$1" ]; do
+  case $1 in
+    -f|-force) force=1;;
+    -help|--help|-usage|--usage) usage; exit 0;;
+    *) echo "ERROR: unknown argument '$1'"; usage; exit 1;;
+    esac
+  shift
+done
+
 if [ -z "$JAVA_HOME" -a -x /usr/libexec/java_home ]; then
   JAVA_HOME=$(/usr/libexec/java_home)
   export JAVA_HOME
@@ -43,19 +59,31 @@
 $INSTALLDIR/bin/${HELPER_COMMAND} get_cluster_state -quiet
 if [ $? -ne 1 ]; then
   $INSTALLDIR/bin/${HELPER_COMMAND} shutdown_cluster_all
+  first=1
+  tries=0
+  echo -n "INFO: Waiting up to 60s for cluster to shutdown"
+  while [ -n "$($JAVA_HOME/bin/jps | awk '/CCDriver/')" -a $tries -lt 60 ]; do
+    sleep 1s
+    echo -n .
+    tries=$(expr $tries + 1)
+  done
+  echo ".done." || true
 else
-  echo "WARNING: sample cluster does not appear to be running, will attempt to wait for"
-  echo "         CCDriver to terminate if running."
+  echo "WARNING: sample cluster does not appear to be running"
 fi
 
-first=1
-while [ -n "$($JAVA_HOME/bin/jps | awk '/CCDriver/')" ]; do
-  if [ $first ]; then
-    echo
-    echo -n "Waiting for CCDriver to terminate."
-    unset first
+if $JAVA_HOME/bin/jps | grep ' \(CCDriver\|NCDriver\|NCService\)$' > /tmp/$$_jps; then
+  echo -n "WARNING: ${PRODUCT} processes remain after cluster shutdown; "
+  if [ $force ]; then
+    echo "-f[orce] specified, forcibly terminating ${PRODUCT} processes:"
+    cat /tmp/$$_jps | while read line; do
+      echo -n "   - $line..."
+      echo $line | awk '{ print $1 }' | xargs -n1 kill -9
+      echo "killed"
+    done
+  else
+    echo "re-run with -f|-force to forcibly terminate all ${PRODUCT} processes:"
+    cat /tmp/$$_jps | sed 's/^/  - /'
   fi
-  sleep 2s
-  echo -n .
-done
-[ ! $first ] && echo ".done." || true
+fi
+rm /tmp/$$_jps

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Gerrit-PatchSet: 4
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>

Change in asterixdb[master]: Detect, Option to Forcibly Terminate AsterixDB Processes

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: Detect, Option to Forcibly Terminate AsterixDB Processes
......................................................................


Patch Set 1:

Build Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-notopic/3160/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: No

Change in asterixdb[master]: Detect, Option to Forcibly Terminate AsterixDB Processes

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: Detect, Option to Forcibly Terminate AsterixDB Processes
......................................................................


Patch Set 3:

Integration Tests Successful

https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-integration-tests/1029/ : SUCCESS

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: No

Change in asterixdb[master]: Detect, Option to Forcibly Terminate AsterixDB Processes

Posted by "Jenkins (Code Review)" <do...@asterixdb.incubator.apache.org>.
Jenkins has posted comments on this change.

Change subject: Detect, Option to Forcibly Terminate AsterixDB Processes
......................................................................


Patch Set 3:

Integration Tests Started https://asterix-jenkins.ics.uci.edu/job/asterix-gerrit-integration-tests/1029/

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie09c86fe67f7933574a03574fbe334e8c1be2bbd
Gerrit-PatchSet: 3
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Jenkins <je...@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Michael Blow <mb...@apache.org>
Gerrit-Reviewer: Till Westmann <ti...@apache.org>
Gerrit-HasComments: No