def resetServer(self, req, ctx): shutil.rmtree(os.path.join(self.config['log_path']), ignore_errors=True) # data collection shutil.rmtree(os.path.join(self.config['data_path']), ignore_errors=True) return rnp.Null()
def restartServer(self, req, ctx): try: self.timestamp(True, req.flag) except Exception as e: mprint(e) self.server.stop(0) os.execvp('python3', ['python3', 'server.py', str(self.port)]) return rnp.Null()
def getTimestamp(self): timestamps = [] for _, server in self.servers.items(): resp = server.getTimestamp(rnp.Null()) timestamps += list( map(lambda x: (x.term, float(x.time), x.type), resp.timestamps)) timestamps.sort() return timestamps
def noop(self, req, ctx): return rnp.Null()
def noop(self, serverIP, timeout=1): return self.servers[serverIP].noop(rnp.Null(), timeout=timeout)
def resetServer(self, serverIP): while True: try: return self.servers[serverIP].resetServer(rnp.Null()) except: continue
def getStatus(self, serverIP): return self.servers[serverIP].getStatus(rnp.Null())
def getLeader(self): server = random.choice(list(self.servers.values())) return server.getLeader(rnp.Null())