@@ -12,16 +12,16 @@ set -e
12
12
# #H - keytab : Kerberos auth file to connect Spark Analytix cluster (cmsmonit)
13
13
# #H - hdfs : HDFS_PATH output path that include spark job results. Mongoimport will import them.
14
14
# #H - mongohost : MongoDB host
15
+ # #H - mongoport : MongoDB port
15
16
# #H - mongouser : MongoDB user which has write access to required MongoDB database/collection
16
17
# #H - mongopass : MongoDB user password
17
18
# #H - mongowritedb : MongoDB database name that results will be written
18
19
# #H - mongoauthdb : MongoDB database for authentication. Required for mongoimport `--authenticationDatabase` argument
19
20
# #H - wdir : working directory
20
21
# #H
21
22
# #H Usage Example:
22
- # #H ./cron4rucio_hdfs2mongo.sh --keytab ./keytab --hdfs /tmp/cmsmonit --mongohost $MONGO_HOST \
23
- # #H --mongouser $MONGO_ROOT_USERNAME --mongopass $MONGO_ROOT_PASSWORD --mongowritedb rucio \
24
- # #H --mongoauthdb admin --wdir $WDIR
23
+ # #H ./cron4rucio_hdfs2mongo.sh --keytab ./keytab --hdfs /tmp/cmsmonit --mongohost $MONGO_HOST --mongoport $MONGO_PORT \
24
+ # #H --mongouser $MONGO_ROOT_USERNAME --mongopass $MONGO_ROOT_PASSWORD --mongowritedb rucio --mongoauthdb admin --wdir $WDIR
25
25
# #H
26
26
# #H How to test:
27
27
# #H - You can test just by giving different '--mongowritedb'.
@@ -51,12 +51,12 @@ if [ "$1" == "" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ] || [ "$1" == "-hel
51
51
exit 0
52
52
fi
53
53
util_cron_send_start " $myname " " 1d"
54
- unset -v KEYTAB_SECRET HDFS_PATH ARG_MONGOHOST ARG_MONGOUSER ARG_MONGOPASS ARG_MONGOWRITEDB ARG_MONGOAUTHDB WDIR help
54
+ unset -v KEYTAB_SECRET HDFS_PATH ARG_MONGOHOST ARG_MONGOPORT ARG_MONGOUSER ARG_MONGOPASS ARG_MONGOWRITEDB ARG_MONGOAUTHDB WDIR help
55
55
# ------------------------------------------------------------------------------------------------------------- PREPARE
56
56
util4datasetmon_input_args_parser $@
57
57
58
- 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} "
59
- util_check_vars HDFS_PATH ARG_MONGOHOST ARG_MONGOUSER ARG_MONGOPASS ARG_MONGOWRITEDB ARG_MONGOAUTHDB WDIR
58
+ 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} "
59
+ util_check_vars HDFS_PATH ARG_MONGOHOST ARG_MONGOPORT ARG_MONGOUSER ARG_MONGOPASS ARG_MONGOWRITEDB ARG_MONGOAUTHDB WDIR
60
60
util_setup_spark_k8s
61
61
62
62
# Check commands/CLIs exist
@@ -83,7 +83,7 @@ function run_mongo_import() {
83
83
hadoop fs -getmerge " $hdfs_out_dir " /part-* .json " $local_json_merge_file "
84
84
85
85
mongoimport --drop --type=json \
86
- --host " $ARG_MONGOHOST " --username " $ARG_MONGOUSER " --password " $ARG_MONGOPASS " \
86
+ --host " $ARG_MONGOHOST " --port " $ARG_MONGOPORT " -- username " $ARG_MONGOUSER " --password " $ARG_MONGOPASS " \
87
87
--authenticationDatabase " $ARG_MONGOAUTHDB " --db " $ARG_MONGOWRITEDB " \
88
88
--collection " $collection " --file " $local_json_merge_file "
89
89
util4logi " Mongoimport finished. ${hdfs_out_dir} imported to collection: ${collection} "
@@ -105,7 +105,7 @@ run_mongo_import "${HDFS_PATH}/${hdfs_datasets_in_tape_and_disk}" "$col_datasets
105
105
# Write current date to json file and import it to MongoDB "source_timestamp" collection for Go Web Page.
106
106
echo " {\" createdAt\" : \" $( date +%Y-%m-%d) \" }" > source_timestamp.json
107
107
mongoimport --drop --type=json \
108
- --host " $ARG_MONGOHOST " --username " $ARG_MONGOUSER " --password " $ARG_MONGOPASS " \
108
+ --host " $ARG_MONGOHOST " --port " $ARG_MONGOPORT " -- username " $ARG_MONGOUSER " --password " $ARG_MONGOPASS " \
109
109
--authenticationDatabase " $ARG_MONGOAUTHDB " --db " $ARG_MONGOWRITEDB " \
110
110
--collection " source_timestamp" --file source_timestamp.json
111
111
@@ -115,7 +115,7 @@ util4logi "source_timestamp collection is updated with current date"
115
115
# Modify JS script
116
116
sed -i " s/_MONGOWRITEDB_/$ARG_MONGOWRITEDB /g" " $script_dir " /createindexes.js
117
117
118
- mongosh --host " $ARG_MONGOHOST " --username " $ARG_MONGOUSER " --password " $ARG_MONGOPASS " \
118
+ mongosh --host " $ARG_MONGOHOST " --port " $ARG_MONGOPORT " -- username " $ARG_MONGOUSER " --password " $ARG_MONGOPASS " \
119
119
--authenticationDatabase " $ARG_MONGOAUTHDB " < " $script_dir " /createindexes.js
120
120
util4logi " MongoDB indexes are created for datasets and detailed_datasets collections"
121
121
0 commit comments