#
# Check given host is slave server of gfmd
#
check_gfmd_slave()
{
	TARGET_HOSTNAME=`$GFSERVICE get-config-gfarm-param $1 \
		BACKEND_HOSTNAME`
	[ "X$TARGET_HOSTNAME" = X ] && return 1

	if [ X$4 != X ]; then
		RETRY_INTERVAL=$4
	else
		RETRY_INTERVAL=1
	fi

	I=0
	while [ $I -lt $3 ]; do
		MODE=`$GFSERVICE gfcmd $2 gfmdhost -l | \
			awk "/${TARGET_HOSTNAME}/{ print \\\$2 }"`
		if [ X$MODE = Xslave ]; then
			return 0
		fi
		sleep $RETRY_INTERVAL
		I=`expr $I + 1`
	done

	return 1
}
