You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/10/21 06:04:01 UTC

[GitHub] [ozone] tanvipenumudy commented on a diff in pull request #3864: HDDS-7363. Changes to Ozone CLI to validate if the jars in classpath files are present on an install

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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org