xrootd
XrdClCopyProcess.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // XRootD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // XRootD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17 //------------------------------------------------------------------------------
18 
19 #ifndef __XRD_CL_COPY_PROCESS_HH__
20 #define __XRD_CL_COPY_PROCESS_HH__
21 
22 #include "XrdCl/XrdClURL.hh"
24 #include <stdint.h>
25 
26 namespace XrdCl
27 {
28  //----------------------------------------------------------------------------
30  //----------------------------------------------------------------------------
32  {
33  public:
34  virtual ~CopyProgressHandler() {}
35 
36  //------------------------------------------------------------------------
43  //------------------------------------------------------------------------
44  virtual void BeginJob( uint16_t jobNum,
45  uint16_t jobTotal,
46  const URL *source,
47  const URL *destination ) = 0;
48 
49  //------------------------------------------------------------------------
53  //------------------------------------------------------------------------
54  virtual void EndJob( const XRootDStatus &status ) = 0;
55 
56  //------------------------------------------------------------------------
62  //------------------------------------------------------------------------
63  virtual void JobProgress( uint64_t bytesProcessed,
64  uint64_t bytesTotal ) = 0;
65  };
66 
67  //----------------------------------------------------------------------------
69  //----------------------------------------------------------------------------
71  {
72  JobDescriptor(): sourceLimit(1), force(false), posc(false), coerce(false),
73  thirdParty(false), checkSumPrint(false), chunkSize( 4194304 ),
75  {}
76 
79  uint16_t sourceLimit;
80 
81  bool force;
82  bool posc;
83 
84  bool coerce;
85 
86  bool thirdParty;
87 
89 
90 
92 
93  std::string checkSumType;
94  std::string checkSumPreset;
95  uint32_t chunkSize;
96 
97  uint8_t parallelChunks;
98 
99 
100  std::string sourceCheckSum;
101 
102  std::string targetCheckSum;
103 
105 
106  std::vector<URL> sources;
107 
109  };
110 
111  //----------------------------------------------------------------------------
113  //----------------------------------------------------------------------------
114  class CopyJob
115  {
116  public:
117  //------------------------------------------------------------------------
119  //------------------------------------------------------------------------
120  CopyJob( JobDescriptor *jobDesc ):
121  pJob( jobDesc ) {}
122 
123  //------------------------------------------------------------------------
125  //------------------------------------------------------------------------
126  virtual ~CopyJob()
127  {
128  }
129 
130  //------------------------------------------------------------------------
135  //------------------------------------------------------------------------
136  virtual XRootDStatus Run( CopyProgressHandler *progress = 0 ) = 0;
137 
138  //------------------------------------------------------------------------
140  //------------------------------------------------------------------------
142  {
143  return pJob;
144  }
145 
146  protected:
148  };
149 
150  //----------------------------------------------------------------------------
152  //----------------------------------------------------------------------------
154  {
155  public:
156  //------------------------------------------------------------------------
158  //------------------------------------------------------------------------
160 
161  //------------------------------------------------------------------------
163  //------------------------------------------------------------------------
164  virtual ~CopyProcess();
165 
166  //------------------------------------------------------------------------
169  //------------------------------------------------------------------------
170  void AddJob( JobDescriptor *job )
171  {
172  pJobDescs.push_back( job );
173  }
174 
175  //------------------------------------------------------------------------
176  // Prepare the copy jobs
177  //------------------------------------------------------------------------
179 
180  //------------------------------------------------------------------------
182  //------------------------------------------------------------------------
184 
185  private:
186  void CleanUpJobs();
187  std::list<JobDescriptor*> pJobDescs;
188  std::list<CopyJob*> pJobs;
189  };
190 }
191 
192 #endif // __XRD_CL_COPY_PROCESS_HH__