Esempio n. 1
0
 def heartbeat_reply(self, stats):
     #print 'heartbeat_reply', self.address, stats, self.online
     if self.shut_down:
         return
     if not self.online:
         return
     if stats == None:
         self.active_sessions = None
         self.go_offline()
     else:
         sessions_created = active_sessions = active_streams = preceived = ptransmitted = 0
         for line in stats.splitlines():
             line_parts = line.split(':', 1)
             if line_parts[0] == 'sessions created':
                 sessions_created = int(line_parts[1])
             elif line_parts[0] == 'active sessions':
                 active_sessions = int(line_parts[1])
             elif line_parts[0] == 'active streams':
                 active_streams = int(line_parts[1])
             elif line_parts[0] == 'packets received':
                 preceived = int(line_parts[1])
             elif line_parts[0] == 'packets transmitted':
                 ptransmitted = int(line_parts[1])
             self.update_active(active_sessions, sessions_created, active_streams, preceived, ptransmitted)
     to = TimeoutInact(self.heartbeat, self.hrtb_ival)
     to.spread_runs(0.1)
     to.go()
Esempio n. 2
0
 def go_offline(self):
     if self.shut_down:
         return
     #print 'go_offline', self.address, self.online
     if self.online:
         self.online = False
         to = TimeoutInact(self.version_check, self.hrtb_retr_ival)
         to.spread_runs(0.1)
         to.go()
Esempio n. 3
0
 def version_check_reply(self, version):
     if self.shut_down:
         return
     if version == '20040107':
         self.go_online()
     elif self.online:
         self.go_offline()
     else:
         to = TimeoutInact(self.version_check, self.hrtb_retr_ival)
         to.spread_runs(0.1)
         to.go()