archiver.h

Go to the documentation of this file.
00001 #ifndef __archiver_h__
00002 #define __archiver_h__
00003 
00004 #include <string>
00005 #include <map>
00006 
00007 #include "asserts.h"
00008 #include "estring.h"
00009 #include "timer.h"
00010 #include "exec.h"
00011 #include "rconfig.h"
00012 #include "logger.h"
00013 #include "vaulter.h"
00014 #include "reporter.h"
00015 
00016 /** Map exit codes and signal numbers to verbose strings */
00017 class rstat
00018 {
00019 public:
00020         rstat();
00021         const std::string& exit(const int a_int) const;
00022         const std::string& signal(const int a_int) const;
00023 
00024 private:
00025         std::map<int,std::string> m_exit_str;
00026         std::map<int,std::string> m_signal_str;
00027         std::string m_unknown_exit;
00028         std::string m_unknown_signal;
00029 };
00030 
00031 extern class rstat rsync_estat_str;
00032 
00033 class archiver;
00034 
00035 /** Archive the paths associated with a single job */
00036 class job_archiver {
00037 public:
00038         enum archiving_status {
00039                 status_pending,
00040                 status_processing,
00041                 status_retry_later,
00042                 status_fatal_error,
00043                 status_error,
00044                 status_completed,
00045                 status_done,
00046         };
00047 
00048         job_archiver(const job * a_job);
00049         const std::string prefix(void);
00050         const std::string id(void);
00051         void clear(void);
00052         void end(void);
00053         const archiving_status status(void);
00054         void start(void);
00055         void process(void);
00056 
00057         single_job_report report(void) const;
00058 
00059 private:
00060         const job* m_job;
00061         archiving_status m_status;
00062         timer m_timer;
00063         execute m_exec;
00064         bool m_success;
00065         estring m_io_out;
00066         estring m_io_err;
00067         pid_t m_child_pid;
00068         job_path_report m_jpr;
00069         single_job_report m_jr;
00070         std::string m_error_msg;
00071 
00072         void mf_do_chores(void);
00073         void mf_process_report(const std::string& a_str);
00074         void mf_process_child_io(bool a_finalize);
00075         void mf_process_rsync_io(
00076                 execute& a_exec, 
00077                 uint16 a_timeout,
00078                 uint64& a_files_total,
00079                 uint64& a_files_xferd,
00080                 uint64& a_size_total,
00081                 uint64& a_size_xferd,
00082                 bool& a_overflow_detected
00083                 );
00084         void mf_parse_rsync_io(
00085                 std::string a_str, 
00086                 uint64& a_files_total,
00087                 uint64& a_files_xferd,
00088                 uint64& a_size_total,
00089                 uint64& a_size_xferd
00090                 );
00091         void mf_trim_string(std::string& a_str);
00092         void mf_parse_report(const std::string& a_str);
00093 };
00094 
00095 /** Create (or update an existing) archive in the selected vault */
00096 class archive_manager {
00097 public:
00098         archive_manager();
00099 
00100         void clear(void);
00101         void init(void);
00102         const bool initialized(void) const;
00103 
00104         void archive(void);
00105 
00106         const std::string archive_path(void) const;
00107         const std::string working_archive_path(void) const;
00108 
00109 private:
00110         std::vector<job_archiver*> m_jobs;
00111         bool m_initialized;
00112 
00113         void mf_log_status(void);
00114 };
00115 
00116 extern archive_manager archiver;
00117 
00118 #endif

Generated on Mon Jul 12 12:02:41 2004 for rvm by doxygen 1.3.6