1
0
Fork 0

startStandAloneAgency default random order of agent start

This commit is contained in:
Kaveh Vahedipour 2016-11-03 16:25:28 +01:00
parent d35c6d6dce
commit cd141cbde1
1 changed files with 19 additions and 1 deletions

View File

@ -22,6 +22,19 @@ function help() {
}
function shuffle() {
local i tmp size max rand
size=${#array[*]}
max=$(( 32768 / size * size ))
for ((i=size-1; i>0; i--)); do
while (( (rand=$RANDOM) >= max )); do :; done
rand=$(( rand % (i+1) ))
tmp=${array[i]} array[i]=${array[rand]} array[rand]=$tmp
done
}
NRAGENTS=3
POOLSZ=""
TRANSPORT="tcp"
@ -118,7 +131,12 @@ fi
rm -rf agency
mkdir -p agency
PIDS=""
for aid in `seq 0 $(( $POOLSZ - 1 ))`; do
array=(`seq 0 $(( $POOLSZ - 1 ))`)
shuffle
for aid in "${array[@]}"; do
port=$(( $BASE + $aid ))
if [ "$GOSSIP_MODE" = 2 ]; then
nport=$(( $BASE + $(( $(( $aid + 1 )) % 3 ))))