00001 //------------------------------------------------------------------------------ 00002 // Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN) 00003 // Author: Lukasz Janyst <ljanyst@cern.ch> 00004 //------------------------------------------------------------------------------ 00005 // This file is part of the XRootD software suite. 00006 // 00007 // XRootD is free software: you can redistribute it and/or modify 00008 // it under the terms of the GNU Lesser General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // XRootD is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public License 00018 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00019 // 00020 // In applying this licence, CERN does not waive the privileges and immunities 00021 // granted to it by virtue of its status as an Intergovernmental Organization 00022 // or submit itself to any jurisdiction. 00023 //------------------------------------------------------------------------------ 00024 00025 #ifndef __XRD_CL_COPY_PROCESS_HH__ 00026 #define __XRD_CL_COPY_PROCESS_HH__ 00027 00028 #include "XrdCl/XrdClURL.hh" 00029 #include "XrdCl/XrdClXRootDResponses.hh" 00030 #include "XrdCl/XrdClPropertyList.hh" 00031 #include <stdint.h> 00032 #include <vector> 00033 00034 namespace XrdCl 00035 { 00036 class CopyJob; 00037 00038 //---------------------------------------------------------------------------- 00040 //---------------------------------------------------------------------------- 00041 class CopyProgressHandler 00042 { 00043 public: 00044 virtual ~CopyProgressHandler() {} 00045 00046 //------------------------------------------------------------------------ 00053 //------------------------------------------------------------------------ 00054 virtual void BeginJob( uint16_t jobNum, 00055 uint16_t jobTotal, 00056 const URL *source, 00057 const URL *destination ) 00058 { 00059 (void)jobNum; (void)jobTotal; (void)source; (void)destination; 00060 }; 00061 00062 //------------------------------------------------------------------------ 00067 //------------------------------------------------------------------------ 00068 virtual void EndJob( uint16_t jobNum, 00069 const PropertyList *result ) 00070 { 00071 (void)jobNum; (void)result; 00072 }; 00073 00074 //------------------------------------------------------------------------ 00081 //------------------------------------------------------------------------ 00082 virtual void JobProgress( uint16_t jobNum, 00083 uint64_t bytesProcessed, 00084 uint64_t bytesTotal ) 00085 { 00086 (void)jobNum; (void)bytesProcessed; (void)bytesTotal; 00087 }; 00088 00089 //------------------------------------------------------------------------ 00091 //------------------------------------------------------------------------ 00092 virtual bool ShouldCancel( uint16_t jobNum ) 00093 { 00094 (void)jobNum; 00095 return false; 00096 } 00097 }; 00098 00099 //---------------------------------------------------------------------------- 00100 // Forward declaration of implementation holding CopyProcess' data members 00101 //---------------------------------------------------------------------------- 00102 struct CopyProcessImpl; 00103 00104 //---------------------------------------------------------------------------- 00106 //---------------------------------------------------------------------------- 00107 class CopyProcess 00108 { 00109 public: 00110 //------------------------------------------------------------------------ 00112 //------------------------------------------------------------------------ 00113 CopyProcess(); 00114 00115 //------------------------------------------------------------------------ 00117 //------------------------------------------------------------------------ 00118 virtual ~CopyProcess(); 00119 00120 //------------------------------------------------------------------------ 00166 //------------------------------------------------------------------------ 00167 XRootDStatus AddJob( const PropertyList &properties, 00168 PropertyList *results ); 00169 00170 //------------------------------------------------------------------------ 00171 // Prepare the copy jobs 00172 //------------------------------------------------------------------------ 00173 XRootDStatus Prepare(); 00174 00175 //------------------------------------------------------------------------ 00177 //------------------------------------------------------------------------ 00178 XRootDStatus Run( CopyProgressHandler *handler ); 00179 00180 private: 00181 void CleanUpJobs(); 00182 00183 //------------------------------------------------------------------------ 00185 //------------------------------------------------------------------------ 00186 inline static void MarkTPC( PropertyList &properties ) 00187 { 00188 std::string keys[] = { "source", "target" }; 00189 size_t size = sizeof( keys ) / sizeof( std::string ); 00190 for( size_t i = 0; i < size; ++i ) 00191 { 00192 URL url; 00193 properties.Get( keys[i], url ); 00194 URL::ParamsMap params = url.GetParams(); 00195 params["xrdcl.intent"] = "tpc"; 00196 url.SetParams( params ); 00197 properties.Set( keys[i], url.GetURL() ); 00198 } 00199 } 00200 00201 //------------------------------------------------------------------------ 00203 //------------------------------------------------------------------------ 00204 CopyProcessImpl *pImpl; 00205 }; 00206 } 00207 00208 #endif // __XRD_CL_COPY_PROCESS_HH__