From 03f1db571e68d12e353130eeef7d8da84262b634 Mon Sep 17 00:00:00 2001 From: rodorad Date: Thu, 8 Dec 2016 14:53:27 -0800 Subject: [PATCH 1/4] test build if mar files exist. --- docker/Dockerfile | 2 + docker/build.sh | 51 ++++++++++++++++++- model-scoring-core/bin/model-scoring.sh | 3 -- model-scoring-core/bin/scoring-server.sh | 2 +- .../conf/application.conf.scoring | 2 +- 5 files changed, 53 insertions(+), 7 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index d18eebc..ac71a65 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,6 +9,8 @@ USER modelscoring WORKDIR /home/modelscoring/ ADD $MODEL_SCORING_PACKAGE . +EXPOSE 9100 + WORKDIR /home/modelscoring/ ENTRYPOINT [ "bin/model-scoring.sh" ] diff --git a/docker/build.sh b/docker/build.sh index f325257..a6e5128 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -37,7 +37,7 @@ echo Base name $NAME NAME=${NAME//.zip/} echo Base name $NAME -echo docker build --file=Dockerfile --tag=scoring-engine \ +echo docker build --file=Dockerfile --tag=scoring-engine-$BUILD_NUMBER \ --build-arg HTTP_PROXY=$http_proxy \ --build-arg HTTPS_PROXY=$http_proxy \ --build-arg NO_PROXY=$no_proxy \ @@ -46,7 +46,7 @@ echo docker build --file=Dockerfile --tag=scoring-engine \ --build-arg no_proxy=$no_proxy \ --build-arg MODEL_SCORING_PACKAGE=$NAME \ . -docker build --file=Dockerfile --tag=scoring-engine \ +docker build --file=Dockerfile --tag=scoring-engine-$BUILD_NUMBER \ --build-arg HTTP_PROXY=$http_proxy \ --build-arg HTTPS_PROXY=$http_proxy \ --build-arg NO_PROXY=$no_proxy \ @@ -56,3 +56,50 @@ docker build --file=Dockerfile --tag=scoring-engine \ --build-arg MODEL_SCORING_PACKAGE=$NAME \ . +mars=$(find `pwd` -name "*.mar" -type f ) +IFS=$'\n' +for mar in $mars +do + echo + echo $mar + MARNAME="`basename $mar`" + echo Base name $MARNAME + MARNAME=${MARNAME//.mar/} + echo Base name $MARNAME + docker kill $MARNAME-$BUILD_NUMBER + docker rm $MARNAME-$BUILD_NUMBER +done + +for mar in $mars +do + echo + echo $mar + MARNAME="`basename $mar`" + echo Base name $MARNAME + MARNAME=${MARNAME//.mar/} + echo Base name $MARNAME + DOCKERCONT=$MARNAME-$BUILD_NUMBER + docker kill $DOCKERCONT + docker rm $DOCKERCONT + docker run -it -d -p 9100:9100 --name=$DOCKERCONT scoring-engine-5 + MAX=20 + code=$(curl -s -o /dev/null localhost:9100 -w "%{http_code}") + count=$((0)) + while [ $code -ne 200 ] || [ $count -gt $MAX ]; + do + echo $code + code=$(curl -s -o /dev/null localhost:9100 -w "%{http_code}") + count=$((0+1)) + sleep 1 + done + code=$(curl -F "file=@$mar" -s -o /dev/null localhost:9100/uploadMarFile -w "%{http_code}") + if [ $code -ge 200 ] && [ $code -lt 400 ]; then + echo yes $code + else + echo failed to load model $mar, http status code $code + docker logs $DOCKERCONT + exit 1 + fi + docker kill $DOCKERCONT + docker rm $DOCKERCONT +done \ No newline at end of file diff --git a/model-scoring-core/bin/model-scoring.sh b/model-scoring-core/bin/model-scoring.sh index 663762e..d48f902 100755 --- a/model-scoring-core/bin/model-scoring.sh +++ b/model-scoring-core/bin/model-scoring.sh @@ -27,11 +27,8 @@ export HOSTNAME=`hostname` # It is difficult to modify the library path for dynamic libraries after the Java process has started # LD_LIBRARY_PATH allows the OS to find the dynamic libraries and any dependencies export MODEL_TMP_DIR=`mktemp -d -t tap-scoring-modelXXXXXXXXXXXXXXXXXX` - - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MODEL_TMP_DIR - MODEL_SCORING_MAIN="org.trustedanalytics.scoring.MyMainFunction" diff --git a/model-scoring-core/bin/scoring-server.sh b/model-scoring-core/bin/scoring-server.sh index 53444b3..77f8fe5 100755 --- a/model-scoring-core/bin/scoring-server.sh +++ b/model-scoring-core/bin/scoring-server.sh @@ -15,10 +15,10 @@ # limitations under the License. # -#set -o errexit DIR="$( cd "$( dirname "$0" )" && pwd )" pushd $DIR/.. + pwd export HOSTNAME=`hostname` diff --git a/model-scoring-core/conf/application.conf.scoring b/model-scoring-core/conf/application.conf.scoring index e55924b..ecf9d0e 100644 --- a/model-scoring-core/conf/application.conf.scoring +++ b/model-scoring-core/conf/application.conf.scoring @@ -2,7 +2,7 @@ #The mar file path can be provided on the command line with a java property #-Dtrustedanalytics.scoring-engine.archive-mar="SOME_PATH" trustedanalytics.scoring-engine { - archive-mar = "hdfs://SOME_PATH/SOME_TAR" + archive-mar = "" } #-Dtrustedanalytics.scoring.port="SOME_PORT" From 14e01a27a2f5e6d7a9f7019f60062f95b82a2188 Mon Sep 17 00:00:00 2001 From: rodorad Date: Thu, 8 Dec 2016 15:29:01 -0800 Subject: [PATCH 2/4] fix mvn warnings --- model-scoring-core/pom.xml | 3 --- pom.xml | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/model-scoring-core/pom.xml b/model-scoring-core/pom.xml index e7ec13d..11e3afc 100644 --- a/model-scoring-core/pom.xml +++ b/model-scoring-core/pom.xml @@ -69,9 +69,6 @@ - - maven-compiler-plugin - net.alchim31.maven scala-maven-plugin diff --git a/pom.xml b/pom.xml index ab84b67..04108ac 100644 --- a/pom.xml +++ b/pom.xml @@ -130,7 +130,9 @@ 1.3.2 + org.apache.maven.plugins maven-compiler-plugin + 3.6.0 default-compile @@ -258,11 +260,9 @@ + org.apache.maven.plugins maven-compiler-plugin - - - com.mycila - license-maven-plugin + 3.6.0 com.mycila From 06bd5483797dc108b42481deaac9fae9e05b532c Mon Sep 17 00:00:00 2001 From: rodorad Date: Thu, 8 Dec 2016 15:41:17 -0800 Subject: [PATCH 3/4] fix docker image test name --- docker/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/build.sh b/docker/build.sh index a6e5128..cd8934b 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -81,11 +81,11 @@ do DOCKERCONT=$MARNAME-$BUILD_NUMBER docker kill $DOCKERCONT docker rm $DOCKERCONT - docker run -it -d -p 9100:9100 --name=$DOCKERCONT scoring-engine-5 + docker run -it -d -p 9100:9100 --name=$DOCKERCONT scoring-engine-$BUILD_NUMBER MAX=20 code=$(curl -s -o /dev/null localhost:9100 -w "%{http_code}") count=$((0)) - while [ $code -ne 200 ] || [ $count -gt $MAX ]; + while [ $code -ne 200 ] && [ $count -gt $MAX ]; do echo $code code=$(curl -s -o /dev/null localhost:9100 -w "%{http_code}") From 91f4635cbcac0039e09cf4a9be9735910680fb1e Mon Sep 17 00:00:00 2001 From: rodorad Date: Thu, 8 Dec 2016 15:46:42 -0800 Subject: [PATCH 4/4] fix while condition --- docker/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/build.sh b/docker/build.sh index cd8934b..dc26c3c 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -85,7 +85,7 @@ do MAX=20 code=$(curl -s -o /dev/null localhost:9100 -w "%{http_code}") count=$((0)) - while [ $code -ne 200 ] && [ $count -gt $MAX ]; + while [ $code -ne 200 ] && [ $count -lt $MAX ]; do echo $code code=$(curl -s -o /dev/null localhost:9100 -w "%{http_code}")