From f1cb31665a687d9c13f04c27f6e659cb016944d0 Mon Sep 17 00:00:00 2001 From: Howard Yoo Date: Mon, 4 May 2020 21:54:31 -0500 Subject: [PATCH 01/18] version 2 of springboot jersey app This is a successor of the springboot jersey app, but does not use jersey anymore - it comes with more modern spring boot, as well as uses eureka for service discovery and load balancing. --- .../springboot-jersey-app-2/common/mvnw | 310 ++++++++++++++++++ .../springboot-jersey-app-2/common/mvnw.cmd | 182 ++++++++++ .../springboot-jersey-app-2/common/pom.xml | 63 ++++ .../java/com/wfsample/bean/ServiceBean.java | 27 ++ .../common/dto/DeliveryStatusDTO.java | 45 +++ .../com/wfsample/common/dto/OrderDTO.java | 27 ++ .../wfsample/common/dto/OrderStatusDTO.java | 35 ++ .../wfsample/common/dto/PackedShirtsDTO.java | 27 ++ .../com/wfsample/common/dto/ResponseDTO.java | 118 +++++++ .../com/wfsample/common/dto/ShirtDTO.java | 25 ++ .../wfsample/common/dto/ShirtStyleDTO.java | 35 ++ .../com/wfsample/service/DeliveryService.java | 33 ++ .../com/wfsample/service/ShoppingService.java | 27 ++ .../com/wfsample/service/StylingService.java | 46 +++ .../src/main/resources/application.properties | 1 + .../springboot-jersey-app-2/delivery/mvnw | 310 ++++++++++++++++++ .../springboot-jersey-app-2/delivery/mvnw.cmd | 182 ++++++++++ .../springboot-jersey-app-2/delivery/pom.xml | 52 +++ .../delivery/DeliveryApplication.java | 16 + .../delivery/DeliveryController.java | 101 ++++++ .../src/main/resources/application.properties | 1 + .../main/resources/delivery-application.yml | 14 + .../delivery/DeliveryApplicationTests.java | 13 + .../springboot-jersey-app-2/loadgen.sh | 13 + .../springboot-jersey-app-2/mvnw | 310 ++++++++++++++++++ .../springboot-jersey-app-2/mvnw.cmd | 182 ++++++++++ .../springboot-jersey-app-2/pom.xml | 106 ++++++ .../springboot-jersey-app-2/registration/mvnw | 310 ++++++++++++++++++ .../registration/mvnw.cmd | 182 ++++++++++ .../registration/pom.xml | 67 ++++ .../registration/RegistrationApplication.java | 17 + .../src/main/resources/application.properties | 1 + .../main/resources/registration-server.yml | 25 ++ .../RegistrationApplicationTests.java | 13 + .../shopping/ShoppingApplicationTests.java | 13 + .../springboot-jersey-app-2/shopping/mvnw | 310 ++++++++++++++++++ .../springboot-jersey-app-2/shopping/mvnw.cmd | 182 ++++++++++ .../springboot-jersey-app-2/shopping/pom.xml | 72 ++++ .../shopping/ShoppingApplication.java | 16 + .../shopping/ShoppingController.java | 59 ++++ .../src/main/resources/application.properties | 1 + .../main/resources/shopping-application.yml | 14 + .../shopping/ShoppingApplicationTests.java | 13 + .../springboot-jersey-app-2/styling/mvnw | 310 ++++++++++++++++++ .../springboot-jersey-app-2/styling/mvnw.cmd | 182 ++++++++++ .../springboot-jersey-app-2/styling/pom.xml | 72 ++++ .../wavefront/styling/StylingApplication.java | 16 + .../wavefront/styling/StylingController.java | 90 +++++ .../src/main/resources/application.properties | 1 + .../main/resources/styling-application.yml | 14 + .../styling/StylingApplicationTests.java | 13 + 51 files changed, 4294 insertions(+) create mode 100755 3D-microservices-observability/springboot-jersey-app-2/common/mvnw create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/mvnw.cmd create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/pom.xml create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/bean/ServiceBean.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/DeliveryStatusDTO.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/OrderDTO.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/OrderStatusDTO.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/PackedShirtsDTO.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/ResponseDTO.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/ShirtDTO.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/ShirtStyleDTO.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/DeliveryService.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/ShoppingService.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/StylingService.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/src/main/resources/application.properties create mode 100755 3D-microservices-observability/springboot-jersey-app-2/delivery/mvnw create mode 100644 3D-microservices-observability/springboot-jersey-app-2/delivery/mvnw.cmd create mode 100644 3D-microservices-observability/springboot-jersey-app-2/delivery/pom.xml create mode 100644 3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/java/com/wavefront/delivery/DeliveryApplication.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/java/com/wavefront/delivery/DeliveryController.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/application.properties create mode 100644 3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/delivery-application.yml create mode 100644 3D-microservices-observability/springboot-jersey-app-2/delivery/src/test/java/com/wavefront/delivery/DeliveryApplicationTests.java create mode 100755 3D-microservices-observability/springboot-jersey-app-2/loadgen.sh create mode 100755 3D-microservices-observability/springboot-jersey-app-2/mvnw create mode 100644 3D-microservices-observability/springboot-jersey-app-2/mvnw.cmd create mode 100644 3D-microservices-observability/springboot-jersey-app-2/pom.xml create mode 100755 3D-microservices-observability/springboot-jersey-app-2/registration/mvnw create mode 100644 3D-microservices-observability/springboot-jersey-app-2/registration/mvnw.cmd create mode 100644 3D-microservices-observability/springboot-jersey-app-2/registration/pom.xml create mode 100644 3D-microservices-observability/springboot-jersey-app-2/registration/src/main/java/com/wavefront/registration/RegistrationApplication.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/registration/src/main/resources/application.properties create mode 100644 3D-microservices-observability/springboot-jersey-app-2/registration/src/main/resources/registration-server.yml create mode 100644 3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/registration/RegistrationApplicationTests.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/shopping/ShoppingApplicationTests.java create mode 100755 3D-microservices-observability/springboot-jersey-app-2/shopping/mvnw create mode 100644 3D-microservices-observability/springboot-jersey-app-2/shopping/mvnw.cmd create mode 100644 3D-microservices-observability/springboot-jersey-app-2/shopping/pom.xml create mode 100644 3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/java/com/wavefront/shopping/ShoppingApplication.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/java/com/wavefront/shopping/ShoppingController.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/resources/application.properties create mode 100644 3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/resources/shopping-application.yml create mode 100644 3D-microservices-observability/springboot-jersey-app-2/shopping/src/test/java/com/wavefront/shopping/ShoppingApplicationTests.java create mode 100755 3D-microservices-observability/springboot-jersey-app-2/styling/mvnw create mode 100644 3D-microservices-observability/springboot-jersey-app-2/styling/mvnw.cmd create mode 100644 3D-microservices-observability/springboot-jersey-app-2/styling/pom.xml create mode 100644 3D-microservices-observability/springboot-jersey-app-2/styling/src/main/java/com/wavefront/styling/StylingApplication.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/styling/src/main/java/com/wavefront/styling/StylingController.java create mode 100644 3D-microservices-observability/springboot-jersey-app-2/styling/src/main/resources/application.properties create mode 100644 3D-microservices-observability/springboot-jersey-app-2/styling/src/main/resources/styling-application.yml create mode 100644 3D-microservices-observability/springboot-jersey-app-2/styling/src/test/java/com/wavefront/styling/StylingApplicationTests.java diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/mvnw b/3D-microservices-observability/springboot-jersey-app-2/common/mvnw new file mode 100755 index 0000000..a16b543 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/mvnw.cmd b/3D-microservices-observability/springboot-jersey-app-2/common/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/pom.xml b/3D-microservices-observability/springboot-jersey-app-2/common/pom.xml new file mode 100644 index 0000000..3fbd9f0 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/pom.xml @@ -0,0 +1,63 @@ + + + 4.0.0 + + com.wavefront + springboot-jersey-app-2 + 0.0.1-SNAPSHOT + + com.wavefront + common + 0.0.1-SNAPSHOT + common + set of common libraries + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/bean/ServiceBean.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/bean/ServiceBean.java new file mode 100644 index 0000000..2addfc9 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/bean/ServiceBean.java @@ -0,0 +1,27 @@ +package com.wfsample.bean; +import com.wfsample.service.*; + +import org.springframework.cloud.client.loadbalancer.LoadBalanced; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +@Component +public class ServiceBean { + + @LoadBalanced // Make sure to create the load-balanced template + @Bean + RestTemplate restTemplate() { + return new RestTemplate(); + } + + @Bean + public DeliveryService getDeliveryServiceBean() { + return new DeliveryService(DeliveryService.DELIVERY_SERVICE_URL); + } + + @Bean + public StylingService getStylingServiceBean() { + return new StylingService(StylingService.STYLING_SERVICE_URL); + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/DeliveryStatusDTO.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/DeliveryStatusDTO.java new file mode 100644 index 0000000..6b3e2a1 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/DeliveryStatusDTO.java @@ -0,0 +1,45 @@ +package com.wfsample.common.dto; + +/** + * DTO for delivery status for shirts. + * + * @author Srujan Narkedamalli (snarkedamall@wavefront.com). + */ +public class DeliveryStatusDTO { + String orderNum; + String trackingNum; + String status; + + public DeliveryStatusDTO() { + } + + public DeliveryStatusDTO(String orderNum, String trackingNum, String status) { + this.trackingNum = trackingNum; + this.orderNum = orderNum; + this.status = status; + } + + public String getOrderNum() { + return orderNum; + } + + public void setOrderNum(String orderNum) { + this.orderNum = orderNum; + } + + public String getTrackingNum() { + return trackingNum; + } + + public void setTrackingNum(String trackingNum) { + this.trackingNum = trackingNum; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/OrderDTO.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/OrderDTO.java new file mode 100644 index 0000000..776a897 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/OrderDTO.java @@ -0,0 +1,27 @@ +package com.wfsample.common.dto; + +/** + * DTO for a beachshirts order. + * + * @author Srujan Narkedamalli (snarkedamall@wavefront.com). + */ +public class OrderDTO { + String styleName; + int quantity; + + public String getStyleName() { + return styleName; + } + + public void setStyleName(String styleName) { + this.styleName = styleName; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/OrderStatusDTO.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/OrderStatusDTO.java new file mode 100644 index 0000000..453be08 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/OrderStatusDTO.java @@ -0,0 +1,35 @@ +package com.wfsample.common.dto; + +/** + * DTO for a beachshirts order status. + * + * @author Srujan Narkedamalli (snarkedamall@wavefront.com). + */ +public class OrderStatusDTO { + String orderId; + String status; + + public OrderStatusDTO() { + } + + public OrderStatusDTO(String orderId, String status) { + this.orderId = orderId; + this.status = status; + } + + public String getStatus() { + return status; + } + + public void setStatus(String statusMessage) { + this.status = statusMessage; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/PackedShirtsDTO.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/PackedShirtsDTO.java new file mode 100644 index 0000000..2832b72 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/PackedShirtsDTO.java @@ -0,0 +1,27 @@ +package com.wfsample.common.dto; + +import java.util.List; + +/** + * DTO for packed beachshirts after the order is completed. + * + * @author Srujan Narkedamalli (snarkedamall@wavefront.com). + */ +public class PackedShirtsDTO { + List shirts; + + public PackedShirtsDTO() { + } + + public PackedShirtsDTO(List shirts) { + this.shirts = shirts; + } + + public List getShirts() { + return shirts; + } + + public void setShirts(List shirts) { + this.shirts = shirts; + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/ResponseDTO.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/ResponseDTO.java new file mode 100644 index 0000000..8259903 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/ResponseDTO.java @@ -0,0 +1,118 @@ +package com.wfsample.common.dto; + +public class ResponseDTO { + private String status; + private String message; + private DeliveryStatusDTO deliveryStatusDTO; + private OrderDTO orderDTO; + private OrderStatusDTO orderStatusDTO; + private PackedShirtsDTO packedShirtsDTO; + private ShirtDTO shirtDTO; + private ShirtStyleDTO shirtStyleDTO; + + + public String getStatus() { + return status; + } + + public String getMessage() { + return message; + } + + public void setStatus(String status) { + this.status = status; + } + + public void setMessage(String message) { + this.message = message; + } + + public DeliveryStatusDTO getDeliveryStatusDTO() { + return deliveryStatusDTO; + } + + public void setDeliveryStatusDTO(DeliveryStatusDTO deliveryStatusDTO) { + this.deliveryStatusDTO = deliveryStatusDTO; + } + + public OrderDTO getOrderDTO() { + return orderDTO; + } + + public void setOrderDTO(OrderDTO orderDTO) { + this.orderDTO = orderDTO; + } + + public OrderStatusDTO getOrderStatudDTO() { + return orderStatusDTO; + } + + public void setOrderStatudDTO(OrderStatusDTO orderStatudDTO) { + this.orderStatusDTO = orderStatudDTO; + } + + public PackedShirtsDTO getPackedShirtsDTO() { + return packedShirtsDTO; + } + + public void setPackedShirtsDTO(PackedShirtsDTO packedShirtsDTO) { + this.packedShirtsDTO = packedShirtsDTO; + } + + public ShirtDTO getShirtDTO() { + return shirtDTO; + } + + public void setShirtDTO(ShirtDTO shirtDTO) { + this.shirtDTO = shirtDTO; + } + + public ShirtStyleDTO getShirtStyleDTO() { + return shirtStyleDTO; + } + + public void setShirtStyleDTO(ShirtStyleDTO shirtStyleDTO) { + this.shirtStyleDTO = shirtStyleDTO; + } + + public static ResponseDTO ok() { + ResponseDTO response = new ResponseDTO(); + response.setStatus("OK"); + return response; + } + + public ResponseDTO entity(OrderStatusDTO statusDTO) { + this.orderStatusDTO = statusDTO; + return this; + } + + public ResponseDTO entity(DeliveryStatusDTO statusDTO) { + this.deliveryStatusDTO = statusDTO; + return this; + } + + public ResponseDTO entity(OrderDTO orderDTO) { + this.orderDTO = orderDTO; + return this; + } + + public ResponseDTO entity(PackedShirtsDTO packedDTO) { + this.packedShirtsDTO = packedDTO; + return this; + } + + public ResponseDTO msg(String msg) { + this.message = msg; + return this; + } + + public static ResponseDTO status(String status) { + ResponseDTO response = new ResponseDTO(); + response.setStatus(status); + return response; + } + + public ResponseDTO build() { + return this; + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/ShirtDTO.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/ShirtDTO.java new file mode 100644 index 0000000..3220345 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/ShirtDTO.java @@ -0,0 +1,25 @@ +package com.wfsample.common.dto; + +/** + * DTO for beach shirt. + * + * @author Srujan Narkedamalli (snarkedamall@wavefront.com). + */ +public class ShirtDTO { + ShirtStyleDTO style; + + public ShirtDTO() { + } + + public ShirtDTO(ShirtStyleDTO style) { + this.style = style; + } + + public ShirtStyleDTO getStyle() { + return style; + } + + public void setStyle(ShirtStyleDTO style) { + this.style = style; + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/ShirtStyleDTO.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/ShirtStyleDTO.java new file mode 100644 index 0000000..e3b87ca --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/common/dto/ShirtStyleDTO.java @@ -0,0 +1,35 @@ +package com.wfsample.common.dto; + +/** + * DTO for a beach shirt style. + * + * @author Srujan Narkedamalli (snarkedamall@wavefront.com). + */ +public class ShirtStyleDTO { + String name; + String imageUrl; + + public ShirtStyleDTO() { + } + + public ShirtStyleDTO(String name, String imageUrl) { + this.name = name; + this.imageUrl = imageUrl; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getImageUrl() { + return imageUrl; + } + + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/DeliveryService.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/DeliveryService.java new file mode 100644 index 0000000..eaacb9e --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/DeliveryService.java @@ -0,0 +1,33 @@ +package com.wfsample.service; + +import com.wfsample.common.dto.PackedShirtsDTO; +import com.wfsample.common.dto.ResponseDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.client.loadbalancer.LoadBalanced; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + + +@Service +public class DeliveryService { + + @Autowired + @LoadBalanced + protected RestTemplate restTemplate; + public static final String DELIVERY_SERVICE_URL = "http://DELIVERY-SERVICE"; + protected String serviceUrl; + + public DeliveryService(String serviceUrl) { + this.serviceUrl = serviceUrl.startsWith("http") ? + serviceUrl : "http://" + serviceUrl; + } + + public ResponseDTO getHello() { + ResponseDTO response = restTemplate.getForObject(serviceUrl + "/hello", ResponseDTO.class); + return response; + } + + public ResponseDTO dispatch(String orderNum, PackedShirtsDTO packedShirtsDTO) { + return restTemplate.postForObject(serviceUrl + "/dispatch/" + orderNum, packedShirtsDTO, ResponseDTO.class); + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/ShoppingService.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/ShoppingService.java new file mode 100644 index 0000000..c25d2ea --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/ShoppingService.java @@ -0,0 +1,27 @@ +package com.wfsample.service; + +import com.wfsample.common.dto.ResponseDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.client.loadbalancer.LoadBalanced; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +@Service +public class ShoppingService { + + @Autowired + @LoadBalanced + protected RestTemplate restTemplate; + public static final String STYLING_SERVICE_URL = "http://SHOPPING-SERVICE"; + protected String serviceUrl; + + public ShoppingService(String serviceUrl) { + this.serviceUrl = serviceUrl.startsWith("http") ? + serviceUrl : "http://" + serviceUrl; + } + + public ResponseDTO getHello() { + ResponseDTO response = restTemplate.getForObject(serviceUrl + "/hello", ResponseDTO.class); + return response; + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/StylingService.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/StylingService.java new file mode 100644 index 0000000..d3c9847 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/StylingService.java @@ -0,0 +1,46 @@ +package com.wfsample.service; + +import com.wfsample.common.dto.OrderDTO; +import com.wfsample.common.dto.ResponseDTO; +import com.wfsample.common.dto.ShirtStyleDTO; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.client.loadbalancer.LoadBalanced; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class StylingService { + + @Autowired + @LoadBalanced + protected RestTemplate restTemplate; + public static final String STYLING_SERVICE_URL = "http://STYLING-SERVICE"; + protected String serviceUrl; + + public StylingService(String serviceUrl) { + this.serviceUrl = serviceUrl.startsWith("http") ? + serviceUrl : "http://" + serviceUrl; + } + + public ResponseDTO getHello() { + ResponseDTO response = restTemplate.getForObject(serviceUrl + "/hello", ResponseDTO.class); + return response; + } + + public List getAllStyles() { + List response = restTemplate.getForObject(serviceUrl + "/styles", new ArrayList().getClass()); + return response; + } + + public ResponseDTO makeShirts(String styleName, int quantity) { + String requestUrl = serviceUrl + "/shirts"; + OrderDTO order = new OrderDTO(); + order.setStyleName(styleName); + order.setQuantity(quantity); + return restTemplate.postForObject(requestUrl, order, ResponseDTO.class); + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/resources/application.properties b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/3D-microservices-observability/springboot-jersey-app-2/delivery/mvnw b/3D-microservices-observability/springboot-jersey-app-2/delivery/mvnw new file mode 100755 index 0000000..a16b543 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/delivery/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/3D-microservices-observability/springboot-jersey-app-2/delivery/mvnw.cmd b/3D-microservices-observability/springboot-jersey-app-2/delivery/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/delivery/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/3D-microservices-observability/springboot-jersey-app-2/delivery/pom.xml b/3D-microservices-observability/springboot-jersey-app-2/delivery/pom.xml new file mode 100644 index 0000000..a0689db --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/delivery/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + com.wavefront + springboot-jersey-app-2 + 0.0.1-SNAPSHOT + + com.wavefront + delivery + 0.0.1-SNAPSHOT + delivery + Demo project for Spring Boot + + + 1.8 + + + + + com.wavefront + common + 0.0.1-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/java/com/wavefront/delivery/DeliveryApplication.java b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/java/com/wavefront/delivery/DeliveryApplication.java new file mode 100644 index 0000000..8ceb3e8 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/java/com/wavefront/delivery/DeliveryApplication.java @@ -0,0 +1,16 @@ +package com.wavefront.delivery; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class DeliveryApplication { + + public static void main(String[] args) { + System.setProperty("spring.config.name", "delivery-application"); + SpringApplication.run(DeliveryApplication.class, args); + } + +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/java/com/wavefront/delivery/DeliveryController.java b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/java/com/wavefront/delivery/DeliveryController.java new file mode 100644 index 0000000..19c1f34 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/java/com/wavefront/delivery/DeliveryController.java @@ -0,0 +1,101 @@ +package com.wavefront.delivery; + +import com.wfsample.common.dto.DeliveryStatusDTO; +import com.wfsample.common.dto.PackedShirtsDTO; +import com.wfsample.common.dto.ResponseDTO; + +import org.springframework.http.MediaType; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import java.util.Queue; +import java.util.UUID; +import java.util.concurrent.ConcurrentLinkedDeque; +import java.util.concurrent.ThreadLocalRandom; +import java.util.logging.Logger; + +@RestController +@RequestMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE) +public class DeliveryController { + + /* + * TODO: Add a gauge to monitor the size of dispatch queue. + * Also, consider adding relevant ApplicationTags for this metric. + */ + private static Queue dispatchQueue ; + protected Logger logger = Logger.getLogger(DeliveryController.class.getName()); + static { + dispatchQueue = new ConcurrentLinkedDeque<>(); + } + + @GetMapping(path="/hello") + public ResponseDTO hello() { + return ResponseDTO.ok().msg("hello from Delivery Service").build(); + } + + @PostMapping(path="/dispatch/{orderNum}") + public ResponseDTO dispatch(@RequestBody PackedShirtsDTO packedShirts, @PathVariable("orderNum") String orderNum) { + ResponseDTO response = new ResponseDTO(); + if (ThreadLocalRandom.current().nextInt(0, 5) == 0) { + String msg = "Failed to dispatch shirts!"; + logger.warning(msg); + return ResponseDTO.status("SERVICE UNAVAILABLE").msg(msg).build(); + } + if (orderNum.isEmpty()) { + /* + * TODO: Try to emitting an error metrics with relevant ApplicationTags to Wavefront. + */ + String msg = "Invalid Order Num"; + logger.warning(msg); + return ResponseDTO.status("BAD REQUEST").msg(msg).build(); + } + if (packedShirts == null || packedShirts.getShirts() == null || + packedShirts.getShirts().size() == 0) { + /* + * TODO: Try to emitting an error metrics with relevant ApplicationTags to Wavefront. + */ + String msg = "No shirts to deliver"; + logger.warning(msg); + return ResponseDTO.status("BAD REQUEST").msg(msg).build(); + } + dispatchQueue.add(packedShirts); + String trackingNum = UUID.randomUUID().toString(); + return ResponseDTO.ok().entity(new DeliveryStatusDTO(orderNum, trackingNum, + "shirts delivery dispatched")); + } + + @GetMapping(path="/retrieve/{orderNum}") + public ResponseDTO retrieve(@PathVariable("orderNum") String orderNum) { + if (orderNum.isEmpty()) { + /* + * TODO: Try to emitting an error metrics with relevant ApplicationTags to Wavefront. + */ + String msg = "Invalid Order Num"; + logger.warning(msg); + return ResponseDTO.status("BAD REQUEST").msg(msg).build(); + } + return ResponseDTO.ok().msg("Order: " + orderNum + " returned").build(); + } + + @Scheduled(fixedRate = 30000) + private void processQueue() { + System.out.println("Processing " + dispatchQueue.size() + " in the Dispatch Queue!"); + while (!dispatchQueue.isEmpty()) { + deliverPackedShirts(dispatchQueue.poll()); + } + } + + private void deliverPackedShirts(PackedShirtsDTO packedShirtsDTO) { + for (int i = 0; i < packedShirtsDTO.getShirts().size(); i++) { + /* + * TODO: Try to Increment a delta counter when shirts are delivered. + * Also, consider adding relevant ApplicationTags for this metric. + */ + } + System.out.println(packedShirtsDTO.getShirts().size() + " shirts delivered!"); + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/application.properties b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/delivery-application.yml b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/delivery-application.yml new file mode 100644 index 0000000..343e62d --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/delivery-application.yml @@ -0,0 +1,14 @@ +# Spring properties +spring: + application: + name: delivery-service + +# Discovery Server Access +eureka: + client: + serviceUrl: + defaultZone: http://localhost:1111/eureka/ + +# HTTP Server +server: + port: 2222 # HTTP (Tomcat) port \ No newline at end of file diff --git a/3D-microservices-observability/springboot-jersey-app-2/delivery/src/test/java/com/wavefront/delivery/DeliveryApplicationTests.java b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/test/java/com/wavefront/delivery/DeliveryApplicationTests.java new file mode 100644 index 0000000..515d4c3 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/test/java/com/wavefront/delivery/DeliveryApplicationTests.java @@ -0,0 +1,13 @@ +package com.wavefront.delivery; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class DeliveryApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/loadgen.sh b/3D-microservices-observability/springboot-jersey-app-2/loadgen.sh new file mode 100755 index 0000000..ca86383 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/loadgen.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +echo "Send requests every $1 seconds" + +while [ true ] +do + quantity=$((1 + RANDOM % 20)) + curl_cmd="curl -X POST http://localhost:4444/order -H 'Content-Type: application/json' -d '{\"styleName\": \"beachops\", \"quantity\": '$quantity'}'" + echo $curl_cmd + eval $curl_cmd + sleep $1 + printf "\n" +done \ No newline at end of file diff --git a/3D-microservices-observability/springboot-jersey-app-2/mvnw b/3D-microservices-observability/springboot-jersey-app-2/mvnw new file mode 100755 index 0000000..a16b543 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/3D-microservices-observability/springboot-jersey-app-2/mvnw.cmd b/3D-microservices-observability/springboot-jersey-app-2/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/3D-microservices-observability/springboot-jersey-app-2/pom.xml b/3D-microservices-observability/springboot-jersey-app-2/pom.xml new file mode 100644 index 0000000..7cbac02 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/pom.xml @@ -0,0 +1,106 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.3.0.RC1 + + + com.wavefront + springboot-jersey-app-2 + 0.0.1-SNAPSHOT + springboot-jersey-app-2 + springboot jersey v2 + + + 1.8 + 1.8 + 1.8 + + + + common + registration + delivery + styling + shopping + + + + + org.springframework.boot + spring-boot-starter-jersey + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + + + org.springframework.cloud + spring-cloud-starter + + + + + org.springframework.cloud + spring-cloud-starter-eureka-server + LATEST + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + Hoxton.RELEASE + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + pom + + diff --git a/3D-microservices-observability/springboot-jersey-app-2/registration/mvnw b/3D-microservices-observability/springboot-jersey-app-2/registration/mvnw new file mode 100755 index 0000000..a16b543 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/registration/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/3D-microservices-observability/springboot-jersey-app-2/registration/mvnw.cmd b/3D-microservices-observability/springboot-jersey-app-2/registration/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/registration/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/3D-microservices-observability/springboot-jersey-app-2/registration/pom.xml b/3D-microservices-observability/springboot-jersey-app-2/registration/pom.xml new file mode 100644 index 0000000..8370ed4 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/registration/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + + com.wavefront + springboot-jersey-app-2 + 0.0.1-SNAPSHOT + + com.wavefront + registration + 0.0.1-SNAPSHOT + registration + Demo project for Spring Boot + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-jersey + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + diff --git a/3D-microservices-observability/springboot-jersey-app-2/registration/src/main/java/com/wavefront/registration/RegistrationApplication.java b/3D-microservices-observability/springboot-jersey-app-2/registration/src/main/java/com/wavefront/registration/RegistrationApplication.java new file mode 100644 index 0000000..a422faa --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/registration/src/main/java/com/wavefront/registration/RegistrationApplication.java @@ -0,0 +1,17 @@ +package com.wavefront.registration; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; + +@SpringBootApplication +@EnableEurekaServer +public class RegistrationApplication { + + public static void main(String[] args) { + // Tell Boot to look for registration-server.yml + System.setProperty("spring.config.name", "registration-server"); + SpringApplication.run(RegistrationApplication.class, args); + } + +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/registration/src/main/resources/application.properties b/3D-microservices-observability/springboot-jersey-app-2/registration/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/registration/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/3D-microservices-observability/springboot-jersey-app-2/registration/src/main/resources/registration-server.yml b/3D-microservices-observability/springboot-jersey-app-2/registration/src/main/resources/registration-server.yml new file mode 100644 index 0000000..67366db --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/registration/src/main/resources/registration-server.yml @@ -0,0 +1,25 @@ +# Ignore JDBC Dependency +# This demo puts 3 applicatons in the same project so they all pick up the +# JDBC Depdendency, but this application doesn't need it. +spring.autoconfigure.exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration + +# Configure this Discovery Server +eureka: + instance: + hostname: localhost + leaseRenewalIntervalInSeconds: 10 + metadataMap: + instanceId: ${spring.application.name}:${spring.application.instance_id:${server.port}} + client: # Not a client, don't register with yourself + registerWithEureka: false + fetchRegistry: false + +server: + port: 1111 # HTTP (Tomcat) port + +# Discovery Server Dashboard uses FreeMarker. Don't want Thymeleaf templates +spring: + thymeleaf: + enabled: false # Disable Thymeleaf + datasource: + type: org.springframework.jdbc.datasource.SimpleDriverDataSource \ No newline at end of file diff --git a/3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/registration/RegistrationApplicationTests.java b/3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/registration/RegistrationApplicationTests.java new file mode 100644 index 0000000..6db28a4 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/registration/RegistrationApplicationTests.java @@ -0,0 +1,13 @@ +package com.wavefront.registration; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class RegistrationApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/shopping/ShoppingApplicationTests.java b/3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/shopping/ShoppingApplicationTests.java new file mode 100644 index 0000000..07f9bdb --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/shopping/ShoppingApplicationTests.java @@ -0,0 +1,13 @@ +package com.wavefront.shopping; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ShoppingApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/shopping/mvnw b/3D-microservices-observability/springboot-jersey-app-2/shopping/mvnw new file mode 100755 index 0000000..a16b543 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/shopping/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/3D-microservices-observability/springboot-jersey-app-2/shopping/mvnw.cmd b/3D-microservices-observability/springboot-jersey-app-2/shopping/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/shopping/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/3D-microservices-observability/springboot-jersey-app-2/shopping/pom.xml b/3D-microservices-observability/springboot-jersey-app-2/shopping/pom.xml new file mode 100644 index 0000000..38f3585 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/shopping/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + com.wavefront + springboot-jersey-app-2 + 0.0.1-SNAPSHOT + + com.wavefront + shopping + 0.0.1-SNAPSHOT + shopping + Demo project for Spring Boot + + + 1.8 + + + + + com.wavefront + common + 0.0.1-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-jersey + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + diff --git a/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/java/com/wavefront/shopping/ShoppingApplication.java b/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/java/com/wavefront/shopping/ShoppingApplication.java new file mode 100644 index 0000000..28b0793 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/java/com/wavefront/shopping/ShoppingApplication.java @@ -0,0 +1,16 @@ +package com.wavefront.shopping; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class ShoppingApplication { + + public static void main(String[] args) { + System.setProperty("spring.config.name", "shopping-application"); + SpringApplication.run(ShoppingApplication.class, args); + } + +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/java/com/wavefront/shopping/ShoppingController.java b/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/java/com/wavefront/shopping/ShoppingController.java new file mode 100644 index 0000000..4f2acef --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/java/com/wavefront/shopping/ShoppingController.java @@ -0,0 +1,59 @@ +package com.wavefront.shopping; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.wfsample.common.dto.OrderDTO; +import com.wfsample.common.dto.ResponseDTO; +import com.wfsample.common.dto.ShirtStyleDTO; +import com.wfsample.service.StylingService; + +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; +import java.util.logging.Logger; + +@RestController +@RequestMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE) +@ComponentScan(basePackages="com.wfsample.bean") +public class ShoppingController { + + protected Logger logger = Logger.getLogger(ShoppingController.class.getName()); + + @Autowired + StylingService stylingService; + + @GetMapping(path="/hello") + public ResponseDTO hello() { + return ResponseDTO.ok().msg("hello from Shopping Service").build(); + } + + @GetMapping(path="/menu") + public List getMenu() { + List styles = stylingService.getAllStyles(); + return styles; + } + + @PostMapping(path="/order") + public ResponseDTO orderShirts(@RequestBody OrderDTO orderDTO) { + + if (ThreadLocalRandom.current().nextInt(0, 10) == 0) { + String msg = "Failed to order shirts!"; + logger.warning(msg); + return ResponseDTO.status("SERVICE UNAVAILABLE").msg(msg).build(); + } + ResponseDTO stylingResponse = stylingService.makeShirts(orderDTO.getStyleName(), orderDTO.getQuantity()); + if(stylingResponse.getStatus().equalsIgnoreCase("OK")) { + return stylingResponse; + } else { + String msg = "Failed to order shirts!"; + logger.warning(msg); + return ResponseDTO.status("FAILED").msg(msg).build(); + } + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/resources/application.properties b/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/resources/shopping-application.yml b/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/resources/shopping-application.yml new file mode 100644 index 0000000..dc3ff60 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/resources/shopping-application.yml @@ -0,0 +1,14 @@ +# Spring properties +spring: + application: + name: shopping-service + +# Discovery Server Access +eureka: + client: + serviceUrl: + defaultZone: http://localhost:1111/eureka/ + +# HTTP Server +server: + port: 4444 # HTTP (Tomcat) port \ No newline at end of file diff --git a/3D-microservices-observability/springboot-jersey-app-2/shopping/src/test/java/com/wavefront/shopping/ShoppingApplicationTests.java b/3D-microservices-observability/springboot-jersey-app-2/shopping/src/test/java/com/wavefront/shopping/ShoppingApplicationTests.java new file mode 100644 index 0000000..07f9bdb --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/shopping/src/test/java/com/wavefront/shopping/ShoppingApplicationTests.java @@ -0,0 +1,13 @@ +package com.wavefront.shopping; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ShoppingApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/styling/mvnw b/3D-microservices-observability/springboot-jersey-app-2/styling/mvnw new file mode 100755 index 0000000..a16b543 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/styling/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/3D-microservices-observability/springboot-jersey-app-2/styling/mvnw.cmd b/3D-microservices-observability/springboot-jersey-app-2/styling/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/styling/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/3D-microservices-observability/springboot-jersey-app-2/styling/pom.xml b/3D-microservices-observability/springboot-jersey-app-2/styling/pom.xml new file mode 100644 index 0000000..162c31b --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/styling/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + com.wavefront + springboot-jersey-app-2 + 0.0.1-SNAPSHOT + + com.wavefront + styling + 0.0.1-SNAPSHOT + styling + Demo project for Spring Boot + + + 1.8 + + + + + com.wavefront + common + 0.0.1-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-jersey + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + + + diff --git a/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/java/com/wavefront/styling/StylingApplication.java b/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/java/com/wavefront/styling/StylingApplication.java new file mode 100644 index 0000000..9ae9fc2 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/java/com/wavefront/styling/StylingApplication.java @@ -0,0 +1,16 @@ +package com.wavefront.styling; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@SpringBootApplication +@EnableDiscoveryClient +public class StylingApplication { + + public static void main(String[] args) { + System.setProperty("spring.config.name", "styling-application"); + SpringApplication.run(StylingApplication.class, args); + } + +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/java/com/wavefront/styling/StylingController.java b/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/java/com/wavefront/styling/StylingController.java new file mode 100644 index 0000000..2377785 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/java/com/wavefront/styling/StylingController.java @@ -0,0 +1,90 @@ +package com.wavefront.styling; + +import com.wfsample.common.dto.PackedShirtsDTO; +import com.wfsample.common.dto.ResponseDTO; +import com.wfsample.common.dto.OrderDTO; +import com.wfsample.common.dto.ShirtDTO; +import com.wfsample.common.dto.ShirtStyleDTO; +import com.wfsample.service.DeliveryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; +import java.util.logging.Logger; + +import javax.annotation.PostConstruct; + +import static java.util.stream.Collectors.toList; + +@RestController +@RequestMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE) +@ComponentScan(basePackages="com.wfsample.bean") +public class StylingController { + + @Autowired + DeliveryService deliveryService; + + protected Logger logger = Logger.getLogger(StylingController.class.getName()); + private List shirtStyleDTOS; + + @PostConstruct + public void init() { + shirtStyleDTOS = new ArrayList<>(); + ShirtStyleDTO dto = new ShirtStyleDTO(); + dto.setName("style1"); + dto.setImageUrl("style1Image"); + ShirtStyleDTO dto2 = new ShirtStyleDTO(); + dto2.setName("style2"); + dto2.setImageUrl("style2Image"); + shirtStyleDTOS.add(dto); + shirtStyleDTOS.add(dto2); + } + + @GetMapping(path="/styles") + public List getAllStyles() { + return this.shirtStyleDTOS; + } + + @GetMapping(path="/hello") + public ResponseDTO hello() { + return ResponseDTO.ok().msg("hello from Styling Service").build(); + } + + @PostMapping(path="/shirts") + public ResponseDTO makeShirts(@RequestBody OrderDTO orderDTO) { + + String styleName = orderDTO.getStyleName(); + int quantity = orderDTO.getQuantity(); + + if (ThreadLocalRandom.current().nextInt(0, 5) == 0) { + String msg = "Failed to make shirts!"; + logger.warning(msg); + return ResponseDTO.status("SERVICE UNAVAILABLE").msg(msg).build(); + } + String orderNum = UUID.randomUUID().toString(); + List packedShirts = new ArrayList(); + for (int i = 0; i < quantity; i++) { + packedShirts.add(new ShirtDTO(new ShirtStyleDTO(styleName, styleName + "Image"))); + } + PackedShirtsDTO packedShirtsDTO = new PackedShirtsDTO(packedShirts.stream(). + map(shirt -> new ShirtDTO( + new ShirtStyleDTO(shirt.getStyle().getName(), shirt.getStyle().getImageUrl()))).collect(toList())); + ResponseDTO deliveryResponse = deliveryService.dispatch(orderNum, packedShirtsDTO); + if(deliveryResponse.getStatus().equalsIgnoreCase("OK")) { + return deliveryResponse; + } else { + String msg = "Failed to make shirts!"; + logger.warning(msg); + return ResponseDTO.status("FAILED").msg(msg).build(); + } + } +} diff --git a/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/resources/application.properties b/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/resources/application.properties new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/resources/styling-application.yml b/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/resources/styling-application.yml new file mode 100644 index 0000000..fca9cc7 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/resources/styling-application.yml @@ -0,0 +1,14 @@ +# Spring properties +spring: + application: + name: styling-service + +# Discovery Server Access +eureka: + client: + serviceUrl: + defaultZone: http://localhost:1111/eureka/ + +# HTTP Server +server: + port: 3333 # HTTP (Tomcat) port \ No newline at end of file diff --git a/3D-microservices-observability/springboot-jersey-app-2/styling/src/test/java/com/wavefront/styling/StylingApplicationTests.java b/3D-microservices-observability/springboot-jersey-app-2/styling/src/test/java/com/wavefront/styling/StylingApplicationTests.java new file mode 100644 index 0000000..9c2416b --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/styling/src/test/java/com/wavefront/styling/StylingApplicationTests.java @@ -0,0 +1,13 @@ +package com.wavefront.styling; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class StylingApplicationTests { + + @Test + void contextLoads() { + } + +} From 6720bba9d60f76095d44b1d87db3adac9e36093d Mon Sep 17 00:00:00 2001 From: Howard Yoo Date: Mon, 4 May 2020 22:05:09 -0500 Subject: [PATCH 02/18] Create README.md added initial readme --- .../springboot-jersey-app-2/README.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 3D-microservices-observability/springboot-jersey-app-2/README.md diff --git a/3D-microservices-observability/springboot-jersey-app-2/README.md b/3D-microservices-observability/springboot-jersey-app-2/README.md new file mode 100644 index 0000000..2403acb --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/README.md @@ -0,0 +1,34 @@ +# Wavefront Hackathon - Springboot Jersey App 2 + +This is a sample java application using Springboot beachshirts (#[beachops](https://medium.com/@matthewzeier/thoughts-from-an-operations-wrangler-how-we-use-alerts-to-monitor-wavefront-71329c5e57a8)) +which makes shirts for the beach. + +## Running Application locally + +- `git clone` this repo and navigate to this dir: + +- ```bash + git clone https://github.com/wavefrontHQ/hackathon.git + cd hackathon/3D-microservices-observability/springboot-jersey-app-2 + ``` +- Run `mvn clean install` from the root directory of the project. + +- Now run all the services using below commands from root directory of the project. + + ```bash + mvn -pl registration spring-boot:run + mvn -pl delivery spring-boot:run + mvn -pl styling spring-boot:run + mvn -pl shopping spring-boot:run + ``` + +- Now view the shopping menus using HTTP GET request: `curl -X GET http://localhost:4444/menu` + +- Order shirts using HTTP POST request: + +- ```bash + curl -X POST -d '{"styleName":"style1", "quantity":10}' -H "Content-Type: application/json" http://localhost:4444/order + ``` + +- Use `./loadgen.sh {interval}` in the root directory to send a request of ordering shirts every `{interval}` seconds + From 31cdda7fb21c07fe24bc2de329a750dba3edf638 Mon Sep 17 00:00:00 2001 From: Howard Yoo Date: Mon, 4 May 2020 22:10:39 -0500 Subject: [PATCH 03/18] Update README.md Added information on Eureka server --- .../springboot-jersey-app-2/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/3D-microservices-observability/springboot-jersey-app-2/README.md b/3D-microservices-observability/springboot-jersey-app-2/README.md index 2403acb..5d59eb9 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/README.md +++ b/3D-microservices-observability/springboot-jersey-app-2/README.md @@ -1,7 +1,9 @@ # Wavefront Hackathon - Springboot Jersey App 2 This is a sample java application using Springboot beachshirts (#[beachops](https://medium.com/@matthewzeier/thoughts-from-an-operations-wrangler-how-we-use-alerts-to-monitor-wavefront-71329c5e57a8)) -which makes shirts for the beach. +which makes shirts for the beach. The application is based on spring boot web using rest templates and rest annotations. +- JDK 1.8 and up +- Spring Boot 2.3.0.RC1 ## Running Application locally @@ -32,3 +34,5 @@ which makes shirts for the beach. - Use `./loadgen.sh {interval}` in the root directory to send a request of ordering shirts every `{interval}` seconds +- This application uses spring Eureka for service discovery. `registration` is the Eureka server running on port 1111. + User your browser to go to `http://localhost:1111` to monitor the three services `delivery`, `styling`, and `shopping`. \ No newline at end of file From ae36b16c74573a8ea4607f92ab8fde6549630daa Mon Sep 17 00:00:00 2001 From: Howard Yoo Date: Mon, 4 May 2020 22:11:47 -0500 Subject: [PATCH 04/18] Update README.md --- .../springboot-jersey-app-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3D-microservices-observability/springboot-jersey-app-2/README.md b/3D-microservices-observability/springboot-jersey-app-2/README.md index 5d59eb9..8797e73 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/README.md +++ b/3D-microservices-observability/springboot-jersey-app-2/README.md @@ -35,4 +35,4 @@ which makes shirts for the beach. The application is based on spring boot web us - Use `./loadgen.sh {interval}` in the root directory to send a request of ordering shirts every `{interval}` seconds - This application uses spring Eureka for service discovery. `registration` is the Eureka server running on port 1111. - User your browser to go to `http://localhost:1111` to monitor the three services `delivery`, `styling`, and `shopping`. \ No newline at end of file + Use your browser to open `http://localhost:1111` to monitor the three services `delivery`, `styling`, and `shopping`. \ No newline at end of file From 80c9d68a62e0587e786dbcf5682aad830b907289 Mon Sep 17 00:00:00 2001 From: Howard Yoo Date: Mon, 4 May 2020 23:09:05 -0500 Subject: [PATCH 05/18] Update pom.xml --- .../springboot-jersey-app-2/pom.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/3D-microservices-observability/springboot-jersey-app-2/pom.xml b/3D-microservices-observability/springboot-jersey-app-2/pom.xml index 7cbac02..a1b0651 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/pom.xml +++ b/3D-microservices-observability/springboot-jersey-app-2/pom.xml @@ -29,6 +29,21 @@ + + + org.springframework.boot spring-boot-starter-jersey From 6bda6d5c2d7f20de4b326a532bad1b66803926d0 Mon Sep 17 00:00:00 2001 From: Howard Yoo Date: Mon, 4 May 2020 23:13:40 -0500 Subject: [PATCH 06/18] Update README.md --- .../springboot-jersey-app-2/README.md | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/3D-microservices-observability/springboot-jersey-app-2/README.md b/3D-microservices-observability/springboot-jersey-app-2/README.md index 8797e73..c746d5a 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/README.md +++ b/3D-microservices-observability/springboot-jersey-app-2/README.md @@ -35,4 +35,27 @@ which makes shirts for the beach. The application is based on spring boot web us - Use `./loadgen.sh {interval}` in the root directory to send a request of ordering shirts every `{interval}` seconds - This application uses spring Eureka for service discovery. `registration` is the Eureka server running on port 1111. - Use your browser to open `http://localhost:1111` to monitor the three services `delivery`, `styling`, and `shopping`. \ No newline at end of file + Use your browser to open `http://localhost:1111` to monitor the three services `delivery`, `styling`, and `shopping`. + +## Enabling Wavefront Spring Boot Starter ## +- Uncomment the following entries in `pom.xml` in order to use Wavefront freemium to track your application performance. +```xml + +... + +... + +``` +- Follow the instructions in the standard output regarding the access to Wavefront freemium. \ No newline at end of file From fb8e64c74c6438413bb68cc208cc9c6ecf1e84e6 Mon Sep 17 00:00:00 2001 From: Howard Yoo Date: Tue, 5 May 2020 07:35:34 -0500 Subject: [PATCH 07/18] Update pom.xml --- .../springboot-jersey-app-2/pom.xml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/3D-microservices-observability/springboot-jersey-app-2/pom.xml b/3D-microservices-observability/springboot-jersey-app-2/pom.xml index a1b0651..2a98c29 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/pom.xml +++ b/3D-microservices-observability/springboot-jersey-app-2/pom.xml @@ -30,13 +30,16 @@ - + + + org.springframework.boot spring-boot-starter-jersey From 79d44c1315e64c3024f7d0f6334827ec797616b1 Mon Sep 17 00:00:00 2001 From: Howard Yoo Date: Tue, 5 May 2020 08:21:56 -0500 Subject: [PATCH 08/18] updated to provide exception and exception handling exception is now produced, and also handled. --- .../java/com/wfsample/service/DeliveryService.java | 8 ++++++-- .../java/com/wfsample/service/StylingService.java | 13 ++++++++++--- .../com/wavefront/shopping/ShoppingController.java | 4 ++-- .../com/wavefront/styling/StylingController.java | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/DeliveryService.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/DeliveryService.java index eaacb9e..ff181e2 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/DeliveryService.java +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/DeliveryService.java @@ -27,7 +27,11 @@ public ResponseDTO getHello() { return response; } - public ResponseDTO dispatch(String orderNum, PackedShirtsDTO packedShirtsDTO) { - return restTemplate.postForObject(serviceUrl + "/dispatch/" + orderNum, packedShirtsDTO, ResponseDTO.class); + public ResponseDTO dispatch(String orderNum, PackedShirtsDTO packedShirtsDTO) throws Exception { + ResponseDTO response = restTemplate.postForObject(serviceUrl + "/dispatch/" + orderNum, packedShirtsDTO, ResponseDTO.class); + if(!response.getStatus().equalsIgnoreCase("OK")) { + throw new Exception(response.getStatus() + ":" + response.getMessage()); + } + return response; } } diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/StylingService.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/StylingService.java index d3c9847..6d3b278 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/StylingService.java +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/service/StylingService.java @@ -31,16 +31,23 @@ public ResponseDTO getHello() { return response; } - public List getAllStyles() { + public List getAllStyles() throws Exception { List response = restTemplate.getForObject(serviceUrl + "/styles", new ArrayList().getClass()); + if(response == null || response.size() == 0) { + throw new Exception("Failed to retrieve list of styles."); + } return response; } - public ResponseDTO makeShirts(String styleName, int quantity) { + public ResponseDTO makeShirts(String styleName, int quantity) throws Exception { String requestUrl = serviceUrl + "/shirts"; OrderDTO order = new OrderDTO(); order.setStyleName(styleName); order.setQuantity(quantity); - return restTemplate.postForObject(requestUrl, order, ResponseDTO.class); + ResponseDTO response = restTemplate.postForObject(requestUrl, order, ResponseDTO.class); + if(!response.getStatus().equalsIgnoreCase("OK")) { + throw new Exception(response.getStatus() + ":" + response.getMessage()); + } + return response; } } diff --git a/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/java/com/wavefront/shopping/ShoppingController.java b/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/java/com/wavefront/shopping/ShoppingController.java index 4f2acef..db33b9d 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/java/com/wavefront/shopping/ShoppingController.java +++ b/3D-microservices-observability/springboot-jersey-app-2/shopping/src/main/java/com/wavefront/shopping/ShoppingController.java @@ -34,13 +34,13 @@ public ResponseDTO hello() { } @GetMapping(path="/menu") - public List getMenu() { + public List getMenu() throws Exception { List styles = stylingService.getAllStyles(); return styles; } @PostMapping(path="/order") - public ResponseDTO orderShirts(@RequestBody OrderDTO orderDTO) { + public ResponseDTO orderShirts(@RequestBody OrderDTO orderDTO) throws Exception { if (ThreadLocalRandom.current().nextInt(0, 10) == 0) { String msg = "Failed to order shirts!"; diff --git a/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/java/com/wavefront/styling/StylingController.java b/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/java/com/wavefront/styling/StylingController.java index 2377785..c27acd9 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/java/com/wavefront/styling/StylingController.java +++ b/3D-microservices-observability/springboot-jersey-app-2/styling/src/main/java/com/wavefront/styling/StylingController.java @@ -60,7 +60,7 @@ public ResponseDTO hello() { } @PostMapping(path="/shirts") - public ResponseDTO makeShirts(@RequestBody OrderDTO orderDTO) { + public ResponseDTO makeShirts(@RequestBody OrderDTO orderDTO) throws Exception { String styleName = orderDTO.getStyleName(); int quantity = orderDTO.getQuantity(); From 4de84461d8a63fbd0ded74f91efff51f47ad6297 Mon Sep 17 00:00:00 2001 From: Howard Yoo Date: Mon, 11 May 2020 13:45:28 -0500 Subject: [PATCH 09/18] added application name to make the demo more meaningful added application name in each of application yml files --- .../src/main/resources/application.properties | 1 - .../main/resources/delivery-application.yml | 7 ++++++- .../springboot-jersey-app-2/pom.xml | 19 +++++++++---------- .../src/main/resources/application.properties | 1 - .../main/resources/registration-server.yml | 8 +++++++- .../src/main/resources/application.properties | 1 - .../main/resources/shopping-application.yml | 7 ++++++- .../src/main/resources/application.properties | 1 - .../main/resources/styling-application.yml | 7 ++++++- 9 files changed, 34 insertions(+), 18 deletions(-) diff --git a/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/application.properties b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/application.properties index 8b13789..e69de29 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/application.properties +++ b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/application.properties @@ -1 +0,0 @@ - diff --git a/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/delivery-application.yml b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/delivery-application.yml index 343e62d..5674aa7 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/delivery-application.yml +++ b/3D-microservices-observability/springboot-jersey-app-2/delivery/src/main/resources/delivery-application.yml @@ -11,4 +11,9 @@ eureka: # HTTP Server server: - port: 2222 # HTTP (Tomcat) port \ No newline at end of file + port: 2222 # HTTP (Tomcat) port + +# wavefront +wavefront: + application: + name: SpringShirts \ No newline at end of file diff --git a/3D-microservices-observability/springboot-jersey-app-2/pom.xml b/3D-microservices-observability/springboot-jersey-app-2/pom.xml index 2a98c29..169be59 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/pom.xml +++ b/3D-microservices-observability/springboot-jersey-app-2/pom.xml @@ -30,15 +30,6 @@ - - - - + + ` part to enable + `spring-cloud-starter-sleuth` in order to have SLEUTH produce distributed tracing for the application, or you can + use opentracing instead. ```xml ... - + + + + + ... ``` -- Follow the instructions in the standard output regarding the access to Wavefront freemium. \ No newline at end of file +- Follow the instructions in the standard output regarding the access to Wavefront freemium. Once you navigate to your Wavefront UI, + you should be able to see your metrics and traces shown. You may need to wait about a minute for the first flow of metrics to be shown + in the UI, and also make sure to run loadgen.sh with seconds interval e.g. `loadgen.sh 5` in order to produce some test loads. \ No newline at end of file From f03d6f01d0bae251e8026ecbb1ef0181b8fec629 Mon Sep 17 00:00:00 2001 From: Howard Yoo <32691630+howardyoo@users.noreply.github.com> Date: Tue, 12 May 2020 14:53:26 -0500 Subject: [PATCH 11/18] Update README.md --- .../springboot-jersey-app-2/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/3D-microservices-observability/springboot-jersey-app-2/README.md b/3D-microservices-observability/springboot-jersey-app-2/README.md index f657dec..7ae3b74 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/README.md +++ b/3D-microservices-observability/springboot-jersey-app-2/README.md @@ -10,7 +10,7 @@ which makes shirts for the beach. The application is based on spring boot web us - `git clone` this repo and navigate to this dir: - ```bash - git clone https://github.com/wavefrontHQ/hackathon.git + git clone https://github.com/howardyoo/distributed-tracing-sample-apps/hackathon.git cd hackathon/3D-microservices-observability/springboot-jersey-app-2 ``` - Run `mvn clean install` from the root directory of the project. @@ -75,4 +75,4 @@ which makes shirts for the beach. The application is based on spring boot web us ``` - Follow the instructions in the standard output regarding the access to Wavefront freemium. Once you navigate to your Wavefront UI, you should be able to see your metrics and traces shown. You may need to wait about a minute for the first flow of metrics to be shown - in the UI, and also make sure to run loadgen.sh with seconds interval e.g. `loadgen.sh 5` in order to produce some test loads. \ No newline at end of file + in the UI, and also make sure to run loadgen.sh with seconds interval e.g. `loadgen.sh 5` in order to produce some test loads. From ab601c923eb927c0be72690547a867f3deb7b37c Mon Sep 17 00:00:00 2001 From: Howard Yoo <32691630+howardyoo@users.noreply.github.com> Date: Tue, 12 May 2020 14:53:56 -0500 Subject: [PATCH 12/18] Update README.md --- .../springboot-jersey-app-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3D-microservices-observability/springboot-jersey-app-2/README.md b/3D-microservices-observability/springboot-jersey-app-2/README.md index 7ae3b74..308b250 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/README.md +++ b/3D-microservices-observability/springboot-jersey-app-2/README.md @@ -10,7 +10,7 @@ which makes shirts for the beach. The application is based on spring boot web us - `git clone` this repo and navigate to this dir: - ```bash - git clone https://github.com/howardyoo/distributed-tracing-sample-apps/hackathon.git + git clone https://github.com/howardyoo/distributed-tracing-sample-apps/ cd hackathon/3D-microservices-observability/springboot-jersey-app-2 ``` - Run `mvn clean install` from the root directory of the project. From a5367a9a223f0976fc475f167a0e58d600caed49 Mon Sep 17 00:00:00 2001 From: Howard Yoo <32691630+howardyoo@users.noreply.github.com> Date: Tue, 12 May 2020 15:01:41 -0500 Subject: [PATCH 13/18] Update README.md --- .../springboot-jersey-app-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3D-microservices-observability/springboot-jersey-app-2/README.md b/3D-microservices-observability/springboot-jersey-app-2/README.md index 308b250..71cf415 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/README.md +++ b/3D-microservices-observability/springboot-jersey-app-2/README.md @@ -11,7 +11,7 @@ which makes shirts for the beach. The application is based on spring boot web us - ```bash git clone https://github.com/howardyoo/distributed-tracing-sample-apps/ - cd hackathon/3D-microservices-observability/springboot-jersey-app-2 + cd ./distributed-tracing-sample-apps/3D-microservices-observability/springboot-jersey-app-2 ``` - Run `mvn clean install` from the root directory of the project. From f8ca7f6313ba5056e6978ea57a3a06dd2682f7b6 Mon Sep 17 00:00:00 2001 From: Howard Yoo <32691630+howardyoo@users.noreply.github.com> Date: Tue, 12 May 2020 15:03:03 -0500 Subject: [PATCH 14/18] Update README.md --- .../springboot-jersey-app-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3D-microservices-observability/springboot-jersey-app-2/README.md b/3D-microservices-observability/springboot-jersey-app-2/README.md index 71cf415..81761f5 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/README.md +++ b/3D-microservices-observability/springboot-jersey-app-2/README.md @@ -13,7 +13,7 @@ which makes shirts for the beach. The application is based on spring boot web us git clone https://github.com/howardyoo/distributed-tracing-sample-apps/ cd ./distributed-tracing-sample-apps/3D-microservices-observability/springboot-jersey-app-2 ``` -- Run `mvn clean install` from the root directory of the project. +- Run `mvn clean compile` from the root directory of the project. - Now run all the services using below commands from root directory of the project. From bdcb9eabc58c2c62320d8d691c918255d4098bb1 Mon Sep 17 00:00:00 2001 From: Howard Yoo <32691630+howardyoo@users.noreply.github.com> Date: Tue, 12 May 2020 15:03:57 -0500 Subject: [PATCH 15/18] Update README.md --- .../springboot-jersey-app-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3D-microservices-observability/springboot-jersey-app-2/README.md b/3D-microservices-observability/springboot-jersey-app-2/README.md index 81761f5..30fba51 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/README.md +++ b/3D-microservices-observability/springboot-jersey-app-2/README.md @@ -1,4 +1,4 @@ -# Wavefront Hackathon - Springboot Jersey App 2 +# Wavefront Distributed Tracing Sample Apps - Springboot Jersey App 2 This is a sample java application using Springboot beachshirts (#[beachops](https://medium.com/@matthewzeier/thoughts-from-an-operations-wrangler-how-we-use-alerts-to-monitor-wavefront-71329c5e57a8)) which makes shirts for the beach. The application is based on spring boot web using rest templates and rest annotations. From 4b55cf5f70f5d36c2a705ae09c096d7eb34adc29 Mon Sep 17 00:00:00 2001 From: Howard Yoo Date: Tue, 12 May 2020 15:38:54 -0500 Subject: [PATCH 16/18] updated build plugin settings updated build plugin settings --- .../springboot-jersey-app-2/common/pom.xml | 9 +-------- .../springboot-jersey-app-2/pom.xml | 14 ++++++++------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/pom.xml b/3D-microservices-observability/springboot-jersey-app-2/common/pom.xml index 3fbd9f0..eb68424 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/common/pom.xml +++ b/3D-microservices-observability/springboot-jersey-app-2/common/pom.xml @@ -36,14 +36,7 @@ - - - - org.springframework.boot - spring-boot-maven-plugin - - - + diff --git a/3D-microservices-observability/springboot-jersey-app-2/pom.xml b/3D-microservices-observability/springboot-jersey-app-2/pom.xml index 169be59..5f9f013 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/pom.xml +++ b/3D-microservices-observability/springboot-jersey-app-2/pom.xml @@ -103,12 +103,14 @@ - - - org.springframework.boot - spring-boot-maven-plugin - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + From 1d21e37c55d5189c45309363dec6f39491b98492 Mon Sep 17 00:00:00 2001 From: Howard Yoo Date: Tue, 12 May 2020 15:52:37 -0500 Subject: [PATCH 17/18] removed unnecessary test --- .../registration/RegistrationApplicationTests.java | 2 -- .../shopping/ShoppingApplicationTests.java | 13 ------------- 2 files changed, 15 deletions(-) delete mode 100644 3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/shopping/ShoppingApplicationTests.java diff --git a/3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/registration/RegistrationApplicationTests.java b/3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/registration/RegistrationApplicationTests.java index 6db28a4..6dbfc31 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/registration/RegistrationApplicationTests.java +++ b/3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/registration/RegistrationApplicationTests.java @@ -5,9 +5,7 @@ @SpringBootTest class RegistrationApplicationTests { - @Test void contextLoads() { } - } diff --git a/3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/shopping/ShoppingApplicationTests.java b/3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/shopping/ShoppingApplicationTests.java deleted file mode 100644 index 07f9bdb..0000000 --- a/3D-microservices-observability/springboot-jersey-app-2/registration/src/test/java/com/wavefront/shopping/ShoppingApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.wavefront.shopping; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class ShoppingApplicationTests { - - @Test - void contextLoads() { - } - -} From 9fc04bfc201ecf793c609d459a3ecc899fc66768 Mon Sep 17 00:00:00 2001 From: Howard Yoo Date: Tue, 12 May 2020 16:22:10 -0500 Subject: [PATCH 18/18] fixed issues with common common module lacking main - fixed. --- .../springboot-jersey-app-2/common/pom.xml | 9 ++++++++- .../common/src/main/java/com/wfsample/Main.java | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/Main.java diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/pom.xml b/3D-microservices-observability/springboot-jersey-app-2/common/pom.xml index eb68424..3fbd9f0 100644 --- a/3D-microservices-observability/springboot-jersey-app-2/common/pom.xml +++ b/3D-microservices-observability/springboot-jersey-app-2/common/pom.xml @@ -36,7 +36,14 @@ - + + + + org.springframework.boot + spring-boot-maven-plugin + + + diff --git a/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/Main.java b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/Main.java new file mode 100644 index 0000000..f2ac4b7 --- /dev/null +++ b/3D-microservices-observability/springboot-jersey-app-2/common/src/main/java/com/wfsample/Main.java @@ -0,0 +1,7 @@ +package com.wfsample; + +public class Main { + public static void main(String[] args) { + + } +}