コード例 #1
0
ファイル: inputHelper.py プロジェクト: deenaariff/jChain
 def handle_resolve(self,tokens):
     if len(tokens) < 1:
         print um.MISSING_ARGS
     else:
         _ip = self.cluster.nodes[tokens[0]]
         rsp = dataHelper.make_request(_ip,"nodes/resolve/")
         print rsp
コード例 #2
0
ファイル: inputHelper.py プロジェクト: deenaariff/jChain
 def handle_chain(self,tokens):
     if len(tokens) < 1:
         print um.MISSING_ARGS
     else:
         _ip = self.cluster.nodes[tokens[0]]
         rsp = dataHelper.make_request(_ip,"crash/",tokens)
         print rsp
コード例 #3
0
    def handle_get_data(self):

        for ip in self.cluster.routes:

            rsp = dataHelper.make_request(ip, "getKeyStore")

            keys = ["Endpoint", "Term", "Commit Index", "Data"]

            for key in keys:
                print key + ":", rsp[key]

            print
コード例 #4
0
    def handle_update(self, tokens):
        if len(tokens) < 2:
            print um.MISSING_ARGS
        else:

            self.cluster.find_leader()

            rsp = dataHelper.make_request(self.cluster.leader, "update/",
                                          tokens)

            keys = ["Total Logs", "Key", "Value", "State", "Term"]

            for key in keys:
                print key + ":", rsp[key]
コード例 #5
0
    def print_cluster(self):

        data = []
        for url in self.routes:
            tmp = []
            try:
                rsp = dh.make_request(url)
                for key in self.default_keys:
                    tmp.append(rsp[key])
            except Exception:
                tmp = ["DEAD"] * len(self.default_keys)
            data.append(tmp)

        print tabulate(data, headers=self.default_keys)
コード例 #6
0
 def find_leader(self):
     if len(self.routes) > 0:
         while not self.leader:
             for url in self.urls:
                 try:
                     rsp = dh.make_request(url)
                     if rsp['State'] == 'LEADER':
                         self.leader = "http://" + rsp['IP Address'] + ":" + str(rsp['Endpoint Port'])
                 except urllib2.HTTPError, e:
                     print('HTTPError = ' + str(e.code))
                 except urllib2.URLError, e:
                     print('URLError = ' + str(e.reason))
                     print url + " not reachable"
                 except Exception, e:
                     print e
コード例 #7
0
 def handle_crash(self, tokens):
     if len(tokens) < 1:
         print um.MISSING_ARGS
     else:
         rsp = dataHelper.make_request(self.cluster.leader, "crash/",
                                       tokens)