ARC SDK
DataMover.h
1 // -*- indent-tabs-mode: nil -*-
2 
3 #ifndef __ARC_DATAMOVER_H__
4 #define __ARC_DATAMOVER_H__
5 
6 #include <list>
7 #include <string>
8 
9 #include <arc/data/FileCache.h>
10 #include <arc/data/DataPoint.h>
11 #include <arc/data/DataSpeed.h>
12 #include <arc/data/DataStatus.h>
13 
14 namespace Arc {
15 
16  class Logger;
17  class URLMap;
18 
20 
25  class DataMover {
26  private:
27  bool be_verbose;
28  bool force_secure;
29  bool force_passive;
30  bool force_registration;
31  bool do_checks;
32  std::string verbose_prefix;
33  bool do_retries;
34  unsigned long long int default_min_speed;
35  time_t default_min_speed_time;
36  unsigned long long int default_min_average_speed;
37  time_t default_max_inactivity_time;
38  DataSpeed::show_progress_t show_progress;
39  std::string preferred_pattern;
40  bool cancelled;
43  Glib::Mutex lock_;
44  static Logger logger;
45  public:
47 
52  typedef void (*callback)(DataMover* mover, DataStatus status, void* arg);
54  DataMover();
56  ~DataMover();
58 
76  DataStatus Transfer(DataPoint& source, DataPoint& destination,
77  FileCache& cache, const URLMap& map,
78  callback cb = NULL, void *arg = NULL,
79  const char *prefix = NULL);
81 
105  DataStatus Transfer(DataPoint& source, DataPoint& destination,
106  FileCache& cache, const URLMap& map,
107  unsigned long long int min_speed,
108  time_t min_speed_time,
109  unsigned long long int min_average_speed,
110  time_t max_inactivity_time,
111  callback cb = NULL, void *arg = NULL,
112  const char *prefix = NULL);
114 
122  DataStatus Delete(DataPoint& url, bool errcont = false);
124  void Cancel();
126  bool verbose();
128  void verbose(bool);
130 
133  void verbose(const std::string& prefix);
135  bool retry();
137  void retry(bool);
139  void secure(bool);
141  void passive(bool);
143  void force_to_meta(bool);
145  bool checks();
147 
152  void checks(bool v);
154 
160  void set_default_min_speed(unsigned long long int min_speed,
161  time_t min_speed_time) {
162  default_min_speed = min_speed;
163  default_min_speed_time = min_speed_time;
164  }
166 
172  void set_default_min_average_speed(unsigned long long int min_average_speed) {
173  default_min_average_speed = min_average_speed;
174  }
176 
181  void set_default_max_inactivity_time(time_t max_inactivity_time) {
182  default_max_inactivity_time = max_inactivity_time;
183  }
186  show_progress = func;
187  }
189 
198  void set_preferred_pattern(const std::string& pattern) {
199  preferred_pattern = pattern;
200  }
201  };
202 
203 } // namespace Arc
204 
205 #endif // __ARC_DATAMOVER_H__
Arc namespace contains all core ARC classes.
Definition: ArcConfig.h:11
void set_default_max_inactivity_time(time_t max_inactivity_time)
Set maximal allowed time for no data transfer.
Definition: DataMover.h:181
~DataMover()
Destructor cancels transfer if active and waits for cancellation to finish.
Status code returned by many DataPoint methods.
Definition: DataStatus.h:54
void passive(bool)
Set if passive transfer should be used for FTP-like transfers.
A logger class.
Definition: Logger.h:493
FileCache provides an interface to all cache operations.
Definition: FileCache.h:61
A DataPoint represents a data resource and is an abstraction of a URL.
Definition: DataPoint.h:121
DataStatus Delete(DataPoint &url, bool errcont=false)
Delete the file at url.
bool verbose()
Returns whether printing information about transfer status is activated.
void Cancel()
Cancel transfer, cleaning up any data written or registered.
DataMover provides an interface to transfer data between two DataPoints.
Definition: DataMover.h:25
void set_preferred_pattern(const std::string &pattern)
Set a preferred pattern for ordering of replicas.
Definition: DataMover.h:198
void set_default_min_speed(unsigned long long int min_speed, time_t min_speed_time)
Set minimal allowed transfer speed (default is 0) to &#39;min_speed&#39;.
Definition: DataMover.h:160
void force_to_meta(bool)
Set if file should be transferred and registered even if such LFN is already registered and source is...
void secure(bool)
Set if high level of security (encryption) will be used during transfer if available.
URLMap allows mapping certain patterns of URLs to other URLs.
Definition: URLMap.h:22
void(* callback)(DataMover *mover, DataStatus status, void *arg)
Callback function which can be passed to Transfer().
Definition: DataMover.h:52
void(* show_progress_t)(FILE *o, const char *s, unsigned int t, unsigned long long int all, unsigned long long int max, double instant, double average)
Callback for output of transfer status.
Definition: DataSpeed.h:59
DataStatus Transfer(DataPoint &source, DataPoint &destination, FileCache &cache, const URLMap &map, callback cb=NULL, void *arg=NULL, const char *prefix=NULL)
Initiates transfer from &#39;source&#39; to &#39;destination&#39;.
void set_progress_indicator(DataSpeed::show_progress_t func=NULL)
Set function which is called every second during the transfer.
Definition: DataMover.h:185
bool retry()
Returns whether transfer will be retried in case of failure.
void set_default_min_average_speed(unsigned long long int min_average_speed)
Set minimal allowed average transfer speed.
Definition: DataMover.h:172
DataMover()
Constructor. Sets all transfer parameters to default values.
bool checks()
Returns true if extra checks are made before transfer starts.