diff --git a/metron-platform/metron-solr/metron-solr-common/src/main/scripts/create_collection.sh b/metron-platform/metron-solr/metron-solr-common/src/main/scripts/create_collection.sh index 7693646e25..ae2e94a8a2 100755 --- a/metron-platform/metron-solr/metron-solr-common/src/main/scripts/create_collection.sh +++ b/metron-platform/metron-solr/metron-solr-common/src/main/scripts/create_collection.sh @@ -16,8 +16,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -METRON_VERSION=${project.version} -METRON_HOME=/usr/metron/$METRON_VERSION ZOOKEEPER=${ZOOKEEPER:-localhost:2181} ZOOKEEPER_HOME=${ZOOKEEPER_HOME:-/usr/hdp/current/zookeeper-client} SECURITY_ENABLED=${SECURITY_ENABLED:-false} @@ -26,6 +24,15 @@ if [ ${SECURITY_ENABLED,,} == 'true' ]; then NEGOTIATE=' --negotiate -u : ' fi +# test for errors +if [[ ${SOLR_NODE} =~ .*:null ]]; then + echo "Error occurred while attempting to read SOLR Cloud configuration data from Zookeeper."; + if ! [[ ${ZOOKEEPER} =~ .*/solr ]]; then + echo "Warning! Environment variable ZOOKEEPER=$ZOOKEEPER does not contain a chrooted zookeeper ensemble address - are you sure you do not mean ZOOKEEPER=$ZOOKEEPER/solr?"; + fi + exit 1; +fi + # Get the first Solr node from the list of live nodes in Zookeeper SOLR_NODE=`$ZOOKEEPER_HOME/bin/zkCli.sh -server $ZOOKEEPER ls /live_nodes | tail -n 1 | sed 's/\[\([^,]*\).*\]/\1/' | sed 's/_solr//'` diff --git a/metron-platform/metron-solr/metron-solr-common/src/main/scripts/delete_collection.sh b/metron-platform/metron-solr/metron-solr-common/src/main/scripts/delete_collection.sh index c8b45e7e1b..8279aa83b4 100755 --- a/metron-platform/metron-solr/metron-solr-common/src/main/scripts/delete_collection.sh +++ b/metron-platform/metron-solr/metron-solr-common/src/main/scripts/delete_collection.sh @@ -16,8 +16,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -METRON_VERSION=${project.version} -METRON_HOME=/usr/metron/$METRON_VERSION ZOOKEEPER=${ZOOKEEPER:-localhost:2181} ZOOKEEPER_HOME=${ZOOKEEPER_HOME:-/usr/hdp/current/zookeeper-client} SECURITY_ENABLED=${SECURITY_ENABLED:-false} @@ -29,5 +27,14 @@ fi # Get the first Solr node from the list of live nodes in Zookeeper SOLR_NODE=`$ZOOKEEPER_HOME/bin/zkCli.sh -server $ZOOKEEPER ls /live_nodes | tail -n 1 | sed 's/\[\([^,]*\).*\]/\1/' | sed 's/_solr//'` +# test for errors +if [[ ${SOLR_NODE} =~ .*:null ]]; then + echo "Error occurred while attempting to read SOLR Cloud configuration data from Zookeeper."; + if ! [[ ${ZOOKEEPER} =~ .*/solr ]]; then + echo "Warning! Environment variable ZOOKEEPER=$ZOOKEEPER does not contain a chrooted zookeeper ensemble address - are you sure you do not mean ZOOKEEPER=$ZOOKEEPER/solr?"; + fi + exit 1; +fi + # Delete the collection curl -X GET $NEGOTIATE "http://$SOLR_NODE/solr/admin/collections?action=DELETE&name=$1"