More intelligent way for discover master_node

Change-Id: Iec195d10273167c5e49cebdeebe7636fcbe14b8d
Merge "More intelligent way for discover master_node"