Last active
December 15, 2015 19:29
-
-
Save pescobar/5311968 to your computer and use it in GitHub Desktop.
sge jsv for java jobs memory reservation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
jsv_on_start() { | |
return | |
} | |
jsv_on_verify() { | |
# for debugging | |
#params=$(jsv_show_params) | |
#jsv_log_info "$params" | |
pe_max=$(jsv_get_param pe_max) | |
#jsv_log_info "$pe_max" | |
# get h_vmem value. Something like 3.5G | |
hvmem=$(jsv_sub_get_param l_hard h_vmem) | |
# strip the G | |
hvmem=$(echo "${hvmem%?}") | |
# convert h_vmem to megabytes | |
hvmem=$(echo "$hvmem * 1024" | bc) | |
#jsv_log_info $hvmem | |
#if pe_max is set (number of slots), | |
# multiply h_vmem * slots | |
if [[ $pe_max ]] | |
then | |
hvmem=$(echo "$hvmem * $pe_max" | bc) | |
fi | |
# substract some memory from h_vmem for sge processes etc... | |
hvmem=$(echo "$hvmem - 1024" | bc) | |
# remove decimals | |
hvmem=$(echo ${hvmem%.*}) | |
#jsv_log_info $hvmem | |
# add the env var JAVAMX to the job context | |
# that will be used in the java wrapper | |
jsv_add_env JAVAMX -Xmx"$hvmem"m | |
# if needed I can also set java minimum memory (-Xms) | |
# or any other java option or env var which later can | |
# be used in the java wrapper. This is not mandatory | |
# jsv_add_env JAVAMS -Xms128m | |
jsv_accept "Job OK" | |
return | |
} | |
. ${SGE_ROOT}/util/resources/jsv/jsv_include.sh | |
jsv_main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment