rvm  1.11
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Go to the documentation of this file.
1 #ifndef __archiver_h__
2 #define __archiver_h__
4 #include <string>
5 #include <map>
7 #include "asserts.h"
8 #include "estring.h"
9 #include "timer.h"
10 #include "exec.h"
11 #include "rconfig.h"
12 #include "logger.h"
13 #include "vaulter.h"
14 #include "reporter.h"
16 /** Map exit codes and signal numbers to verbose strings */
17 class rstat
18 {
19 public:
20  rstat();
21  const std::string& exit(const int a_int) const;
22  const std::string& signal(const int a_int) const;
24 private:
25  std::map<int,std::string> m_exit_str;
26  std::map<int,std::string> m_signal_str;
27  std::string m_unknown_exit;
28  std::string m_unknown_signal;
29 };
31 extern class rstat rsync_estat_str;
33 class archiver;
35 /** Archive the paths associated with a single job */
36 class job_archiver {
37 public:
46  };
48  job_archiver(const job * a_job);
49  const std::string prefix(void);
50  const std::string id(void);
51  void clear(void);
52  void end(void);
53  const archiving_status status(void);
54  void start(void);
55  void process(void);
57  single_job_report report(void) const;
59 private:
60  const job* m_job;
66  bool m_success;
69  pid_t m_child_pid;
72  std::string m_error_msg;
74  void mf_do_chores(void);
75  void mf_process_report(const std::string& a_str);
76  void mf_process_child_io(bool a_finalize);
78  execute& a_exec,
79  uint16 a_timeout,
80  uint64& a_files_total,
81  uint64& a_files_xferd,
82  uint64& a_size_total,
83  uint64& a_size_xferd,
84  bool& a_overflow_detected
85  );
86  void mf_parse_rsync_io(
87  std::string a_str,
88  uint64& a_files_total,
89  uint64& a_files_xferd,
90  uint64& a_size_total,
91  uint64& a_size_xferd
92  );
93  void mf_trim_string(std::string& a_str);
94  void mf_parse_report(const std::string& a_str);
95 };
97 /** Create (or update an existing) archive in the selected vault */
99 public:
100  archive_manager();
102  void clear(void);
103  void init(void);
104  const bool initialized(void) const;
106  void archive(void);
108  const std::string archive_path(void) const;
109  const std::string working_archive_path(void) const;
111 private:
112  std::vector<job_archiver*> m_jobs;
115  void mf_log_status(void);
116 };
120 #endif
std::string m_unknown_exit
Definition: archiver.h:27
Archive the paths associated with a single job.
Definition: archiver.h:36
timer m_timer
Definition: archiver.h:62
An extended string class.
Definition: estring.h:52
void clear(void)
Clear the job archiver and return it to it's initial state.
Definition: archiver.cc:166
single_job_report report(void) const
Return the job report for this job.
Definition: archiver.cc:388
Hold configuration data for a single job.
Definition: rconfig.h:136
const std::string prefix(void)
Generate a job prefix string.
Definition: archiver.cc:137
void clear(void)
Clear the archive manager and clear the job list.
Definition: archiver.cc:1067
void mf_log_status(void)
Give a status report.
Definition: archiver.cc:1128
bool m_success
Definition: archiver.h:66
A single job report.
Definition: reporter.h:164
bool m_initialized
Definition: archiver.h:113
void process(void)
Parent processor for a job.
Definition: archiver.cc:327
void mf_process_child_io(bool a_finalize)
Process I/O from the child.
Definition: archiver.cc:730
pid_t m_child_pid
Definition: archiver.h:69
single_job_report m_jr
Definition: archiver.h:71
void mf_parse_report(const std::string &a_str)
const job * m_job
Definition: archiver.h:60
archive_manager archiver
The global archive manager.
Definition: archiver.cc:1536
std::map< int, std::string > m_exit_str
Definition: archiver.h:25
void start(void)
Begin processing.
Definition: archiver.cc:217
const std::string & exit(const int a_int) const
Get a verbose string for an exit code.
Definition: archiver.cc:97
void end(void)
End any processes handling this job.
Definition: archiver.cc:184
void mf_trim_string(std::string &a_str)
Trim off all non-digit leading and trailing characters from a string.
Definition: archiver.cc:807
estring m_io_out
Definition: archiver.h:67
std::vector< job_archiver * > m_jobs
Definition: archiver.h:112
void mf_do_chores(void)
Child processor for a job.
Definition: archiver.cc:406
void mf_process_rsync_io(execute &a_exec, uint16 a_timeout, uint64 &a_files_total, uint64 &a_files_xferd, uint64 &a_size_total, uint64 &a_size_xferd, bool &a_overflow_detected)
Process I/O from rsync.
Definition: archiver.cc:943
std::map< int, std::string > m_signal_str
Definition: archiver.h:26
archiving_status m_status
Definition: archiver.h:61
job_path_report m_jpr
Definition: archiver.h:70
const std::string & signal(const int a_int) const
Get a verbose string for a signal number.
Definition: archiver.cc:106
void mf_process_report(const std::string &a_str)
Definition: archiver.cc:715
Job report for an rsync run on a single path.
Definition: reporter.h:86
estring m_io_err
Definition: archiver.h:68
class rstat rsync_estat_str
Definition: archiver.cc:114
std::string m_error_msg
Definition: archiver.h:72
Map exit codes and signal numbers to verbose strings.
Definition: archiver.h:17
Fork a child process or execute an external program.
Definition: exec.h:21
void init(void)
Initialize the archive manager.
Definition: archiver.cc:1078
Definition: archiver.cc:1058
job_archiver(const job *a_job)
Definition: archiver.cc:124
bool m_rsync_timeout_flag
Definition: archiver.h:64
const archiving_status status(void)
Return the processing status of this job archiver.
Definition: archiver.cc:203
Create (or update an existing) archive in the selected vault.
Definition: archiver.h:98
void mf_parse_rsync_io(std::string a_str, uint64 &a_files_total, uint64 &a_files_xferd, uint64 &a_size_total, uint64 &a_size_xferd)
Parse I/O from rsync.
Definition: archiver.cc:821
execute m_exec
Definition: archiver.h:65
void archive(void)
Archive jobs.
Definition: archiver.cc:1235
const std::string working_archive_path(void) const
Return the absolute path to the unfinished working archive directory.
Definition: archiver.cc:1520
timer m_io_timer
Definition: archiver.h:63
Definition: archiver.cc:26
const bool initialized(void) const
Return the initialized status of the archive manager.
Definition: archiver.cc:1117
std::string m_unknown_signal
Definition: archiver.h:28
const std::string id(void)
Generate a job id string.
Definition: archiver.cc:149
Used as a stopwatch.
Definition: timer.h:29
const std::string archive_path(void) const
Return an absolute path to the finished archive directory.
Definition: archiver.cc:1505