I created a script that processes files in a loop, using a process call. I check the exit code of said call to see if I should move the files (on success.) Problem is, that when the process fails with an exception, it never exits. How do I go about detecting the exception occurred, so I can make the script move on to the next files?
Relevant part of script
# Stream data
sstableloader -d $3 $tablepathfull
# On success, move data to target dir
if [[ $? != 0 ]]; then
echo "Error: Table failed - $tablepathfull"
else
echo "Table OK - $tablepathfull"
trgtdir="$2/$hostname/$keyspacename/$typename/$timestamp/$keyspacename/$tablename"
mkdir -p $trgtdir
mv $tablepathfull/* $trgtdir
rmdir $tablepathfull
fi
If there is no 'official' way, is it perhaps possible to capture the output (see below) of the process call, and simply kill the process once/if the exception occurs?
Exception output
Exception in thread "STREAM-OUT-/XX.XX.XXX.88" Exception in thread "STREAM-OUT-/XX.XX.XXX.92" java.lang.NullPointerException
at org.apache.cassandra.streaming.ConnectionHandler$MessageHandler.signalCloseDone(ConnectionHandler.java:249)
at org.apache.cassandra.streaming.ConnectionHandler$OutgoingMessageHandler.run(ConnectionHandler.java:375)
at java.lang.Thread.run(Thread.java:744)
java.lang.NullPointerException
at org.apache.cassandra.streaming.ConnectionHandler$MessageHandler.signalCloseDone(ConnectionHandler.java:249)
at org.apache.cassandra.streaming.ConnectionHandler$OutgoingMessageHandler.run(ConnectionHandler.java:375)
at java.lang.Thread.run(Thread.java:744)