tanvipenumudy commented on code in PR #3864:
URL: https://github.com/apache/ozone/pull/3864#discussion_r1001399251


##########
hadoop-ozone/dist/src/shell/ozone/ozone-functions.sh:
##########
@@ -2661,6 +2662,110 @@ function ozone_generic_java_subcmd_handler
   fi
 }
 
+## @description Validates if all jars as indicated in the corresponding 
${OZONE_RUN_ARTIFACT_NAME} classpath file are present
+## @audience private
+## @stability evolving
+## @replaceable yes
+function validate_classpath
+{
+  if [ -n "$1" ]; then
+    case "$1" in
+      -h|--help)
+        echo "Usage I: ozone classpath <ARTIFACTNAME> --validate"
+        echo "Usage II: ozone --daemon start|status|stop 
csi|datanode|om|recon|s3g|scm --validate"
+        echo
+        echo "Options:"
+        echo
+        echo "  -h, --help"
+        echo "      This help text."
+        echo
+        echo "  --validate"
+        echo "      Validates if all jars as indicated in the corresponding 
OZONE_RUN_ARTIFACT_NAME classpath file are present."
+        echo
+        exit 0
+        ;;
+      --validate)
+        validate_classpath_util "$2"
+        ;;
+      *)
+        echo "Invalid option "$1". Use --help to see the valid options."
+        exit 1
+        ;;
+    esac
+  fi
+}
+
+## @description Utility function of validate_classpath
+## @audience private
+## @stability evolving
+## @replaceable yes
+function validate_classpath_util
+{
+  local FLAG_FAIL
+  FLAG_FAIL=1
+
+  if [ -n "$1" ]; then
+    if [ "${OZONE_SUBCMD_SUPPORTDAEMONIZATION}" == false ]; then
+      echo "unrecognized option"
+      exit 1
+    fi
+    case "$1" in
+      -h|--help)
+        echo "Usage: ozone --daemon start|status|stop 
csi|datanode|om|recon|s3g|scm --validate --continue"
+        echo
+        echo "Options:"
+        echo
+        echo "  -h, --help"
+        echo "      This help text."
+        echo
+        echo "  --continue"
+        echo "      The command execution shall continue even if the 
validation fails."
+        echo
+        exit 0
+        ;;
+      --continue)
+        echo "The command execution shall continue even if the validation 
fails."
+        FLAG_FAIL=0
+        ;;
+      *)
+        echo "Invalid option '$1'. Use --help to see the valid options."
+        exit 1
+        ;;
+    esac
+  fi
+
+  local CLASSPATH_FILE
+  
CLASSPATH_FILE="${OZONE_HOME}/share/ozone/classpath/${OZONE_RUN_ARTIFACT_NAME}.classpath"
+  echo "Validating classpath file: $(realpath "$CLASSPATH_FILE")"
+  if [[ ! -e "$CLASSPATH_FILE" ]]; then
+    echo "ERROR: Classpath file descriptor $CLASSPATH_FILE is missing"
+    exit 1
+  fi
+
+  source "$CLASSPATH_FILE"
+  OIFS=$IFS
+  IFS=':'
+
+  local flag
+  flag=1

Review Comment:
   Made the changes, thank you for the suggestion!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to