1717#include < boost/bind.hpp>
1818#include < boost/lexical_cast.hpp>
1919#include < boost/version.hpp>
20+ #include < boost/chrono.hpp>
2021
2122constexpr int kCommandTimeoutMs = 5000 ; // /< Default command timeout in milliseconds.
2223
@@ -57,11 +58,11 @@ void uRaftController::init() {
5758 return ;
5859 }
5960
60- check_cmd_status_timer_.expires_from_now ( boost::posix_time::millisec (opt_.check_cmd_status_period ));
61+ check_cmd_status_timer_.expires_after ( std::chrono::milliseconds (opt_.check_cmd_status_period ));
6162 check_cmd_status_timer_.async_wait (boost::bind (&uRaftController::checkCommandStatus, this ,
6263 boost::asio::placeholders::error));
6364
64- check_node_status_timer_.expires_from_now ( boost::posix_time::millisec (opt_.check_node_status_period ));
65+ check_node_status_timer_.expires_after ( std::chrono::milliseconds (opt_.check_node_status_period ));
6566 check_node_status_timer_.async_wait (boost::bind (&uRaftController::checkNodeStatus, this ,
6667 boost::asio::placeholders::error));
6768
@@ -249,7 +250,7 @@ void uRaftController::checkCommandStatus(const boost::system::error_code &error)
249250 }
250251 }
251252
252- check_cmd_status_timer_.expires_from_now ( boost::posix_time::millisec (opt_.check_cmd_status_period ));
253+ check_cmd_status_timer_.expires_after ( std::chrono::milliseconds (opt_.check_cmd_status_period ));
253254 check_cmd_status_timer_.async_wait (boost::bind (&uRaftController::checkCommandStatus, this ,
254255 boost::asio::placeholders::error));
255256}
@@ -295,7 +296,7 @@ void uRaftController::checkNodeStatus(const boost::system::error_code &error) {
295296 }
296297 }
297298
298- check_node_status_timer_.expires_from_now ( boost::posix_time::millisec (opt_.check_node_status_period ));
299+ check_node_status_timer_.expires_after ( std::chrono::milliseconds (opt_.check_node_status_period ));
299300 check_node_status_timer_.async_wait (boost::bind (&uRaftController::checkNodeStatus, this ,
300301 boost::asio::placeholders::error));
301302}
@@ -328,7 +329,7 @@ void uRaftController::scheduleDeadRecovery() {
328329 if (dead_recovery_pending_) { return ; }
329330 dead_recovery_pending_ = true ;
330331
331- dead_recovery_timer_.expires_from_now ( boost::posix_time::millisec (kDeadRecoveryDelayMs ));
332+ dead_recovery_timer_.expires_after ( std::chrono::milliseconds (kDeadRecoveryDelayMs ));
332333 dead_recovery_timer_.async_wait ([this ](const boost::system::error_code &ec) {
333334 if (ec) { return ; }
334335
@@ -353,7 +354,7 @@ void uRaftController::scheduleDeadRecovery() {
353354}
354355
355356void uRaftController::setSlowCommandTimeout (int timeout) {
356- cmd_timeout_timer_.expires_from_now ( boost::posix_time::millisec (timeout));
357+ cmd_timeout_timer_.expires_after ( std::chrono::milliseconds (timeout));
357358 cmd_timeout_timer_.async_wait ([this , timeout](const boost::system::error_code & error) {
358359 if (!error) {
359360 syslog (LOG_ERR, " Metadata server mode switching timeout after %d ms" , timeout);
@@ -631,7 +632,7 @@ void uRaftController::startPromotionBackoff(bool reset) {
631632 syslog (LOG_WARNING, " Promotion backoff enabled (%d ms), streak=%d" , backoff_ms,
632633 promotion_failure_streak_);
633634
634- promotion_backoff_timer_.expires_from_now ( boost::posix_time::millisec (backoff_ms));
635+ promotion_backoff_timer_.expires_after ( std::chrono::milliseconds (backoff_ms));
635636 promotion_backoff_timer_.async_wait ([this ](const boost::system::error_code &ec) {
636637 if (ec) { return ; }
637638 promotion_backoff_active_ = false ;
0 commit comments