#
# Dependencies of this sub-command
#
replicate_file_depends()
{
	echo ""
}

#
# Sub-command: systest::gfarm2fs::replicate_file
#
subcmd_replicate_file()
{
	log_debug "subcmd_replicate_file"

	check_argc $# 2
	check_hostid any $HOSTID
	check_hostid gfsd $2
	DEST_HOST=`exec_remote_host_agent $2 root get-config-gfsd-param \
		"param=GFSD_HOSTNAME"`
	[ $? -ne 0 ] && \
		log_error "gfservice systest::gfarm2fs::replicate_file failed to get hostname"

	exec_remote_host_agent $HOSTID - systest::gfarm2fs::replicate_file \
		"file-path=$1" "dest-host=$DEST_HOST"
	[ $? -ne 0 ] && log_error "gfservice systest::gfarm2fs::replicate_file failed"

	log_debug "end subcmd_replicate_file"
}

#
# Dependencies of this sub-command agent
#
replicate_file_agent_depends()
{
	echo ""
}

#
# Sub-command: systest::gfarm2fs::replicate_file
# read file from the Gfarm file system and print to stdout
#
subcmd_replicate_file_agent()
{
	log_debug "subcmd_replicate_file_agent"

	set_params

	FILE_PATH=`get_param file-path`
	DEST_HOST=`get_param dest-host`

	log_debug "execute: echo $DEST_HOST | gfrep -H - $FILE_PATH"
	echo $DEST_HOST | GFARM_CONFIG_FILE=$GFARM_CONF gfrep -H - $FILE_PATH
	[ $? -ne 0 ] && log_error "gfrep command failed"

	log_debug "end subcmd_replicate_file_agent"
}
