Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump tokens after Cassandra started #217

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Dockerfiles/Cassandra-3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ EXPOSE 7001 7199 8778 9042
ENV CASSIE_VERSION=3.11.2
ENV DEBIAN_FRONTEND=noninteractive

RUN echo "deb http://www.apache.org/dist/cassandra/debian 311x main" | tee -a /etc/apt/sources.list.d/apache.cassandra.list
RUN apt-get update && apt-get -y install gnupg
RUN curl https://www.apache.org/dist/cassandra/KEYS | apt-key add -
RUN echo "deb http://www.apache.org/dist/cassandra/debian 311x main" | tee -a /etc/apt/sources.list.d/apache.cassandra.list

RUN apt-get -y update && apt-get -y -o Dpkg::Options::='--force-confold' --fix-missing dist-upgrade
RUN apt-get -y install vim less sysstat \
RUN apt-get -y install vim less sysstat netcat \
cassandra=$CASSIE_VERSION \
cassandra-tools=$CASSIE_VERSION && \
apt-get clean && \
Expand All @@ -38,6 +39,7 @@ RUN rm -f /etc/cassandra/cassandra.yaml \
/etc/cassandra/cassandra-rackdc.properties && \
chmod 0777 /etc/cassandra

COPY dump-ring-token.sh /usr/local/bin/
COPY planb-cassandra.sh /usr/local/bin/

ENV HOME=/var/lib/cassandra
Expand Down
15 changes: 15 additions & 0 deletions Dockerfiles/Cassandra-3/dump-ring-token.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

function waiting_client_port_open() {
local port=$1

while ! nc -z localhost $port; do
sleep 10
done
}

waiting_client_port_open 9042

IP=$(curl 'http://169.254.169.254/latest/meta-data/local-ipv4')
TOKENS=$(nodetool ring | grep ${IP} | awk '{print $NF ","}' | xargs)
echo ${TOKENS:0:-1}
4 changes: 4 additions & 0 deletions Dockerfiles/Cassandra-3/planb-cassandra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,9 @@ if [ -n "$DC_SUFFIX" ]; then
echo "dc_suffix=$DC_SUFFIX" > /etc/cassandra/cassandra-rackdc.properties
fi

# Initialze the script to dump all the token belong to this node in the ring.
mkdir -p ${CASSANDRA_DATA_DIR}/metadata
nohup /usr/local/bin/dump-ring-token.sh > ${CASSANDRA_DATA_DIR}/metadata/ring-tokens &

echo "Starting Cassandra ..."
exec /usr/sbin/cassandra -R -f