]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
heartbeatmap: simplify api
authorSage Weil <sage@newdream.net>
Thu, 28 Jul 2011 16:10:17 +0000 (09:10 -0700)
committerSage Weil <sage@newdream.net>
Thu, 28 Jul 2011 16:49:23 +0000 (09:49 -0700)
reset_timeout(), clear_timeout() makes more sense than "touch".

Signed-off-by: Sage Weil <sage@newdream.net>
src/common/HeartbeatMap.cc
src/common/HeartbeatMap.h
src/common/WorkQueue.cc

index 8e47b590c4631d70b63cc51a59151125750b05ae..3f15b3829cfc343cd50ecaa9df6fcdbaf1d1e41e 100644 (file)
@@ -53,12 +53,18 @@ void HeartbeatMap::remove_worker(heartbeat_handle_d *h)
   delete h;
 }
 
-void HeartbeatMap::touch_worker(heartbeat_handle_d *h, time_t grace)
+void HeartbeatMap::reset_timeout(heartbeat_handle_d *h, time_t grace)
 {
-  ldout(m_cct, 20) << "touch_worker " << h->thread << " grace " << grace << dendl;
+  ldout(m_cct, 20) << "reset_timeout " << h->thread << " grace " << grace << dendl;
   h->timeout = time(NULL) + grace;
 }
 
+void HeartbeatMap::clear_timeout(heartbeat_handle_d *h)
+{
+  ldout(m_cct, 20) << "clear_timeout " << h->thread << dendl;
+  h->timeout = 0;
+}
+
 bool HeartbeatMap::is_healthy()
 {
   m_rwlock.get_read();
index 5299e36f0ea17eff9103e2fab7a0ffb78a2ade91..fe0b932b5568262caeef15c0873890f56bc6261b 100644 (file)
@@ -40,7 +40,9 @@ class HeartbeatMap {
  public:
   heartbeat_handle_d *add_worker(pthread_t thread, std::string name);
   void remove_worker(heartbeat_handle_d *h);
-  void touch_worker(heartbeat_handle_d *h, time_t grace);
+
+  void reset_timeout(heartbeat_handle_d *h, time_t grace);
+  void clear_timeout(heartbeat_handle_d *h);
 
   bool is_healthy();
 
index 2d4f3a930fd6e8f677d52a16c30f13ecdd6b12d9..b7d7e14b78a13b61fac5e3fca21f0c00e22279af 100644 (file)
@@ -50,7 +50,7 @@ void ThreadPool::worker()
          processing++;
          ldout(cct,12) << "worker wq " << wq->name << " start processing " << item << dendl;
          _lock.Unlock();
-         cct->get_heartbeat_map()->touch_worker(hb, wq->timeout_interval);
+         cct->get_heartbeat_map()->reset_timeout(hb, wq->timeout_interval);
          wq->_void_process(item);
          _lock.Lock();
          wq->_void_process_finish(item);
@@ -67,7 +67,7 @@ void ThreadPool::worker()
     }
 
     ldout(cct,15) << "worker waiting" << dendl;
-    cct->get_heartbeat_map()->touch_worker(hb, 4);
+    cct->get_heartbeat_map()->reset_timeout(hb, 4);
     _cond.WaitInterval(cct, _lock, utime_t(2, 0));
   }
   ldout(cct,0) << "worker finish" << dendl;