當前位置: 首頁>>代碼示例>>Python>>正文


Python SettingsLibrary.getJolokiaURL方法代碼示例

本文整理匯總了Python中SettingsLibrary.getJolokiaURL方法的典型用法代碼示例。如果您正苦於以下問題:Python SettingsLibrary.getJolokiaURL方法的具體用法?Python SettingsLibrary.getJolokiaURL怎麽用?Python SettingsLibrary.getJolokiaURL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SettingsLibrary的用法示例。


在下文中一共展示了SettingsLibrary.getJolokiaURL方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getClusterRoles

# 需要導入模塊: import SettingsLibrary [as 別名]
# 或者: from SettingsLibrary import getJolokiaURL [as 別名]
def getClusterRoles(shardName, numOfShards=3, numOfTries=3, sleepBetweenRetriesInSecs=1, port=8181, *ips):
    """Given a shardname (e.g. shard-inventory-config), number of shards and bunch of ips

    determines what role each ip has in an Akka (Raft based) cluster
    result would look like
    {'10.194.126.118':'Leader', '10.194.126.118':'Follower', '10.194.126.117': None}
    """
    dict = {}
    for ip in ips:
        i = 1
        dict[ip] = None

        while i <= numOfShards:
            shardMemberName = "member-" + str(i) + "-" + shardName
            j = 1

            while j <= numOfTries:
                print("Try number " + str(j))
                try:
                    print("finding if" + ip + "is leader for shardName =" + shardMemberName)
                    url = SettingsLibrary.getJolokiaURL(ip, str(port), str(i), shardName)
                    resp = UtilLibrary.get(url)
                    print(resp)
                    if resp.status_code != 200:
                        sleep(sleepBetweenRetriesInSecs)
                        continue
                    print(resp.text)
                    data = json.loads(resp.text)
                    if 'value' in data:
                        dataValue = data['value']
                        print("datavalue RaftState is", dataValue['RaftState'])
                        if dataValue['RaftState'] == 'Follower':
                            dict[ip] = 'Follower'
                            break
                        elif dataValue['RaftState'] == 'Leader':
                            dict[ip] = 'Leader'
                except:
                    e = sys.exc_info()[0]
                    print("Try" + str(j) + ":An error occurred when finding leader on" + ip +
                          " for shardName:" + shardMemberName)
                    print(e)
                    sleep(sleepBetweenRetriesInSecs)
                    continue
                finally:
                    j = j + 1

            if dict[ip] is not None:
                break
            i = i + 1

    return dict
開發者ID:cyclefusion,項目名稱:integration,代碼行數:53,代碼來源:ClusterStateLibrary.py

示例2: getClusterRoles

# 需要導入模塊: import SettingsLibrary [as 別名]
# 或者: from SettingsLibrary import getJolokiaURL [as 別名]
def getClusterRoles(shardName,numOfShards=3,numOfTries=3,sleepBetweenRetriesInSecs=1,port=8181,*ips):
    dict={}
    for ip in ips:
      i=1
      dict[ip]=None
      bFollower = 0
      while i <= numOfShards:
        shardMemberName = "member-"+str(i)+"-"+shardName;
        j=1

        while j <= numOfTries:
            print "Try number "+str(j)
            try:
                print "finding if"+ ip +"is leader for shardName ="+shardMemberName
                url = SettingsLibrary.getJolokiaURL(ip,str(port),str(i),shardName)
                resp = UtilLibrary.get(url)
                print resp
                if(resp.status_code != 200):
                    continue
                data = json.loads(resp.text)
                if('value' in data):
                    dataValue = data['value']
                    if(dataValue['RaftState']=='Follower'):
                        dict[ip]='Follower'
                        break;
                    elif(dataValue['RaftState']=='Leader'):
                        dict[ip]='Leader'
            except:
                e = sys.exc_info()[0]
                print "Try"+str(j)+":An error occurred when finding leader on"+ip+" for shardName:" +shardMemberName
                print e
                sleep(sleepBetweenRetriesInSecs)
                continue
            finally:
                j=j+1

        if(dict[ip]!=None):
            break;
        i=i+1

    return dict
開發者ID:Cygnus-Labs,項目名稱:opendaylight-integration,代碼行數:43,代碼來源:ClusterStateLibrary.py


注:本文中的SettingsLibrary.getJolokiaURL方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。