hwc_sync_unit.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * =====================================================================================
  3. *
  4. * Filename: sync_unit.h
  5. *
  6. * Description: sync_unit class definition.
  7. *
  8. * Version: 1.0
  9. * Created: 13/01/2021
  10. * Revision: none
  11. * Compiler: gcc
  12. *
  13. * Author: chenyujie, chenyujie28@jd.com@jd.com
  14. * Company: JD.com, Inc.
  15. *
  16. * =====================================================================================
  17. */
  18. #ifndef __SYNC_UNIT_H
  19. #define __SYNC_UNIT_H
  20. #include <sys/types.h>
  21. #include <unistd.h>
  22. #include <signal.h>
  23. // local
  24. #include "async_file.h"
  25. // common
  26. #include "log/log.h"
  27. #include "task/task_request.h"
  28. #include "task/task_pkey.h"
  29. #include "mem_check.h"
  30. #include "hwc_binlog_obj.h"
  31. #include "table/hotbackup_table_def.h"
  32. #include "table/table_def_manager.h"
  33. // libs/api/cc_api/include
  34. #include "dtcapi.h"
  35. enum E_HWC_SYNC_ERROR_ID
  36. {
  37. E_HWC_SYNC_NORMAL_EXIT,
  38. E_HWC_ACCOUNT_CHECK_FAILL = -100,
  39. E_HWC_SYNC_DTC_ERROR
  40. };
  41. class HwcSync
  42. {
  43. public:
  44. HwcSync(DTC::Server* p_server);
  45. ~HwcSync();
  46. int Run();
  47. void SetLimit(int iLimit) {
  48. // Here we need sync one by one
  49. i_limit_ = iLimit;
  50. }
  51. public:
  52. int query_cold_server(DTCJobOperation* p_job , const DTCValue* key);
  53. void decode_hotbin_result(ResultSet* o_hot_res, const HwcBinlogCont& o_hwc_bin);
  54. void sql_statement_query(const DTCValue* p_key , std::string& s_sql);
  55. int get_current_time();
  56. private:
  57. int i_limit_;
  58. DTC::Server* p_master_;
  59. JournalID o_journal_id_;
  60. };
  61. class HwcSyncUnit {
  62. public:
  63. HwcSyncUnit();
  64. ~HwcSyncUnit();
  65. bool Run(DTC::Server* m , int limit = 1);
  66. private:
  67. HwcSync* p_hwc_sync_;
  68. };
  69. #endif