Example #1
0
 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()
Example #2
0
 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()
Example #3
0
 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
Example #4
0
 def noop(self, req, ctx):
     return rnp.Null()
Example #5
0
 def noop(self, serverIP, timeout=1):
     return self.servers[serverIP].noop(rnp.Null(), timeout=timeout)
Example #6
0
 def resetServer(self, serverIP):
     while True:
         try:
             return self.servers[serverIP].resetServer(rnp.Null())
         except:
             continue
Example #7
0
 def getStatus(self, serverIP):
     return self.servers[serverIP].getStatus(rnp.Null())
Example #8
0
 def getLeader(self):
     server = random.choice(list(self.servers.values()))
     return server.getLeader(rnp.Null())