PG_XID="$1"
IFS='_' read -ra lines <<< "$PG_XID"
[[ "${lines[0]}" = 131077 ]] || exit 0; # this script only works for our own FORMAT ID
PG_TID=${lines[1]}
a=($(echo "$PG_TID"| base64 -d | xxd -ps |tr -d '\n' | while read -N16 i ; do echo 0x$i ; done))
b=($(echo "$PG_TID"| base64 -d | xxd -ps |tr -d '\n' | while read -N8 i ; do echo 0x$i ; done))
c=("${b[@]:4}") # put the last 3 32-bit hexadecimal numbers into array c
# the negative elements of c need special handling since printf below only works with positive
# hexadecimal numbers
for i in "${!c[@]}"; do
arg=${c[$i]}
# inspect the MSB to see if arg is negative - if so convert it from a 2’s complement number
[[ $(($arg>>31)) = 1 ]] && x=$(echo "obase=16; $(($arg - 0x100000000 ))" | bc) || x=$arg
if [[ ${x:0:1} = \- ]] ; then # see if the first character is a minus sign
neg[$i]="-";
c[$i]=0x${x:1} # strip the minus sign and make it hex for use with printf below
else
neg[$i]=""
c[$i]=$x
fi
done
EAP_TID=$(printf %x:%x:${neg[0]}%x:${neg[1]}%x:${neg[2]}%x ${a[0]} ${a[1]} ${c[0]} ${c[1]} ${c[2]})
PG_XID="$1"
IFS='_' read -ra lines <<< "$PG_XID"
[[ "${lines[0]}" = 131077 ]] || exit 0; # this script only works for our own FORMAT ID
PG_TID=${lines[1]}
a=($(echo "$PG_TID"| base64 -d | xxd -ps |tr -d '\n' | while read -N16 i ; do echo 0x$i ; done))
b=($(echo "$PG_TID"| base64 -d | xxd -ps |tr -d '\n' | while read -N8 i ; do echo 0x$i ; done))
c=("${b[@]:4}") # put the last 3 32-bit hexadecimal numbers into array c
# the negative elements of c need special handling since printf below only works with positive
# hexadecimal numbers
for i in "${!c[@]}"; do
arg=${c[$i]}
# inspect the MSB to see if arg is negative - if so convert it from a 2’s complement number
[[ $(($arg>>31)) = 1 ]] && x=$(echo "obase=16; $(($arg - 0x100000000 ))" | bc) || x=$arg
if [[ ${x:0:1} = \- ]] ; then # see if the first character is a minus sign
neg[$i]="-";
c[$i]=0x${x:1} # strip the minus sign and make it hex for use with printf below
else
neg[$i]=""
c[$i]=$x
fi
done
EAP_TID=$(printf %x:%x:${neg[0]}%x:${neg[1]}%x:${neg[2]}%x ${a[0]} ${a[1]} ${c[0]} ${c[1]} ${c[2]})
Copy to ClipboardCopied!Toggle word wrapToggle overflow
完成后,$EAP_TID 变量保存创建此 XID 的交易的全局事务 ID。启动事务的 pod 的节点标识符由以下 bash 命令的输出提供:
echo "$PG_TID"| base64 -d | tail -c +29
echo "$PG_TID"| base64 -d | tail -c +29
Copy to ClipboardCopied!Toggle word wrapToggle overflow