Skip to content

Commit

Permalink
first cut of ZK based SMUI deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Aug 18, 2020
1 parent 6127d69 commit 58e5019
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 6 deletions.
11 changes: 7 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
environment:
- SOLR_URL=http://solr1:8983/solr/ecommerce
# networks:
# - solr
# - solr
depends_on:
- solr1

Expand All @@ -40,9 +40,12 @@ services:
- SMUI_DB_URL=jdbc:mysql://mysql:3306/smui?autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
- SMUI_DB_USER=root
- SMUI_DB_PASSWORD=password
- SMUI_DEPLOY_PRELIVE_SOLR_HOST=solr:8983
volumes:
- ./volumes/preliveCore/conf:/usr/bin/solr/preliveCore/conf
- SMUI_DEPLOY_PRELIVE_SOLR_HOST=solr1:8983
- SMUI_TOGGLE_DEPL_CUSTOM_SCRIPT=true
- SMUI_TOGGLE_DEPL_CUSTOM_SCRIPT_PATH=/smui/conf/smui2solrcloud.sh
- SMUI_DEPLOY_PRELIVE_FN_RULES_TXT=/configs/ecommerce/rules.txt
#volumes:
#- ./volumes/preliveCore/conf:/usr/bin/solr/preliveCore/conf
depends_on:
- mysql

Expand Down
2 changes: 1 addition & 1 deletion quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sleep 5
if [ ! -f ./icecat-products-150k-20200809.tar.gz ]; then
wget https://querqy.org/datasets/icecat/icecat-products-150k-20200809.tar.gz
fi
tar xzf icecat-products-150k-20200809.tar.gz --to-stdout | curl 'http://localhost:8983/solr/ecommerce/update?commit=true' --data-binary @- -H 'Content-type:application/json'
#tar xzf icecat-products-150k-20200809.tar.gz --to-stdout | curl 'http://localhost:8983/solr/ecommerce/update?commit=true' --data-binary @- -H 'Content-type:application/json'

SOLR_INDEX_ID=`curl -X PUT -H "Content-Type: application/json" -d '{"name":"ecommerce", "description":"Ecommerce Demo"}' http://localhost:9000/api/v1/solr-index | jq .returnId`
curl -X PUT -H "Content-Type: application/json" -d '{"name":"attr_t_product_type"}' http://localhost:9000/api/v1/{$SOLR_INDEX_ID}/suggested-solr-field
Expand Down
3 changes: 3 additions & 0 deletions smui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM querqy/smui:3.6.1

COPY conf/smui2solrcloud.sh /smui/conf/smui2solrcloud.sh
COPY conf/jackhanna-0.0.4-SNAPSHOT.jar /smui/conf/jackhanna-0.0.4-SNAPSHOT.jar

# This is a temporary shim to allow us to write to /usr/bin/solr/preliveCore/conf
# since the user running SMUI is smui.
USER root
Expand Down
Binary file added smui/conf/jackhanna-0.0.4-SNAPSHOT.jar
Binary file not shown.
85 changes: 85 additions & 0 deletions smui/conf/smui2solrcloud.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

set -euo pipefail

SRC_TMP_FILE=$1
DST_CP_FILE_TO=$2
SOLR_HOST=$3
SOLR_CORE_NAME=$4
DECOMPOUND_DST_CP_FILE_TO=$5
TARGET_SYSTEM=$6
#REPLACE_RULES_SRC_TMP_FILE=$7
REPLACE_RULES_SRC_TMP_FILE="NONE"
#REPLACE_RULES_DST_CP_FILE_TO=$8
REPLACE_RULES_DST_CP_FILE_TO="NONE"

echo "In smui2solrcloud.sh - script performing rules.txt update and core reload"
echo "^-- SRC_TMP_FILE = $SRC_TMP_FILE"
echo "^-- DST_CP_FILE_TO = $DST_CP_FILE_TO"
echo "^-- SOLR_HOST = $SOLR_HOST"
echo "^-- SOLR_CORE_NAME: $SOLR_CORE_NAME"
echo "^-- DECOMPOUND_DST_CP_FILE_TO = $DECOMPOUND_DST_CP_FILE_TO"
echo "^-- TARGET_SYSTEM = $TARGET_SYSTEM"
echo "^-- REPLACE_RULES_SRC_TMP_FILE = $REPLACE_RULES_SRC_TMP_FILE"
echo "^-- REPLACE_RULES_DST_CP_FILE_TO = $REPLACE_RULES_DST_CP_FILE_TO"

# DEPLOYMENT
#####

echo "^-- Perform rules.txt deployment (decompound-rules.txt eventually)"

# $1 - from_filename
# $2 - to_filename (might be local or remote)
function deploy_rules_txt {

echo "^-- ... pushing file ${1} to ZK at ${2}"

java -jar /smui/conf/jackhanna-0.0.4-SNAPSHOT.jar zoo1:2181 putfile --file ${1} --zkFile ${2}

}

echo "^-- ... rules.txt"
deploy_rules_txt $SRC_TMP_FILE $DST_CP_FILE_TO

echo "^-- ... decompound-rules.txt"
if ! [[ $DECOMPOUND_DST_CP_FILE_TO == "NONE" ]]
then
deploy_rules_txt "$SRC_TMP_FILE-2" $DECOMPOUND_DST_CP_FILE_TO
fi

echo "^-- ... replace-rules.txt"
if ! [[ $REPLACE_RULES_SRC_TMP_FILE == "NONE" && $REPLACE_RULES_DST_CP_FILE_TO == "NONE" ]]
then
deploy_rules_txt $REPLACE_RULES_SRC_TMP_FILE $REPLACE_RULES_DST_CP_FILE_TO
fi

# CORE RELOAD
#####

echo "^-- Perform collection reload for SOLR_HOST = $SOLR_HOST, SOLR_CORE_NAME = $SOLR_CORE_NAME"

if ! [[ $SOLR_HOST == "NONE" ]]
then
# TODO only core reload over http possible. make configurable.
SOLR_STATUS=$(curl -s -i -XGET "http://$SOLR_HOST/solr/admin/collections?wt=xml&action=RELOAD&name=$SOLR_CORE_NAME")

if [ $? -ne 0 ]; then
exit 16
fi

if ! [[ $SOLR_STATUS == *"200 OK"* ]]
then
>&2 echo "Error reloading Solr collection: $SOLR_STATUS"
exit 17
fi

if ! [[ $SOLR_STATUS == *"<int name=\"status\">0</int>"* ]]
then
>&2 echo "Error reloading Solr collection: $SOLR_STATUS"
exit 18
fi
fi

# all ok
echo "smui2solrcloud.sh - ok"
exit 0
1 change: 0 additions & 1 deletion solr/solr_home/ecommerce/conf/solrconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
The file that contains rules for synonyms,
boosting etc.
-->
<!--str name="rules">querqy/rules.txt</str-->
<str name="rules">rules.txt</str>
<!--
If true, case will be ignored while trying to find
Expand Down
Empty file removed volumes/preliveCore/conf/rules.txt
Empty file.

0 comments on commit 58e5019

Please sign in to comment.