xrootd
XrdClCopyProcess.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // This file is part of the XRootD software suite.
6 //
7 // XRootD is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // XRootD is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19 //
20 // In applying this licence, CERN does not waive the privileges and immunities
21 // granted to it by virtue of its status as an Intergovernmental Organization
22 // or submit itself to any jurisdiction.
23 //------------------------------------------------------------------------------
24 
25 #ifndef __XRD_CL_COPY_PROCESS_HH__
26 #define __XRD_CL_COPY_PROCESS_HH__
27 
28 #include "XrdCl/XrdClURL.hh"
31 #include <stdint.h>
32 #include <vector>
33 
34 namespace XrdCl
35 {
36  class CopyJob;
37 
38  //----------------------------------------------------------------------------
40  //----------------------------------------------------------------------------
42  {
43  public:
44  virtual ~CopyProgressHandler() {}
45 
46  //------------------------------------------------------------------------
53  //------------------------------------------------------------------------
54  virtual void BeginJob( uint16_t jobNum,
55  uint16_t jobTotal,
56  const URL *source,
57  const URL *destination )
58  {
59  (void)jobNum; (void)jobTotal; (void)source; (void)destination;
60  };
61 
62  //------------------------------------------------------------------------
67  //------------------------------------------------------------------------
68  virtual void EndJob( uint16_t jobNum,
69  const PropertyList *result )
70  {
71  (void)jobNum; (void)result;
72  };
73 
74  //------------------------------------------------------------------------
81  //------------------------------------------------------------------------
82  virtual void JobProgress( uint16_t jobNum,
83  uint64_t bytesProcessed,
84  uint64_t bytesTotal )
85  {
86  (void)jobNum; (void)bytesProcessed; (void)bytesTotal;
87  };
88 
89  //------------------------------------------------------------------------
91  //------------------------------------------------------------------------
92  virtual bool ShouldCancel( uint16_t jobNum )
93  {
94  (void)jobNum;
95  return false;
96  }
97  };
98 
99  //----------------------------------------------------------------------------
100  // Forward declaration of implementation holding CopyProcess' data members
101  //----------------------------------------------------------------------------
102  struct CopyProcessImpl;
103 
104  //----------------------------------------------------------------------------
106  //----------------------------------------------------------------------------
108  {
109  public:
110  //------------------------------------------------------------------------
112  //------------------------------------------------------------------------
113  CopyProcess();
114 
115  //------------------------------------------------------------------------
117  //------------------------------------------------------------------------
118  virtual ~CopyProcess();
119 
120  //------------------------------------------------------------------------
166  //------------------------------------------------------------------------
167  XRootDStatus AddJob( const PropertyList &properties,
168  PropertyList *results );
169 
170  //------------------------------------------------------------------------
171  // Prepare the copy jobs
172  //------------------------------------------------------------------------
174 
175  //------------------------------------------------------------------------
177  //------------------------------------------------------------------------
179 
180  private:
181  void CleanUpJobs();
182 
183  //------------------------------------------------------------------------
185  //------------------------------------------------------------------------
186  inline static void MarkTPC( PropertyList &properties )
187  {
188  std::string keys[] = { "source", "target" };
189  size_t size = sizeof( keys ) / sizeof( std::string );
190  for( size_t i = 0; i < size; ++i )
191  {
192  URL url;
193  properties.Get( keys[i], url );
194  URL::ParamsMap params = url.GetParams();
195  params["xrdcl.intent"] = "tpc";
196  url.SetParams( params );
197  properties.Set( keys[i], url.GetURL() );
198  }
199  }
200 
201  //------------------------------------------------------------------------
203  //------------------------------------------------------------------------
204  CopyProcessImpl *pImpl;
205  };
206 }
207 
208 #endif // __XRD_CL_COPY_PROCESS_HH__
static void MarkTPC(PropertyList &properties)
Mark the URLs in the property list as ment for TPC.
Definition: XrdClCopyProcess.hh:186
std::map< std::string, std::string > ParamsMap
Definition: XrdClURL.hh:33
virtual void EndJob(uint16_t jobNum, const PropertyList *result)
Definition: XrdClCopyProcess.hh:68
void SetParams(const std::string &params)
Set params.
Interface for copy progress notification.
Definition: XrdClCopyProcess.hh:41
XRootDStatus Prepare()
std::string GetURL() const
Get the URL.
Definition: XrdClURL.hh:86
virtual void BeginJob(uint16_t jobNum, uint16_t jobTotal, const URL *source, const URL *destination)
Definition: XrdClCopyProcess.hh:54
bool Get(const std::string &name, Item &item) const
Definition: XrdClPropertyList.hh:65
XRootDStatus Run(CopyProgressHandler *handler)
Run the copy jobs.
Request status.
Definition: XrdClXRootDResponses.hh:218
CopyProcess()
Constructor.
Definition: XrdClAnyObject.hh:25
Copy the data from one point to another.
Definition: XrdClCopyProcess.hh:107
virtual ~CopyProcess()
Destructor.
void Set(const std::string &name, const Item &value)
Definition: XrdClPropertyList.hh:52
virtual bool ShouldCancel(uint16_t jobNum)
Determine whether the job should be canceled.
Definition: XrdClCopyProcess.hh:92
virtual ~CopyProgressHandler()
Definition: XrdClCopyProcess.hh:44
URL representation.
Definition: XrdClURL.hh:30
XRootDStatus AddJob(const PropertyList &properties, PropertyList *results)
const ParamsMap & GetParams() const
Get the URL params.
Definition: XrdClURL.hh:239
virtual void JobProgress(uint16_t jobNum, uint64_t bytesProcessed, uint64_t bytesTotal)
Definition: XrdClCopyProcess.hh:82
A key-value pair map storing both keys and values as strings.
Definition: XrdClPropertyList.hh:40
CopyProcessImpl * pImpl
Pointer to implementation.
Definition: XrdClCopyProcess.hh:204