def waitForSMRB(self): db_id = self.cfg["PROCESSING_DATA_BLOCK"] db_prefix = self.cfg["DATA_BLOCK_PREFIX"] num_stream = self.cfg["NUM_STREAM"] self.db_key = SMRBDaemon.getDBKey(db_prefix, self.id, num_stream, db_id) # port of the SMRB daemon for this stream smrb_port = SMRBDaemon.getDBMonPort(self.id) # wait up to 30s for the SMRB to be created smrb_wait = 60 smrb_exists = False while not smrb_exists and smrb_wait > 0 and not self.quit_event.isSet( ): self.log(2, "trying to open connection to SMRB") smrb_sock = sockets.openSocket(DL, "localhost", smrb_port, 1) if smrb_sock: smrb_sock.send("smrb_status\r\n") junk = smrb_sock.recv(65536) smrb_sock.close() smrb_exists = True else: sleep(1) smrb_wait -= 1 return smrb_exists
def waitForSMRB (self): db_id = self.cfg["RECEIVING_DATA_BLOCK"] db_prefix = self.cfg["DATA_BLOCK_PREFIX"] num_stream = self.cfg["NUM_STREAM"] self.db_key = SMRBDaemon.getDBKey (db_prefix, self.id, num_stream, db_id) # port of the SMRB daemon for this stream smrb_port = SMRBDaemon.getDBMonPort(self.id) # wait up to 30s for the SMRB to be created smrb_wait = 60 smrb_exists = False while not smrb_exists and smrb_wait > 0 and not self.quit_event.isSet(): self.log(2, "trying to open connection to SMRB") smrb_sock = sockets.openSocket (DL, "localhost", smrb_port, 1) if smrb_sock: smrb_sock.send ("smrb_status\r\n") junk = smrb_sock.recv (65536) smrb_sock.close() smrb_exists = True else: sleep (1) smrb_wait -= 1 return smrb_exists
def getSMRBCapacity(stream_ids, quit_event, dl): smrbs = {} rval = 0 for stream_id in stream_ids: if quit_event.isSet(): continue port = SMRBDaemon.getDBMonPort(stream_id) sock = sockets.openSocket(dl, "localhost", port, 1) if sock: sock.send("smrb_status\n") data = sock.recv(65536) smrbs[stream_id] = json.loads(data) sock.close() return rval, smrbs
def getSMRBCapacity (stream_ids, quit_event, dl): smrbs = {} rval = 0 for stream_id in stream_ids: if quit_event.isSet(): continue port = SMRBDaemon.getDBMonPort (stream_id) sock = sockets.openSocket (dl, "localhost", port, 1) if sock: try: sock.settimeout(1) sock.send ("smrb_status\n") data = sock.recv(65536) except socket.error, e: print "socket connection to SMRB failed" else: smrbs[stream_id] = json.loads(data) sock.close()