trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hzel...@apache.org
Subject [3/5] incubator-trafodion git commit: rework to limit the port range betgween 12000 and 24000
Date Fri, 18 Dec 2015 01:36:46 GMT
rework to limit the port range betgween 12000 and 24000


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/e27daf10
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/e27daf10
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/e27daf10

Branch: refs/heads/master
Commit: e27daf10fb14a1778dcfb66e073bb39a4efb1c82
Parents: 2d2f001
Author: Qifan Chen <qfc@dev02.trafodion.org>
Authored: Fri Dec 18 00:42:13 2015 +0000
Committer: Qifan Chen <qfc@dev02.trafodion.org>
Committed: Fri Dec 18 00:42:13 2015 +0000

----------------------------------------------------------------------
 core/sqf/sql/scripts/install_local_hadoop | 30 ++++++++++++++++++--------
 1 file changed, 21 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/e27daf10/core/sqf/sql/scripts/install_local_hadoop
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/install_local_hadoop b/core/sqf/sql/scripts/install_local_hadoop
index ecf55c6..a829136 100755
--- a/core/sqf/sql/scripts/install_local_hadoop
+++ b/core/sqf/sql/scripts/install_local_hadoop
@@ -393,7 +393,6 @@ else
     # pick a random number between 12000 and 24000 that is divisible by 200
     MY_START_PORT=`expr $RANDOM '%' 60 '*' 200 + 12000`
   elif [ $MY_START_PORT == "available" ]; then
-     # pickup one from available ports
 
      portMsg=`python findPort.py`
 
@@ -403,24 +402,37 @@ else
         echo "No free port available, exit"
         exit 1
      fi
- 
+
      ports=`echo $portMsg | cut -d':' -f 2-2`
      port_arr=($ports)
-     num_ports=${#port_arr[@]}
- 
-     echo "Available ports detected: ${port_arr[*]}"
+
+     port_arr1=()
+
+     # filter out any ports that are not between 12000 and 24000 that "-p rand" uses
+     # this is to assure consistency between this option and the rand option.
+     for elem in "${port_arr[@]}"
+     do
+       if [ $elem -ge 12000 -a $elem -le 24000 ]; then
+         port_arr1[${#port_arr1[@]}]=$elem
+       fi
+     done
+
+     num_ports=${#port_arr1[@]}
+
+     echo "Available ports detected for use: ${port_arr1[*]}"
      echo "Total number of free ports: $num_ports"
- 
+
      if [ $num_ports -eq 0 ]; then
        echo "No free ports available, exit."
        exit 1
      fi
 
-     random_port_index=`python -c "import random; print random.randint(0,${#port_arr[@]}-1)"`
+     random_port_index=`python -c "import random; print random.randint(0,${#port_arr1[@]}-1)"`
      echo "Port index randomely chosen: $random_port_index"
- 
-     MY_START_PORT="${port_arr[$random_port_index]}"
+
+     MY_START_PORT="${port_arr1[$random_port_index]}"
      echo "Port chosen: $MY_START_PORT"
+
   fi
   echo "# Using non-standard port range from MY_START_PORT env var: $MY_START_PORT..."
 fi


Mime
View raw message