Skip to content

Instantly share code, notes, and snippets.

@millerjp
Created March 14, 2016 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save millerjp/2d55664091262c4dc261 to your computer and use it in GitHub Desktop.
Save millerjp/2d55664091262c4dc261 to your computer and use it in GitHub Desktop.
wrapper for sstableloader to load one file at a time, rename and moved completed to directory
#!/bin/bash
#This is the directory that teh sstables will be palce into load - the table name is also going to be changed from v2 to v4
WORKING_DIR=/somecompany/cassandra/data/sstable_loading_dir/someks/sometable_v4
COMPLETED_DIR=/somecompany/cassandra/data/sstable_completed_dir
mkdir -p $COMPLETED_DIR
mkdir -p $WORKING_DIR
rm -rf $WORKING_DIR/*
SSTABLE_SNAPHOST_NAME="snapshotName"
#Map it somehow to the destination host to load the data in
DEST_HOST=`hostname | sed 's/host36/host26/g'`
THROTTLE=$THROTTLE_MEGABITS_PER_SEC
for i in $(find /somecompany/cassandra/data -type d | grep ${SSTABLE_SNAPHOST_NAME} ); do
for x in $(ls ${i}/*Data* | cut -d'-' -f4 | uniq ); do
mv ${i}/*${x}* ${WORKING_DIR}
cd ${WORKING_DIR}
rename 's/v2/v4/' *
sstableloader --throttle ${THROTTLE} -d ${DEST_HOST} ${WORKING_DIR}/ || { echo 'sstableloader for ${x} failed' ; exit 1; }
mv ${WORKING_DIR}/* ${COMPLETED_DIR}/
done
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment