XrdClCopyProcess.hh

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
00003 // Author: Lukasz Janyst <ljanyst@cern.ch>
00004 //------------------------------------------------------------------------------
00005 // XRootD is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU Lesser General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // XRootD is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with XRootD.  If not, see <http://www.gnu.org/licenses/>.
00017 //------------------------------------------------------------------------------
00018 
00019 #ifndef __XRD_CL_COPY_PROCESS_HH__
00020 #define __XRD_CL_COPY_PROCESS_HH__
00021 
00022 #include "XrdCl/XrdClURL.hh"
00023 #include "XrdCl/XrdClXRootDResponses.hh"
00024 #include <stdint.h>
00025 
00026 namespace XrdCl
00027 {
00028   //----------------------------------------------------------------------------
00030   //----------------------------------------------------------------------------
00031   class CopyProgressHandler
00032   {
00033     public:
00034       virtual ~CopyProgressHandler() {}
00035 
00036       //------------------------------------------------------------------------
00043       //------------------------------------------------------------------------
00044       virtual void BeginJob( uint16_t   jobNum,
00045                              uint16_t   jobTotal,
00046                              const URL *source,
00047                              const URL *destination ) = 0;
00048 
00049       //------------------------------------------------------------------------
00053       //------------------------------------------------------------------------
00054       virtual void EndJob( const XRootDStatus &status ) = 0;
00055 
00056       //------------------------------------------------------------------------
00062       //------------------------------------------------------------------------
00063       virtual void JobProgress( uint64_t bytesProcessed,
00064                                 uint64_t bytesTotal ) = 0;
00065   };
00066 
00067   //----------------------------------------------------------------------------
00069   //----------------------------------------------------------------------------
00070   struct JobDescriptor
00071   {
00072     JobDescriptor(): sourceLimit(1), force(false), posc(false), coerce(false),
00073       thirdParty(false), checkSumPrint(false), chunkSize( 4194304 ),
00074       parallelChunks(8)
00075     {}
00076 
00077     URL              source;               
00078     URL              target;               
00079     uint16_t         sourceLimit;          
00080 
00081     bool             force;                
00082     bool             posc;                 
00083 
00084     bool             coerce;               
00085 
00086     bool             thirdParty;           
00087 
00088     bool             thirdPartyFallBack;   
00089 
00090 
00091     bool             checkSumPrint;        
00092 
00093     std::string      checkSumType;         
00094     std::string      checkSumPreset;       
00095     uint32_t         chunkSize;            
00096 
00097     uint8_t          parallelChunks;       
00098 
00099 
00100     std::string      sourceCheckSum;       
00101 
00102     std::string      targetCheckSum;       
00103 
00104     XRootDStatus     status;               
00105 
00106     std::vector<URL> sources;              
00107 
00108     URL              realTarget;           
00109   };
00110 
00111   //----------------------------------------------------------------------------
00113   //----------------------------------------------------------------------------
00114   class CopyJob
00115   {
00116     public:
00117       //------------------------------------------------------------------------
00119       //------------------------------------------------------------------------
00120       CopyJob( JobDescriptor *jobDesc ):
00121         pJob( jobDesc ) {}
00122 
00123       //------------------------------------------------------------------------
00125       //------------------------------------------------------------------------
00126       virtual ~CopyJob()
00127       {
00128       }
00129 
00130       //------------------------------------------------------------------------
00135       //------------------------------------------------------------------------
00136       virtual XRootDStatus Run( CopyProgressHandler *progress = 0 ) = 0;
00137 
00138       //------------------------------------------------------------------------
00140       //------------------------------------------------------------------------
00141       JobDescriptor *GetDescriptor() const
00142       {
00143         return pJob;
00144       }
00145 
00146     protected:
00147       JobDescriptor *pJob;
00148   };
00149 
00150   //----------------------------------------------------------------------------
00152   //----------------------------------------------------------------------------
00153   class CopyProcess
00154   {
00155     public:
00156       //------------------------------------------------------------------------
00158       //------------------------------------------------------------------------
00159       CopyProcess() {}
00160 
00161       //------------------------------------------------------------------------
00163       //------------------------------------------------------------------------
00164       virtual ~CopyProcess();
00165 
00166       //------------------------------------------------------------------------
00169       //------------------------------------------------------------------------
00170       void AddJob( JobDescriptor *job )
00171       {
00172         pJobDescs.push_back( job );
00173       }
00174 
00175       //------------------------------------------------------------------------
00176       // Prepare the copy jobs
00177       //------------------------------------------------------------------------
00178       XRootDStatus Prepare();
00179 
00180       //------------------------------------------------------------------------
00182       //------------------------------------------------------------------------
00183       XRootDStatus Run( CopyProgressHandler *handler );
00184 
00185     private:
00186       void CleanUpJobs();
00187       std::list<JobDescriptor*>  pJobDescs;
00188       std::list<CopyJob*>        pJobs;
00189   };
00190 }
00191 
00192 #endif // __XRD_CL_COPY_PROCESS_HH__

Generated on 27 Jul 2013 for xrootd by  doxygen 1.4.7