int SyncManager::insert(const uint64_t dest_ns_addr, const int64_t app_id, const uint64_t block_id, const uint64_t file_id, const int32_t type) { int32_t ret = DsRuntimeGlobalInformation::instance().is_destroyed() ? EXIT_SERVICE_SHUTDOWN : TFS_SUCCESS; if (TFS_SUCCESS== ret) { int64_t now = Func::get_monotonic_time(); warn_(now); ret = out_of_limit_() ? EXIT_QUEUE_FULL_ERROR : TFS_SUCCESS; } if (TFS_SUCCESS == ret && INVALID_SERVER_ID != dest_addr_) { tbutil::Mutex::Lock lock(mutex_); ++queue_size_; SyncFileEntry entry; entry.app_id_ = app_id; entry.block_id_ = block_id; entry.file_id_ = file_id; entry.dest_ns_addr_ = dest_ns_addr; entry.type_ = type; entry.source_ds_addr_ = self_addr_; entry.source_ns_addr_ = self_ns_addr_; entry.sync_fail_count_ = 0; entry.last_sync_time_ = 0; queue_.push_back(entry); } return ret; }
void SyncManager::run_() { int64_t now = 0; const int32_t MAX_TIMEOUT_MS = 1500; DsRuntimeGlobalInformation& rgi = DsRuntimeGlobalInformation::instance(); while (!rgi.is_destroyed() && !queue_.empty()) { do_sync_(MAX_TIMEOUT_MS, false); now = Func::get_monotonic_time(); warn_(now); usleep(5000); } const int32_t OVER_TIMEOUT_MS = 500; int32_t index = (queue_size_ % MAX_SYNC_FILE_ENTRY_COUNT) + 1; while (index-- > 0) { do_sync_(OVER_TIMEOUT_MS, true); } }
void Core::errorDialog(const std::string &errorMessage) { std::shared_ptr<Gtk::MessageDialog> warn_(new Gtk::MessageDialog(Glib::ustring(errorMessage))); warn_->run(); }