def bulk_heartbeat(self, ids):
self.rethinker.table('services').get_all(*ids).update({ 'last_heartbeat': r.now(), 'load': os.getloadavg()[1] }).run()
# send a non-bulk heartbeat for each id we *didn't* just update
missing_ids = set(ids) - set(self.rethinker.table('services').get_all(*ids).get_field('id').run())
for id in missing_ids:
pool, node, segment = id.split(":")
port = settings['WRITE_PORT'] if pool == 'trough-write' else settings['READ_PORT']
url = 'http://%s:%s/?segment=%s' % (node, port, segment)
self.heartbeat(pool=pool, node=node, segment=segment, port=port, url=url, ttl=round(settings['SYNC_LOOP_TIMING'] * 4))
评论列表
文章目录