hwc_binlog_state.cc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "hwc_binlog_state.h"
  2. // local
  3. #include "comm.h"
  4. #include "hwc_sync_unit.h"
  5. BinlogState::BinlogState(HwcStateManager* p_hwc_state_manager)
  6. : HwcStateBase()
  7. , p_hwc_sync_unit_(new HwcSyncUnit())
  8. {
  9. p_hwc_state_manager_ = p_hwc_state_manager;
  10. }
  11. BinlogState::~BinlogState()
  12. {
  13. DELETE(p_hwc_sync_unit_);
  14. }
  15. void BinlogState::Enter()
  16. {
  17. log4cplus_info(LOG_KEY_WORD "enter into binlog state...");
  18. }
  19. void BinlogState::Exit()
  20. {
  21. log4cplus_info(LOG_KEY_WORD "exit binlog state");
  22. }
  23. void BinlogState::HandleEvent()
  24. {
  25. // 获取本机dtc 写请求
  26. switch (CComm::registor.Regist())
  27. {
  28. case -DTC::EC_FULL_SYNC_STAGE:
  29. case -DTC::EC_INC_SYNC_STAGE:
  30. {
  31. if (p_hwc_sync_unit_->Run(&CComm::master)) {
  32. p_hwc_state_manager_->ChangeState(E_HWC_STATE_FAULT);
  33. }
  34. }
  35. break;
  36. case -DTC::EC_ERR_SYNC_STAGE:
  37. default:
  38. {
  39. log4cplus_error("hwc status is not correct , try use --fixed parament to start");
  40. p_hwc_state_manager_->ChangeState(E_HWC_STATE_FAULT);
  41. }
  42. break;
  43. }
  44. }