Skip to content

Commit

Permalink
Merge pull request #260 from nikodemas/change_rucio_dm_mon_mongodb
Browse files Browse the repository at this point in the history
Change rucio dm mon mongodb import configs
  • Loading branch information
nikodemas authored Jan 11, 2024
2 parents 931b517 + 706206c commit 496b4ac
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions rucio-dataset-monitoring/spark/cron4rucio_hdfs2mongo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ set -e
##H - keytab : Kerberos auth file to connect Spark Analytix cluster (cmsmonit)
##H - hdfs : HDFS_PATH output path that include spark job results. Mongoimport will import them.
##H - mongohost : MongoDB host
##H - mongoport : MongoDB port
##H - mongouser : MongoDB user which has write access to required MongoDB database/collection
##H - mongopass : MongoDB user password
##H - mongowritedb : MongoDB database name that results will be written
##H - mongoauthdb : MongoDB database for authentication. Required for mongoimport `--authenticationDatabase` argument
##H - wdir : working directory
##H
##H Usage Example:
##H ./cron4rucio_hdfs2mongo.sh --keytab ./keytab --hdfs /tmp/cmsmonit --mongohost $MONGO_HOST --mongoport $MONGO_PORT \
##H --mongouser $MONGO_ROOT_USERNAME --mongopass $MONGO_ROOT_PASSWORD --mongowritedb rucio --mongoauthdb admin --wdir $WDIR
##H ./cron4rucio_hdfs2mongo.sh --keytab ./keytab --hdfs /tmp/cmsmonit --mongohost $MONGO_HOST \
##H --mongouser $MONGO_ROOT_USERNAME --mongopass $MONGO_ROOT_PASSWORD --mongowritedb rucio \
##H --mongoauthdb admin --wdir $WDIR
##H
##H How to test:
##H - You can test just by giving different '--mongowritedb'.
Expand Down Expand Up @@ -51,12 +51,12 @@ if [ "$1" == "" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ] || [ "$1" == "-hel
exit 0
fi
util_cron_send_start "$myname" "1d"
unset -v KEYTAB_SECRET HDFS_PATH ARG_MONGOHOST ARG_MONGOPORT ARG_MONGOUSER ARG_MONGOPASS ARG_MONGOWRITEDB ARG_MONGOAUTHDB WDIR help
unset -v KEYTAB_SECRET HDFS_PATH ARG_MONGOHOST ARG_MONGOUSER ARG_MONGOPASS ARG_MONGOWRITEDB ARG_MONGOAUTHDB WDIR help
# ------------------------------------------------------------------------------------------------------------- PREPARE
util4datasetmon_input_args_parser $@

util4logi "Parameters: KEYTAB_SECRET:${KEYTAB_SECRET} HDFS_PATH:${HDFS_PATH} ARG_MONGOHOST:${ARG_MONGOHOST} ARG_MONGOPORT:${ARG_MONGOPORT} ARG_MONGOUSER:${ARG_MONGOUSER} ARG_MONGOWRITEDB:${ARG_MONGOWRITEDB} ARG_MONGOAUTHDB:${ARG_MONGOAUTHDB} WDIR:${WDIR}"
util_check_vars HDFS_PATH ARG_MONGOHOST ARG_MONGOPORT ARG_MONGOUSER ARG_MONGOPASS ARG_MONGOWRITEDB ARG_MONGOAUTHDB WDIR
util4logi "Parameters: KEYTAB_SECRET:${KEYTAB_SECRET} HDFS_PATH:${HDFS_PATH} ARG_MONGOHOST:${ARG_MONGOHOST} ARG_MONGOUSER:${ARG_MONGOUSER} ARG_MONGOWRITEDB:${ARG_MONGOWRITEDB} ARG_MONGOAUTHDB:${ARG_MONGOAUTHDB} WDIR:${WDIR}"
util_check_vars HDFS_PATH ARG_MONGOHOST ARG_MONGOUSER ARG_MONGOPASS ARG_MONGOWRITEDB ARG_MONGOAUTHDB WDIR
util_setup_spark_k8s

# Check commands/CLIs exist
Expand All @@ -83,7 +83,7 @@ function run_mongo_import() {
hadoop fs -getmerge "$hdfs_out_dir"/part-*.json "$local_json_merge_file"

mongoimport --drop --type=json \
--host "$ARG_MONGOHOST" --port "$ARG_MONGOPORT" --username "$ARG_MONGOUSER" --password "$ARG_MONGOPASS" \
--host "$ARG_MONGOHOST" --username "$ARG_MONGOUSER" --password "$ARG_MONGOPASS" \
--authenticationDatabase "$ARG_MONGOAUTHDB" --db "$ARG_MONGOWRITEDB" \
--collection "$collection" --file "$local_json_merge_file"
util4logi "Mongoimport finished. ${hdfs_out_dir} imported to collection: ${collection}"
Expand All @@ -105,7 +105,7 @@ run_mongo_import "${HDFS_PATH}/${hdfs_datasets_in_tape_and_disk}" "$col_datasets
# Write current date to json file and import it to MongoDB "source_timestamp" collection for Go Web Page.
echo "{\"createdAt\": \"$(date +%Y-%m-%d)\"}" >source_timestamp.json
mongoimport --drop --type=json \
--host "$ARG_MONGOHOST" --port "$ARG_MONGOPORT" --username "$ARG_MONGOUSER" --password "$ARG_MONGOPASS" \
--host "$ARG_MONGOHOST" --username "$ARG_MONGOUSER" --password "$ARG_MONGOPASS" \
--authenticationDatabase "$ARG_MONGOAUTHDB" --db "$ARG_MONGOWRITEDB" \
--collection "source_timestamp" --file source_timestamp.json

Expand All @@ -115,7 +115,7 @@ util4logi "source_timestamp collection is updated with current date"
# Modify JS script
sed -i "s/_MONGOWRITEDB_/$ARG_MONGOWRITEDB/g" "$script_dir"/createindexes.js

mongosh --host "$ARG_MONGOHOST" --port "$ARG_MONGOPORT" --username "$ARG_MONGOUSER" --password "$ARG_MONGOPASS" \
mongosh --host "$ARG_MONGOHOST" --username "$ARG_MONGOUSER" --password "$ARG_MONGOPASS" \
--authenticationDatabase "$ARG_MONGOAUTHDB" <"$script_dir"/createindexes.js
util4logi "MongoDB indexes are created for datasets and detailed_datasets collections"

Expand Down

0 comments on commit 496b4ac

Please sign in to comment.