diff --git a/src/XrdServer.cmake b/src/XrdServer.cmake index 76b5c2b04e6..ba54e724c93 100644 --- a/src/XrdServer.cmake +++ b/src/XrdServer.cmake @@ -81,7 +81,7 @@ add_library( XrdSfs/XrdSfsAio.hh XrdSfs/XrdSfsFAttr.hh XrdSfs/XrdSfsFlags.hh - XrdSfs/XrdSfsGPFInfo.hh + XrdSfs/XrdSfsGPFile.hh XrdSfs/XrdSfsInterface.hh #----------------------------------------------------------------------------- diff --git a/src/XrdSfs/XrdSfsGPFInfo.hh b/src/XrdSfs/XrdSfsGPFInfo.hh deleted file mode 100644 index a4c3b1d6899..00000000000 --- a/src/XrdSfs/XrdSfsGPFInfo.hh +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef __XRDSFSGPFINFO_H__ -#define __XRDSFSGPFINFO_H__ -/******************************************************************************/ -/* */ -/* X r d S f s G P F I n f o . h h */ -/* */ -/* (c) 2019 by the Board of Trustees of the Leland Stanford, Jr., University */ -/* All Rights Reserved */ -/* Produced by Andrew Hanushevsky for Stanford University under contract */ -/* DE-AC02-76-SFO0515 with the Department of Energy */ -/* */ -/* This file is part of the XRootD software suite. */ -/* */ -/* XRootD is free software: you can redistribute it and/or modify it under */ -/* the terms of the GNU Lesser General Public License as published by the */ -/* Free Software Foundation, either version 3 of the License, or (at your */ -/* option) any later version. */ -/* */ -/* XRootD is distributed in the hope that it will be useful, but WITHOUT */ -/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ -/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ -/* License for more details. */ -/* */ -/* You should have received a copy of the GNU Lesser General Public License */ -/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ -/* COPYING (GPL license). If not, see . */ -/* */ -/* The copyright holder's institutional names and contributor's names may not */ -/* be used to endorse or promote products derived from this software without */ -/* specific prior written permission of the institution or contributor. */ -/******************************************************************************/ - -#include -#include - -//! Class XrdSfsGPFInfo is used to control the execution of the GetFile() -//! and putFile() methods in XrdSfsInterface. An nstance of this class is -//! passed to the correspondng method specifying what has to be done and how -//! results are to be communicated back. - -/******************************************************************************/ -/* C l a s s X r d S f s G P F I n f o */ -/******************************************************************************/ - -//------------------------------------------------------------------------------ -//! The XrdXrdSfsGPFInfo class contains the get/putFile() parameters and -//! contains callback methods that indicate when the operation completes as -//! well as for progress status updates. -//------------------------------------------------------------------------------ - -class XrdSfsGPFInfo -{ -public: - -std::string cksType; //!< Checksum type or empty if none wanted -std::string cksValue; //!< Checksum value as ASCII hexdecimal string -std::string src; //!< Source getFile: URL putFile: path -std::string srcCgi; //!< Source cgi or empty if none -std::string dst; //!< Destination getFile: path putFile: URL -std::string dstCgi; //!< Destination cgi or empty if none. -const char *tident; //!< Trace identifier -void *rsvd1; //!< Reserved for future use -uint16_t options; //!< Processing options -uint16_t rsvd2; //!< Reserved for future use. -uint8_t pingsec; //!< Seconds between calls to Update() (0 -> no calls) -uint8_t sources; //!< Number of parallel sources (0 -> default) -uint8_t streams; //!< Number of parallel streams (0 -> default) -uint8_t rsvd3; //!< Reserved for future use. - -//------------------------------------------------------------------------------ -//! Possible options. -//------------------------------------------------------------------------------ - -static const uint16_t Keep = 0x0001; //!< Do not remove file upon failure. -static const uint16_t Replace = 0x0002; //. */ +/* */ +/* The copyright holder's institutional names and contributor's names may not */ +/* be used to endorse or promote products derived from this software without */ +/* specific prior written permission of the institution or contributor. */ +/******************************************************************************/ + +class XrdSfsGPInfo; + +class XrdSfsGPFile +{ +public: + +uint16_t opts; //!< Options as defined below +static const uint16_t delegate = 0x0008; //!< Use delegation +static const uint16_t keepErr = 0x0004; //!< Keep file after request failure +static const uint16_t mkPath = 0x0002; //!< Create destination path. +static const uint16_t replace = 0x0001; //!< Replace existing file +static const uint16_t useTLS = 0x0080; //!< Use TLS for the data path +static const uint16_t verCKS = 0x0040; //!< Verify checksum after transfer + +uint16_t rsvd1; +uint8_t pingsec; //!< Seconds between calls to Update() (0 -> no calls) +uint8_t sources; //!< Number of parallel sources (0 -> default) +uint8_t streams; //!< Number of parallel streams (0 -> default) +uint8_t rsvd2; + +union { +XrdSfsGPInfo *gpfInfo; //!< Can be used by the implementation +uint32_t gpfID; //!< Can be used by the implementation + }; + +const char *src; //!< get: full URL, put: local path +const char *dst; //!< get: local path, put: full URL +const char *lclCGI; //!< The CGI, if any, for the local path. +const char *csType; //!< Checksum type +const char *csVal; //!< Checksum value as a hex string +const char *tident; //!< Trace identifier + +void *rsvd3; //!< Reserved field + +//----------------------------------------------------------------------------- +//! Indicate the request has finished. +//! +//! @param rc - the final return code. A value of zero indicates success. +//! A non-zero value should be the errno value corresponding +//! to the reason for the failure. +//! @param emsg - An optional message further explaining the reason for the +//! failure (highly recommended). +//! +//! @return No value is returned but this object is deleted and no references +//! to the object should exist after return is made. +//----------------------------------------------------------------------------- + +virtual void Finished(int rc, const char *emsg=0) = 0; + +//----------------------------------------------------------------------------- +//! Provide request status. Only recursive locks should be held, if any. +//! +//! @param state - One of the enums listed indicating the request state. +//! @param cpct - Percentage (0 to 100) of completion. +//! @param bytes - Number of bytes processed in the indicated state. +//----------------------------------------------------------------------------- + +enum GPFState {gpfPend = 0, //!< Request is pending + gpfXfr, //!< Request is transfering data + gpfCSV //!< Request is doing checksum validation + }; + +virtual void Status(GPFState state, uint32_t cpct, uint64_t bytes) = 0; + +//----------------------------------------------------------------------------- +//! Constructor and Destructor +//----------------------------------------------------------------------------- + + XrdSfsGPFile(const char *tid="") + : opts(0), rsvd1(0), + pingsec(0), sources(0), streams(0), rsvd2(0), + gpfInfo(0), src(0), dst(0), lclCGI(0), + csType(0), csVal(0), tident(tid), rsvd3(0) {} +virtual ~XrdSfsGPFile() {} +}; +#endif diff --git a/src/XrdSfs/XrdSfsInterface.hh b/src/XrdSfs/XrdSfsInterface.hh index 2e7986d3b1e..c57c0cdec88 100644 --- a/src/XrdSfs/XrdSfsInterface.hh +++ b/src/XrdSfs/XrdSfsInterface.hh @@ -39,7 +39,7 @@ #include "XrdOuc/XrdOucIOVec.hh" #include "XrdOuc/XrdOucSFVec.hh" -#include "XrdSfs/XrdSfsGPFInfo.hh" +#include "XrdSfs/XrdSfsGPFile.hh" /******************************************************************************/ /* O p e n M o d e s */ @@ -987,27 +987,31 @@ virtual int fsctl(const int cmd, const XrdSecEntity *client = 0) = 0; //----------------------------------------------------------------------------- -//! Copy a file from a remote location to the local file system. +//! Perform a third party file transfer or cancel one. //! -//! @param fInfo - getFile() parameters. -//! @param eInfo - The object where call-time error info or results are to -//! be returned. See return notes. -//! @param client - Client's identify (see common description). Note that -//! client may become invalid after SFS_STARTED is returned. +//! @param gpAct - What to do as one of the enums listed below. +//! @param gpReq - reference tothe object describing the request. This object +//! is also used communicate the request status. +//! @param eInfo - The object where error info or results are to be returned. +//! @param client - Client's identify (see common description). //! -//! @return One of SFS_DATA, SFS_ERROR, SFS_OK, SFS_REDIRECT, or SFS_STARTED.. -//! The fInfo object is deleted upon return unless SFS_STARTED is -//! returned. In this case, the fInfo object is deleted only when -//! fInfo.Completed() is called. The eInfo is deleted upon return. +//! @return SFS_OK Request accepted (same as SFS_STARTED). Otherwise, one of +//! SFS_ERROR, SFS_REDIRECT, or SFS_STALL. //----------------------------------------------------------------------------- -virtual int getFile( XrdSfsGPFInfo &fInfo, - XrdOucErrInfo &eInfo, - const XrdSecEntity *client = 0) - {(void)fInfo; (void)client; - eInfo.setErrInfo(ENOTSUP, "Not supported."); - return SFS_ERROR; - } +enum gpfFunc {gpfCancel=0, //!< Cancel this request + gpfGet, //!< Perform a file retrieval + gpfPut //!< Perform a file push + }; + +virtual int gpFile( gpfFunc &gpAct, + XrdSfsGPFile &gpReq, + XrdOucErrInfo &eInfo, + const XrdSecEntity *client = 0) + {(void)gpAct, (void)gpReq; (void)client; + eInfo.setErrInfo(ENOTSUP, "Not supported."); + return SFS_ERROR; + } //----------------------------------------------------------------------------- //! Return statistical information. @@ -1074,30 +1078,7 @@ virtual int mkdir(const char *path, const char *opaque = 0) = 0; //----------------------------------------------------------------------------- -//! Copy a file to a remote location to the local file system. -//! -//! @param fInfo - putFile() parameters. -//! @param eInfo - The object where call-time error info or results are to -//! be returned. See return notes. -//! @param client - Client's identify (see common description). Note that -//! client may become invalid after SFS_STARTED is returned. -//! -//! @return One of SFS_DATA, SFS_ERROR, SFS_OK, SFS_REDIRECT, or SFS_STARTED.. -//! The fInfo object is deleted upon return unless SFS_STARTED is -//! returned. In this case, the fInfo object is deleted only when -//! fInfo.Completed() is called. The eInfo is deleted upon return. -//----------------------------------------------------------------------------- - -virtual int putFile( XrdSfsGPFInfo &fInfo, - XrdOucErrInfo &eInfo, - const XrdSecEntity *client = 0) - {(void)fInfo; (void)client; - eInfo.setErrInfo(ENOTSUP, "Not supported."); - return SFS_ERROR; - } - -//----------------------------------------------------------------------------- -//! Preapre a file for future processing. +//! Prepare a file for future processing. //! //! @param pargs - The preapre arguments. //! @param eInfo - The object where error info is to be returned.