Skip to content

Commit

Permalink
HWKMETRICS-87: support decommissioning Cassandra nodes before removin…
Browse files Browse the repository at this point in the history
…g them from the cluster.
  • Loading branch information
mwringe committed May 14, 2015
1 parent 4107d6f commit 8669079
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
3 changes: 3 additions & 0 deletions containers/cassandra-docker/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ COPY cassandra-seed-provider.jar /opt/apache-cassandra/lib/
# Copy our customized run script over to the cassandra bin directory
COPY cassandra-docker.sh /opt/apache-cassandra/bin/

# Copy the preStop scriptover to the cassandra bin directory
COPY cassandra-docker-pre-stop.sh /opt/apache-cassandra/bin/

# TODO: remove this line once https://bugzilla.redhat.com/show_bug.cgi?id=1201848 has been fixed
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
#
# Copyright 2014-2015 Red Hat, Inc. and/or its affiliates
# and other contributors as indicated by the @author tags.
#
# 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.
#
nodetool decommission
nodetool stopdaemon
exit 1
22 changes: 2 additions & 20 deletions containers/cassandra-docker/src/main/docker/cassandra-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,9 @@ else
sed -i 's#${SEED_PROVIDER_CLASSNAME}#org.apache.cassandra.locator.SimpleSeedProvider#g' /opt/apache-cassandra/conf/cassandra.yaml
fi


CASSANDRA_PID_FILE="cass.pid"

function decommission() {
nodetool decommission
nodetool stopdaemon
exit 1
}

#trap "decommission" SIGINT SIGTERM

if [ -n "$CASSANDRA_HOME" ]; then
${CASSANDRA_HOME}/bin/cassandra -p $CASSANDRA_PID_FILE
${CASSANDRA_HOME}/bin/cassandra -f
else
/opt/apache-cassandra/bin/cassandra -p $CASSANDRA_PID_FILE
/opt/apache-cassandra/bin/cassandra -f
fi

CASSANDRA_PID=`cat $CASSANDRA_PID_FILE`
echo "CASSANDRA_PID = $CASSANDRA_PID"

while [ `ps -p $CASSANDRA_PID| wc -l` = 2 ] ; do
sleep 5;
done

9 changes: 8 additions & 1 deletion containers/kubernetes/src/main/fabric8/kubernetes.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@
{ "name": "cassandra-thift-port", "containerPort": 9160},
{ "name": "cassandra-tcp-port", "containerPort": 7000},
{ "name": "cassandra-ssl-port", "containerPort": 7001}
]
],
"lifecycle": {
"preStop": {
"exec": {
"command": ["/opt/apache-cassandra/bin/cassandra-docker-pre-stop.sh"]
}
}
}
}]
}
},
Expand Down

0 comments on commit 8669079

Please sign in to comment.